How to manage Kubernetes' LoadBalancer with Terraform

I use Terraform to provision and manage a Kubernetes cluster on DigitalOcean. Specifically I use DigitalOcean Terraform provider.

It is pretty straight forward to create a cluster.

At the same time DigitalOcean suggests to manage Kubernetes’ Load Balancers with kubectl. Meaning when I install ingress-nginx with kubectl, DigitalOcean will automatically create a LoadBalancer. However that particular LoadBalancer is not defined in a terraform file. Meaning I cannot get it’s IP(for setting a DNS), scale it or delete it.

Another problem is, if I first create a LoadBalancer with terraform. I still need an Ingress Controller. Now I install ingress-nginx with kubectl which will override the LoadBalancer previously created with terraform.

The question is: How to manage Kubernetes LoadBalancer with Terraform on DigitalOcean? Any examples or help is much appreciated.

Show comments

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.

Hi there,

There has been a similar issue raised on the official DigitalOcean Terraform provider repo here:

You can follow the example here:

Along with the changes from this PR here to get the IP address of the load balancer:

Hope that this helps.



This comment has been deleted