kubernetesstatefulsetkubernetes-statefulset

How can I mount a single distinct Secret into each Pod managed by a StatefulSet?


I have 3 different Kubernetes Secrets and I want to mount each one into its own Pod managed by a StatefulSet with 3 replicas.

Is it possible to configure the StatefulSet such that each Secret is mounted into its own Pod?


Solution

  • Not really. A StatefulSet (and any workload controller for that matter) allows only a single pod definition template (it could have multiple containers). The issue with this is that a StatefulSet is designed to have N replicas so can you have an N number of secrets. It would have to be a SecretStatefulSet: a different controller.

    Some solutions:

    In all cases, you will have to make sure that the number of secrets matches your number of pods in your StatefulSet.