Kubernetes : pod parameters depending on replica

9/3/2017

I am looking on how can I change the parameter of containers depending on the number of replica ?

For example, I would like to have an environment variable ( which is the name of my hubot) as follow :

  1. First Replica : Name1
  2. Second replica : Name2...

Do you have an idea of how can I achieve that ? Thanks !

-- Karnero
kubernetes

1 Answer

9/3/2017

The feature is called "StatefulSets" in Kubernetes. Have a look at the Stable Network ID section in particular.

Stateful sets are available in Kubernetes 1.5. If you need an older version, you could use some kind of central registry like redis instead and implement some logic where new pods request the next free number when they start.

-- user3151902
Source: StackOverflow