Define ingress without the wildcard subdomain assigned to the Ingress Controller

11/18/2019

I have an ingress controller answering that is answering to *.mycompany.com. Is it possible, whenever I define Ingress resources in my cluster, not to specify the whole thing some-service.mycompany.com but only the some-service part.

Thus, if I changed the domain name later on (or for example in my test env) I wouldn't need to specify some-service.test.mycompany.com but things would magically work without changing anything.

-- LIvanov
kubernetes
kubernetes-ingress

2 Answers

11/28/2019

Configuration you want to achieve is possible only in nginx but it's impossible to apply it in nginx-ingress due to limitation of "host:".

"ingress-redirect" is invalid: spec.rules[0].host: Invalid value: "~^subdomain\\..+\\..+$;": a DNS-1123 subdomain must consist of lower case alphanumeric characters, '-' or '.',.

It must start and end with an alphanumeric character (e.g. example.com, regex used for validation is [a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*') but nginx syntax allows to use syntax llike this: < server_name mail.*; >.

It would work if you put all configuration as http_snippet, but it's a lot of manual work (which you want to avoid).

I think the better solution is to use HELM. Put ingress yaml to helm chart and use values.my_domain in the chart to prepare Ingress object. Then all you need is to run helm install ingress-chart-name --set values.my_domain=example.com

-- PjoterS
Source: StackOverflow

11/18/2019

For most Ingress Controllers, if you don’t specify the hostname then that Ingress will be a default for anything not matching anything else. The only downside is you can only have one of these (per controller, depending on your layout).

-- coderanger
Source: StackOverflow