Loadbalancing logic in service resource

1/10/2019

In my kubernetes cluster, there is a lot of inter-service communication. I have also enabled horizontal pod autoscaler and we use service resource for all these services.

I need to understand how does the service resource loadbalance the request across the pods.

I did read about SessionAffinity but it only supports ClientIP, if you are not using an Ingress resource.

Want to know if the service can loadbalance based on the load (in terms of cpu, memory, etc.) on a particular pod. In short, does sessionAffinity config support anything other than ClientIP. I dont want to bring in an Ingress resource, as these are not external facing requests, these are inter-service communication.

Thanks in advance.

-- Amit
kubernetes

1 Answer

1/14/2019

In short, does sessionAffinity config support anything other than ClientIP

No, it does not. See the model definition here for v1.SessionAffinityConfig: Nor will it; I already feel that sessionAffinity is out of a Service's scope, I'm surprised it exists at all.

You're going to want to use some kind of layer in front of your service if you want to have more control of your connections. There are plenty of Service Meshes that might solve your problem (see isito or Linkerd )

You could also roll your own solution with nginx and send your requests for that service to the nginx pod.

-- Kevin Minehart
Source: StackOverflow