How to specify multiple hostnames in ingress-nginx @do-loadbalancer-hostname

Posted March 4, 2021 1.3k views
NginxLoad BalancingKubernetes


I am following to setup TLS in my cluster.
I have 2 host names and I want to have both of these subdomains to be added in my nginx annotation.

I cant give comma seperated as it is throughing below warnings:

Warning  SyncLoadBalancerFailed  4s (x2 over 9s)     service-controller  Error syncing load balancer: failed to update load balancer status: Service "ingress-nginx-controller" is invalid: status.loadBalancer.ingress[0].hostname: Invalid value: ",": a DNS-1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. '', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')

Thanks in advance

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

Hi @ratnautilman,

Having the LB hostname annotation on a service is solely used for getting around internal routing issues as specified in our docs: Accessing by Hostname :: How to Configure Advanced Load Balancer Settings in Kubernetes Clusters

As long as your multiple hostnames resolve to the LB in question and a single hostname is set using the annotation, you will not experience the issue described in the docs link above. Other than the bug listed in the docs, there is no technical reason to need to specify this annotation for more than one hostname.

Hope this helps!


John Kwiatkoski
Senior Developer Support Engineer - Kubernetes