Understanding Helm dry run for template debugging

Debugging and troubleshooting Helm Template in the complex production environment can be really daunting if you do not use helm install --dry-run --debug or helm template command for debugging the Helm Templates.

  1. helm install --dry-run --debug :- It will validate and verify your chart by connecting to kubernetes api server and after successful validation it will render the manifest in the form of YAMLs(kubernetes resources)

helm install --dry-run --debug

  1. helm template :- It will do the validation and generate the YAML manifest but it can not guarantee that generated kubernetes resource(YAMLs) is valid or not.

helm template

Deep dive into : - helm install --dry-run --debug

Lets create Helm Chart - helloworld

1helm create helloworld

Since it is very basic helloworld helm chart but still we can verify and validate.

Run the following command -

1helm install myreleasename --debug --dry-run helloworld

Here is what will happen behind the scene -

  1. First the chart will be sent to kubernetes API server
  2. In the second step kubernetes API server will validate and verify the chart manifest
  3. Third step it will generate the template and return you back, so that you can see the final rendered template.

Is --dry-run option require for connecting to Kubernetes cluster?

Yes, you should have active and running Kubernetes Cluster before you use --debug --dry-run.

In case if you do not have kubernetes cluster up and running then it will throw you following error

1Error: Kubernetes cluster unreachable: Get "http://localhost:8080/version?timeout=32s": dial tcp connect: connection refused

So make sure your kubernetes cluster is in healthy state before running --debug --dry-run.

Deep dive into : - helm template

Helm template will help you to validate your chart manifest(YAMLs), but it will not connect to kubernetes API server for kubernetes resource validation.

It will help you to generate the complete kubernetes resource manifest(YAMLs) by replacing the placeholders with actual values.

Run the following command -

1helm template helloworld

You should be to see the following output

 2# Source: helloworld/templates/serviceaccount.yaml
 3apiVersion: v1
 4kind: ServiceAccount
 6  name: RELEASE-NAME-helloworld
 7  labels:
 8    helm.sh/chart: helloworld-0.1.0
 9    app.kubernetes.io/name: helloworld
10    app.kubernetes.io/instance: RELEASE-NAME
11    app.kubernetes.io/version: "1.16.0"
12    app.kubernetes.io/managed-by: Helm
14# Source: helloworld/templates/service.yaml
15apiVersion: v1
16kind: Service
18  name: RELEASE-NAME-helloworld
19  labels:
20    helm.sh/chart: helloworld-0.1.0
21    app.kubernetes.io/name: helloworld
22    app.kubernetes.io/instance: RELEASE-NAME
23    app.kubernetes.io/version: "1.16.0"
24    app.kubernetes.io/managed-by: Helm
26  type: ClusterIP
27  ports:
28    - port: 8080
29      targetPort: http
30      protocol: TCP
31      name: http
32  selector:
33    app.kubernetes.io/name: helloworld
34    app.kubernetes.io/instance: RELEASE-NAME
36# Source: helloworld/templates/deployment.yaml
37apiVersion: apps/v1
38kind: Deployment
40  name: RELEASE-NAME-helloworld
41  labels:
42    helm.sh/chart: helloworld-0.1.0
43    app.kubernetes.io/name: helloworld
44    app.kubernetes.io/instance: RELEASE-NAME
45    app.kubernetes.io/version: "1.16.0"
46    app.kubernetes.io/managed-by: Helm
48  replicas: 1
49  selector:
50    matchLabels:
51      app.kubernetes.io/name: helloworld
52      app.kubernetes.io/instance: RELEASE-NAME
53  template:
54    metadata:
55      labels:
56        app.kubernetes.io/name: helloworld
57        app.kubernetes.io/instance: RELEASE-NAME
58    spec:
59      serviceAccountName: RELEASE-NAME-helloworld
60      securityContext:
61        {}
62      containers:
63        - name: helloworld
64          securityContext:
65            {}
66          image: "rahulwagh17/kubernetes:jhooq-k8s-helloworld"
67          imagePullPolicy: IfNotPresent
68          ports:
69            - name: http
70              containerPort: 8080
71              protocol: TCP
72          resources:
73            {}
75# Source: helloworld/templates/tests/test-connection.yaml
76apiVersion: v1
77kind: Pod
79  name: "RELEASE-NAME-helloworld-test-connection"
80  labels:
81    helm.sh/chart: helloworld-0.1.0
82    app.kubernetes.io/name: helloworld
83    app.kubernetes.io/instance: RELEASE-NAME
84    app.kubernetes.io/version: "1.16.0"
85    app.kubernetes.io/managed-by: Helm
86  annotations:
87    "helm.sh/hook": test-success
89  containers:
90    - name: wget
91      image: busybox
92      command: ['wget']
93      args: ['RELEASE-NAME-helloworld:8080']
94  restartPolicy: Never

As you can see the output which consists of YAMLs and placeholders replaced by its actual values, once you will deploy this YAMLs into the kubernetes cluster then you will get to know the success and failure state of the resource.


In this article we have seen -

  1. What is helm install --dry-run --debug and helm template ow it can be used for debugging helm template
  2. Apart from that we have also seen the difference between both the commands

For more details please refer to official documentation.

Read More -

  1. Helm chart - How to Add/Install plugins
  2. Getting started with Helm Chart
  3. Helm chart - WordPress Installation with MariaDB on Kubernetes
  4. Helm chart - Build you first helm chart with Spring Boot
  5. Helm Chart - Convert Kubernetes YAML into Helm Chart YAML
  6. Helm Chart - Pass environment variables
  7. Helm Chart - Plugin
  8. Helm Chart - Dry Run Install
  9. Helm Chart - How to create multiple values files inside helm chart?
  10. Helmfile - How to use Helmfile for managing helm chart?

Posts in this Series