Which algorithm Kubernetes uses to nevigate traffics in replicaset/deployment Which algorithm Kubernetes uses to nevigate traffics in replicaset/deployment kubernetes kubernetes

Which algorithm Kubernetes uses to nevigate traffics in replicaset/deployment


The algorithm applied to determine which pod will process the request depends on kube-proxy mode that is running.

  • In 1.0, the proxy works in mode called userspace and default algorithm is round robin.

  • In 1.2 mode iptables proxy was added, but still round robin is used due to iptables limitations.

  • In 1.8.0-beta, IP Virtual Server (IPVS) was introduced, it allow much more algorithms options, like:

    • RoundRobin;
    • WeightedRoundRobin;
    • LeastConnection;
    • WeightedLeastConnection;
    • LocalityBasedLeastConnection;
    • LocalityBasedLeastConnectionWithReplication;
    • SourceHashing;
    • DestinationHashing;
    • ShortestExpectedDelay;
    • NeverQueue.

References:

https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxieshttps://sookocheff.com/post/kubernetes/understanding-kubernetes-networking-model/