Kubernetes how to use round-robin(rr) load balancing strategy among pods

4/1/2020

I made a deployment and scaled out to 2 replicas. And I made a service to forward it.

I found that kube-proxy uses iptables for forwarding from Service to Pod. But the load balancing strategy of iptables is RANDOM.

How can I force my service to forward requests to 2 pods using round-robin strategy without switching my kube-proxy to userspace or ipvs mode?

-- Peng Deng
iptables
kubernetes

2 Answers

4/1/2020

You cannot.

But if you really don't want to change --proxy-mode flag on kube-proxy you can use some third-party proxy/loadbalancer (like HAProxy) and point it to your application. But this is usually not the best option as you need to make sure it's deployed with HA and it will also add complexity to your deployment.

-- HelloWorld
Source: StackOverflow

4/1/2020

You cannot, the strategies are only supported in ipvs mode. The option is even called --ipvs-scheduler.

-- coderanger
Source: StackOverflow