<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>

<p>There are definitely several ways of doing it. One popular option is to use <a href="https://helm.sh/" rel="nofollow noreferrer">Helm</a>. Helm lets you define kubernetes manifests using Go templates, and package them on a single unit called a Helm Chart. Later on you can install this Chart (install is what Helm calls to save these manifests in the Kubernetes API). When installing the Helm Chart, you can pass arguments that will be used when rendering the templates. That way you can re-use pretty much everything, and just replace the significant bits of your manifests: Deployments, Services, etc.</p>

<p>There are <a href="https://github.com/helm/charts/tree/master/stable" rel="nofollow noreferrer">plenty of Helm charts available as open sources projects</a>, that you can use as an example on how to create your own Chart.</p>

<p>And many <a href="https://docs.bitnami.com/kubernetes/how-to/create-your-first-helm-chart/" rel="nofollow noreferrer">useful guides on how to create your first Helm Chart</a>.</p>

<p>Here you can find the <a href="https://helm.sh/docs/developing_charts/" rel="nofollow noreferrer">official docs on developing your own Charts</a>.</p>
