Create new helm chart

Create new helm chart

In this tutorial, we are going to discuss about how to create new helm chart. In the earlier tutorial, we discussed about various components involved as a part of helm.

Now it’s time to get more in detail about the charts, how to create a custom chart and the syntax and the various components within the charts.

This is going to be the main section within this particular helm tutorials where we are going to have detailed discussion about each and every component within chart.

So I’m going to create a custom project and get more in details about various files available as a part of the charts and how to make use of them. Then we will start creating a chart from the scratch.

Let me get into the machine where I do have the helm installed. Here I will be issuing the following command

$ helm create mychart
Creating mychart

So above command going to create a chart with the name mychart and that will be put within a folder called mychart. So here mychart folder got created.

Verify Chart Files

If I get into this specific folder, I will be having all the basic required files. This by default, create a small chart with sample deployment, services everything.

[email protected]:~$ cd mychart/

[email protected]:~/mychart$ ls
charts  Chart.yaml  templates  values.yaml

What I will be doing, I will use this specific structure and then we will create a chart from the scratch. Before that, let me get into the different folders and see what are all information will be available within it.

templates folder

The very basic thing of charts is the templates that will be put within the templates folder. If I get into the templates folder I will be having some sample templates.

[email protected]:~/mychart$ cd templates/

[email protected]:~/mychart/templates$ ls
deployment.yaml  _helpers.tpl  hpa.yaml  ingress.yaml  NOTES.txt  serviceaccount.yaml  service.yaml  tests

For time being, Let’s not worry about these templates which got created by default. For understanding purposes, let me cat a sample deployment.yaml file.

[email protected]:~/mychart/templates$ cat deployment.yaml 
apiVersion: apps/v1
kind: Deployment
  name: {{ include "mychart.fullname" . }}
    {{- include "mychart.labels" . | nindent 4 }}
  {{- if not .Values.autoscaling.enabled }}
  replicas: {{ .Values.replicaCount }}
  {{- end }}
      {{- include "mychart.selectorLabels" . | nindent 6 }}
      {{- with .Values.podAnnotations }}
        {{- toYaml . | nindent 8 }}
      {{- end }}
        {{- include "mychart.selectorLabels" . | nindent 8 }}
      {{- with .Values.imagePullSecrets }}
        {{- toYaml . | nindent 8 }}
      {{- end }}
      serviceAccountName: {{ include "mychart.serviceAccountName" . }}
        {{- toYaml .Values.podSecurityContext | nindent 8 }}
        - name: {{ .Chart.Name }}
            {{- toYaml .Values.securityContext | nindent 12 }}
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default Chart.AppVersion }}"
          imagePullPolicy: {{ .Values.image.pullPolicy }}
            - name: http
              containerPort: 80
              protocol: TCP
              path: /
              port: http
              path: /
              port: http
            {{- toYaml .Values.resources | nindent 12 }}
      {{- with .Values.nodeSelector }}
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.affinity }}
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.tolerations }}
        {{- toYaml . | nindent 8 }}
      {{- end }}

It’s going to have the deployment.yaml file, which is templatised. For example, within name I do have a variable which will be read from some value files or from some other chart template.

Don’t worry about this particular syntax, what it is? We will be having detailed discussion about each and every component of it. This is just to have a feel, how a template would look like.

charts folder

Within the charts folder, we will be having all the dependent charts this particular main charts depends on. And this particular folder is empty.

[email protected]:~/mychart/charts$ ls
[email protected]:~/mychart/charts$ 

Now within values.yaml file, this is going to provide the values for the templates and we can have hierarchical value, this is of json format.

[email protected]:~/mychart$ cat values.yaml 
Default values for mychart.
This is a YAML-formatted file.
Declare variables to be passed into your templates.
replicaCount: 1
  repository: nginx
  pullPolicy: IfNotPresent
  # Overrides the image tag whose default is the chart appVersion.
  tag: ""
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
  # Specifies whether a service account should be created
  create: true
  # Annotations to add to the service account
  annotations: {}
  # The name of the service account to use.
  # If not set and create is true, a name is generated using the fullname template
  name: ""
podAnnotations: {}
podSecurityContext: {}
  # fsGroup: 2000
securityContext: {}
  # capabilities:
  #   drop:
  #   - ALL
  # readOnlyRootFilesystem: true
  # runAsNonRoot: true
  # runAsUser: 1000
  type: ClusterIP
  port: 80
  enabled: false
  annotations: {}
    # nginx
    # "true"
    - host: chart-example.local
      - path: /
          serviceName: chart-example.local
          servicePort: 80
  tls: []
  #  - secretName: chart-example-tls
  #    hosts:
  #      - chart-example.local
resources: {}
  # We usually recommend not to specify default resources and to leave this as a conscious
  # choice for the user. This also increases chances charts run on environments with little
  # resources, such as Minikube. If you do want to specify resources, uncomment the following
  # lines, adjust them as necessary, and remove the curly braces after 'resources:'.
  # limits:
  #   cpu: 100m
  #   memory: 128Mi
  # requests:
  #   cpu: 100m
  #   memory: 128Mi
  enabled: false
  minReplicas: 1
  maxReplicas: 100
  targetCPUUtilizationPercentage: 80
  # targetMemoryUtilizationPercentage: 80
nodeSelector: {}
tolerations: []
affinity: {}

I can read any value using the key hierarchy. We will be having detailed discussion on how to read a specific value or array of values later point of time.


In chart.yaml, we will be having various information like what API version, name, description. These three fields are mandatory. Additional to that, we can have other fields like keywords type, what kube version to use and different dependencies we can add, and who is the maintainer and all those values are optional.

While discussing about this specific file chart.yaml we will be having detailed discussion about each and every field what will get added into this particular file.

So like this, we can have other files as well, like license,, values.yaml, values.schema.json crds folder and templates.

Create new helm chart

So license is an optional file that’s going to have the license information about this particular chart.


readme as the name suggests, it’s a human readable text file where We will be having information about this particular chart.


values.schema.json is an optional file, but that’s a very important file where it is going to derive or drive how the structure of the values.yaml file will be. That is something like a schema definition file.

crd folder

Another folder that we did not see it in the default chart that got created. That is crds that’s going to have the custom resources that are required for this particular chart.

Create new helm chart

Scroll to top