Set up unique purpose pods with Helm / Kubernetes

1/29/2019

I need to have n pods doing basically the same thing but operating on different endpoints, based on an environment variable. For example, pod1 will process var1, pod2 will process var2 etc...

Can I have unique purpose pods within a deployment: propagating a unique variable to each pods? Or do I need to have n statefulsets, which looks heavier?

-- Arkon
kubernetes
kubernetes-deployment
kubernetes-helm
kubernetes-pod

1 Answer

1/29/2019

I don't think it is possible with single deployment as this is stateless and you need to maintain state. For example , if pod1 is processing var1 and it dies, new pod should be created which should process var1 only. So this is not possible with single deployment.

But it is possible with single StatefulSet with some changes in your application itself. You can store those env variable somewhere(maybe DB or volume) and pod name(which is unique in this case as it is StatefulSet) against each var. SO instead of reading from env variable, read vars from storage depending on Pod name.

Also creation of multiple endpoints can be managed with labelSelector.

-- Rajesh Deshpande
Source: StackOverflow