Question

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

Posted March 4, 2021 1.3k views
NginxLoad BalancingKubernetes

Hi,

I am following https://www.digitalocean.com/community/tutorials/how-to-set-up-an-nginx-ingress-with-cert-manager-on-digitalocean-kubernetes#step-5-%E2%80%94-enabling-pod-communication-through-the-load-balancer-(optional) to setup TLS in my cluster.
I have 2 host names web.myapp.com and api.myapp.com I want to have both of these subdomains to be added in my nginx annotation.

service.beta.kubernetes.io/do-loadbalancer-hostname

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: "web.myapp.co.za,api.myapp.co.za": a DNS-1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and 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])?)*')

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!

Regards,

John Kwiatkoski
Senior Developer Support Engineer - Kubernetes