Kubernetes: send custom parameters per pod

9/20/2017

I'm testing with a kubernetes cluster, and it's been marvelous to work with. But I got the following scenario:

I need to pass to each pod a custom value(s) just for that pod.

Let's say, I got deployment 1, and I define some env vars to that deployment, the env vars will go to each pod and that's good, but what I need is to send custom values that may go to a specific pod(like "to the third pod that I may create, send this").

This is what I got now:

enter image description here

Then, what I need is something like this:

enter image description here

Is there any artifact/feature I could use? It does not have to be an env var, it may be a configmap value, or anything. thanks in advance

-- mithril_knight
kubernetes

2 Answers

9/20/2017

The real question here is how do you know what you want to put in particular pod in the first place. You could probably achieve something like this writing a custom initialiser for your pods. You could also have an init container prefetching information from central coordinator. To propose a solution, you need to figure it out in a "not a snowflake" way.

-- Radek 'Goblin' Pieczonka
Source: StackOverflow

9/20/2017

Pods in a deployment are homogenous. If you want to set up a set of pods that are distinct from one another, you might want to use StatefulSet, which gives each pod an index you could use within the pod to select relevant config params

-- Jordan Liggitt
Source: StackOverflow