0

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
  • 2,648
  • 6
  • 26
  • 46
  • There's a concept called labelSelectors (in this case podSelector) which you can create and customize service deployments in your k8s cluster. Is this what you are trying? – Raunak Jhawar Jan 29 '19 at 03:31
  • by endpoint you mean node? what is the purpose of "processing var" could you please clarify what you want to achieve? – aurelius Jan 29 '19 at 16:07
  • @aurelius each pod is a queue processor that polls from his own queue. There are many queues and I want a 1 to 1 relation (1 queue -> 1 worker). This means I need to pass "queue-0", "queue-1" to workers 0, 1... Defining custom env variables for pods within a deployment would have good. What I can do as suggested by Rajesh, is to make statefulsets. – Arkon Jan 29 '19 at 22:20

1 Answers1

2

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.

  • You are right, I will make a statefulset from a count variable in my values.yaml. That will do! Thanks – Arkon Jan 29 '19 at 22:18