Kubernetes: Expose only single pod of StatefulSet

8/12/2017

For for a StateFul set, I can access its pods via a headless service internally.

I think, it would make sense, to have an easy way to expose also single pods externally (since the pods usually have a state and therefore loadbalancing over them makes no sense).

So far, I found no straight forward way to do that. Even doing kubectl expose pod pod-1 --type NodePort gives me a service which balances over all pods. Is there a reason why this is like this or is there a nice way to access single pods.

-- Christof Tinnes
kubectl
kubernetes
networking
service
statefulset

1 Answer

8/15/2017

I don’t see they way to distribute the load to single pod. If you want to client keep this session with one pod you can define service sessionAffinity: ClientIP. this will send established client traffic same pod.

-- sfgroups
Source: StackOverflow