Hi everyone, A question related to k8s config-maps and deployment/stateful-sets . . .

Franjo:
Hi everyone,

A question related to k8s config-maps and deployment/stateful-sets …
I have a deployment of 3 replicas, and an associated config-map for it. Inside that config-map I have something like a service name
Example name: service-x where I would like for each of my replica that they have a unique value
• for the first replica to be service-1
• for the second replica to be service-2
• and for the third replica to be service-3
Now I know when I create for example instead of deployment a stateful set that I will get the naming correct, but I have to pass it to the pods through config map.
How could I achive this via deployment or stateful set if it makes more sense to have it that way?
Thanks everyone!

Pita:
You can try something like that
*xyz*: $(SERVICE_NAME)
where SERVICE_NAME is an env var you can define through configMap
I don’t understand where, in the deplpoyment, you want to set up that value

Franjo:
but the env var would be pretty much the same everytime?

I would need it to change value per pod where each pod in the deployment/stateful set has its own unique value

Pita:
can I know why you need this set up?
I mean what is your purpose?

Pita:
anyway yes, *xyz*: $(SERVICE_NAME) return always the same value

Franjo:
Yeah,
So I have go-lang micro-services where inside each of those service we have some amount of cronjobs …
Now to avoid running crons on multiple pods I need this… I know this is not the desired kubernetes way and that kubernetes has its own rules how cronjobs should be running but at this current situation it’s to much work to transfer firstly all cronjobs, so this what I want would be a temp fix for my issue