I’m using DigitalOcean’s Kubernetes and installed 1-click apps Nginx ingress controller. I changed the algorithm of the load balancer to Least Connections. It works but every time the auto scale adds or removes nodes, the load balancer will set the algorithm back to Round Robin. How can I change the load balancer’s algorithm permanently?


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.

Chandan Sagar Pradhan
DigitalOcean Employee
DigitalOcean Employee badge
May 31, 2021
Accepted Answer

Hello @trungld ,

I believe you are setting the LoadBalancer(LB) algorithm from the cloud panel.

All LoadBalancers(LB) provisioned by Kubernetes are managed by the Cloud Controller Manager(CCM) running on the master. Any manual modifications to the LB through the cloud panel will be overwritten by the CCM during its reconciliation process to ensure the LB is configured properly with the state defined by the Kubernetes service.

In order to configure your LB you need to use Kubernetes service annotations. For information on how to apply annotations, you can use the command:

kubectl annotate --help

Docs for DO service annotations can be found here:

https://www.digitalocean.com/docs/kubernetes/how-to/configure-load-balancers/

Service annotations can also be found on our public GitHub repository:

https://github.com/digitalocean/digitalocean-cloud-controller-manager/blob/master/docs/controllers/services/annotations.md

To set the LB algorithm can you please try adding the below annotation to your LB.

service.beta.kubernetes.io/do-loadbalancer-algorithm: "least_connections"

Please find the below link for your reference:

https://docs.digitalocean.com/products/kubernetes/how-to/configure-load-balancers/#algorithm-annotation

Hope that this helps!

Best Regards, Chandan Sagar Pradhan

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.