'kubernetes ingress predefine domain name?

I would like to do something like this: predefine domain name and reference that definition in all my ingresses, think of the following .yml file

DNS=mydomain.com
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: my-ingress
spec:
  rules:
  - host: app1.${DNS}
    http:
      paths:
      - pathType: Prefix
        path: "/"
        backend:
          service:
            name: service1
            port:
              number: 80
  - host: app2.${DNS}
    http:
      paths:
      - pathType: Prefix
        path: "/"
        backend:
          service:
            name: service2
            port:
              number: 80

Is something like this possible? Does any1 have another ideas? What if I wanted to define that 'DNS' externally in another file?

Also external preprocessor tools are unfortunately not an option because I am thinking about deployment using continuous delivery with tools like ArgoCD.

The background is that in our company we develop applications for our customers and install them on premise and we are just starting with the whole containerization stuff. And I am thinking about how I can minimize the configuration workload for deployment and instead of manually editing configurations like these for each of our applications I just want to define them once in a central configuration file and then let all of our applications use that file.

Another example for this would be the namespace for all of the kubernetes objects (not just ingress, but also deployments, services, configmaps etc.) which I also don't want to edit multiple times for multiple applications.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source