Search code examples
kubernetesstatefulset

How to add a Configmap to a specific Pod In a StatefulSet?


I'd like to know how I can add a ConfigMap to a specific pod spawned by a StatefulSet.

I've looked at the spec and I can't figure out how to ensure that a pod only mounts a ConfigMap with a specific label. I've already got a workaround ready in the form of a container. However I'd still like to know if this is possible out of the box.


Solution

  • You can't treat a pod inside the same StatefulSet as a special pod. Simply because you can only specify a single PodSpec that's valid for the whole set.

    A workaround is to mount all versions of the config files in every pod and run an entrypoint script that uses different config files based on the pod name. I have no example to show but it should be quite easy