How to easily duplicate helm charts

9/2/2020

10 microservices on kubernetes with helm3 charts, and saw that all of them have similar structure standard, deployment, service, hpa, network policies etc. and basically the <helm_chart_name>/templates directory is 99% same on all with some if statements on top of file whether we want to deploy that resource,

{{ if .Values.hpa.create }}
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
  name: {{ .Values.deployment.name }}
...
spec:
  scaleTargetRef:
...
{{ end }}

and in values passing yes/no whether we want it - Is there some tool to easily create template for the helm charts ? To create Helm chart with this 5 manifests pre-populated with the reference to values as above ?

-- potatopotato
kubernetes
kubernetes-helm

2 Answers

9/2/2020

What you need is the Library Charts:

A library chart is a type of Helm chart that defines chart primitives or definitions which can be shared by Helm templates in other charts. This allows users to share snippets of code that can be re-used across charts, avoiding repetition and keeping charts DRY.

You can find more details and examples in the linked documentation.

-- WytrzymaƂy Wiktor
Source: StackOverflow

9/2/2020

I think closest thing to the thing I want is https://helm.sh/docs/topics/library_charts/

-- potatopotato
Source: StackOverflow