Question

How to set static IP for loadbalancer in Kubernetes?

Imagine a following situation: I have a Kubernetes cluster and I want to have a statically assigned IP to LoadBalancers within those clusters. How or where I can obtain those static IPs?

Whenever I tear down Kubernetes Pods, IPs are assigned dynamically, which is fine, but if I want to assign the Kubernetes LoadBalancer a static IP, I have no way of knowing which IP address should be set, hence I need to change DNS records every time Kubernetes Master assigns a new IP address.


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

What if we deleted the cluster and reuse the loadbalancer in the newly created cluster. I couldn’t find a way to achieve this. I tried to specify static IP in the service level but no matter what kubernetes creates a new LB. Cannot use the existing one.

Just searched all documentation and sites for some hours to see if something changes. But it seems that this is still not possible or at least not officially supported in any way.

It is very annoying when we are re-installing our ingress controller that the load balancer used ends up with a new IP which results in the need to update the the DNS entries and all our clients out there are going down.

I know that other cloud providers support static/stable IPs for their load balancer for kubernets.

@digitalocean: Isn’t there a supported way to keep the IP of the load banancers stable/static?

I dunno if this is too late, probably so, but in your Service yaml specify something like this:

loadBalancerIP: <your desired external ip>
type: LoadBalancer