<p>I’m somewhat new to Kubernetes and not sure the standard way to do this. I’d like to have many instances of a single microservice, but with each of the containers parameterized slightly differently. (Perhaps an environment variable passed to the container that’s different for each instance, as specified in the container spec of the .yaml file?)</p>

<p>It seems like a single deployment with multiple replicas wouldn’t work. Yet, having n different deployments with very slightly different .yaml files seems a bit redundant. Is there some sort of templating solution perhaps?</p>

<p>Or should each microservice be identical and seek out its parameters from a central service?</p>

<p>I realize this could be interpreted as an “opinion question” but I am looking for typical solutions.</p>

vmayer
<p>As an option you can use <a href="https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/" rel="nofollow noreferrer">StatefulSet</a> with <a href="https://kubernetes.io/docs/concepts/workloads/pods/init-containers/" rel="nofollow noreferrer">InitContainers</a> plus <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/" rel="nofollow noreferrer">ConfigMap</a>.</p>

<p>Statefulset will guarantee you proper naming and order.
ConfigMap will let you store fine-grained information like individual properties or coarse-grained information like entire config files.</p>

<p>Configuration data can be consumed in pods in a variety of ways. ConfigMaps can be used to:</p>

<p>1) Populate the values of environment variables</p>

<p>2) Set command-line arguments in a container</p>

<p>3) Populate config files in a volume</p>

<p>For the begging you can review <a href="https://theithollow.com/2019/04/01/kubernetes-statefulsets/" rel="nofollow noreferrer">Kubernetes – StatefulSets</a> article where you can find a good explanation on how this pieces work together and inspect prepared example on how to deploy containers from the same image but with different properties.</p>
