<p>Is there a way to create a tree of inheritance for Kubernetes deployments? I have a number of deployments which are similar but not identical. They share many ENV vars but not all. They all use the same image. </p>

<p>For example, I have a dev deployment which is configured almost identical to a production deployment but has env vars pointing to a different database backend. I have a celery deployment which is configured the same as the production deployment, however, it has a different run command.</p>

timthelion
<p><a href="https://helm.sh/" rel="nofollow noreferrer">Helm</a> is what many people are using for this. It let's you create templates for kubernetes descriptors and pass parameters in to generate descriptors from the templates.</p>

<p>There are other tools out there which can be used to generate variations on kubernetes deployment descriptors by injecting parameters into templates. Ansible is also popular. But Helm is closely connected with the <a href="https://www.cncf.io/blog/2018/06/01/cncf-to-host-helm/" rel="nofollow noreferrer">Kubernetes CNCF</a> and community and there's a good selection of <a href="https://hub.kubeapps.com/" rel="nofollow noreferrer">official charts</a> available.</p>

<p>EDIT: If the aim is to enable different deployments (e.g. for dev and prod) using a single docker image then that's probably best handled with a single chart. You can create different values files for each deployment and supply the chosen values file to helm install with the <code>--values</code> parameter. If there are parts of the chart that are only sometimes applicable then they can be wrapped in <code>if</code> conditions to turn them on/off.</p>

<p>On the subject of inheritance specifically, there's an <a href="https://github.com/helm/helm/blob/master/docs/chart_template_guide/subcharts_and_globals.md#overriding-values-from-a-parent-chart" rel="nofollow noreferrer">example in the helm documention of how to take another chart as a parent/dependency and override its values</a> and I created <a href="https://github.com/Activiti/ttc-acceptance-tests/tree/cd6c7956de21d7f29d336dc464e5e7e22d0dd7b6/ttc-example" rel="nofollow noreferrer">a chart earlier that you can see in github</a> that <a href="https://github.com/Activiti/ttc-acceptance-tests/blob/cd6c7956de21d7f29d336dc464e5e7e22d0dd7b6/ttc-example/requirements.yaml" rel="nofollow noreferrer">includes several other charts</a> and <a href="https://github.com/Activiti/ttc-acceptance-tests/blob/cd6c7956de21d7f29d336dc464e5e7e22d0dd7b6/ttc-example/values.yaml#L41" rel="nofollow noreferrer">overrides parts of all of them via the values.yml</a>. It also shares some config between the included charts <a href="https://github.com/Activiti/ttc-acceptance-tests/blob/cd6c7956de21d7f29d336dc464e5e7e22d0dd7b6/ttc-example/values.yaml#L47" rel="nofollow noreferrer">with globals</a>. If you're looking to use a parent to reduce duplication rather than join multiple apps then it is possible to create a <a href="https://medium.com/devopslinks/dry-helm-charts-for-micro-services-db3a1d6ecb80" rel="nofollow noreferrer">base/wrapper chart</a> but <a href="https://medium.com/@ryandawsonuk/tips-for-getting-started-with-helm-99b01efdab90" rel="nofollow noreferrer">it may turn out to be better to just duplicate config</a>.</p>

<p>EDIT (180119): The alternative of <a href="https://github.com/kubernetes-sigs/kustomize" rel="nofollow noreferrer">Kustomize</a> may soon <a href="https://github.com/kubernetes/enhancements/issues/633" rel="nofollow noreferrer">become available in kubectl</a></p>
