kubernetes service loadbalancing based on zone

6/28/2019

Let us say I've two zones zone1 and zone2, having 2 apps deployed in each zone. Let us say App1 is a client which fetches information from App2, App1 connects to App2 using k8s service, Now how can I configure app1 of zone1 to connect to app2 of zone1(preferably, if app2 of zone1 is loaded or down connect to app2 of zon2).

Though this can be achieved by application layer using zuul and ribbon with headless service, I want to move this to infra layer. Is there any possibility to do in K8s.

I see IPVS supports Locality-Based Least Connection algorithm, but not sure k8s supports this algorithm, I see supported algos are rr, wrr, lc, sed. but no documentation regarding support for lblc. if lblc is supported is this better solution to prefer same node/pod in dc/pod in zone.

NOTE: This is solution is purely for on-prem k8s cluster.

-- Karthik Prasad
kubernetes
kubernetes-service

1 Answer

7/2/2019

I will answer only to part of your question, have no experience with "best practices" configuration in this area. But what I want to share with you - is that kubernetes definitely supports Locality-Based Least Connection algorithm.

You can find this in the source code:

LocalityBasedLeastConnection IPVSSchedulerMethod = "lblc"
    // LocalityBasedLeastConnectionWithReplication with Replication assigns jobs destined for the same IP address to the
    // least-connection node in the server set for the IP address. If all the node in the server set are overloaded,
    // it picks up a node with fewer jobs in the cluster and adds it to the sever set for the target.
    // If the server set has not been modified for the specified time, the most loaded node is removed from the server set,
    // in order to avoid high degree of replication.

You can find info on how to enable IPVS here: https://kubernetes.io/blog/2018/07/09/ipvs-based-in-cluster-load-balancing-deep-dive/

P.S. Above article doesnt contains no info about lblc but as per source code - k8s supports it.

-- VKR
Source: StackOverflow