kubernetes helm example

helm install –debug –dry-run Example

This tutorial guides you on how to check the generated manifests of a helm release without installing the helm chart by using –debug and –dry-run flags combined. Let’s learn how to using helm install –debug –dry-run with example.

helm install –debug –dry-run Example

As mentioned in the helm documentation, if you wanted to test the chart installation without actually installing anything, you need to use the helm install command with –debug and –dry-run flags combined.

Before you begin, download GitHub sample Hello Helm for our exercise.

$ git clone https://github.com/cloudnativedevops/demo.git

Cloning into 'demo'...
remote: Enumerating objects: 885, done.
remote: Total 885 (delta 0), reused 0 (delta 0), pack-reused 885
Receiving objects: 100% (885/885), 330.78 KiB | 13.78 MiB/s, done.
Resolving deltas: 100% (363/363), done.

Verify, whether the Helm Chart deployment YAML files are there of the demo application in the following path /demo/hello-helm/k8s/demo as shown below.

~/demo/hello-helm/k8s/demo (sneppets)$ ls

Chart.yaml  production-values.yaml  staging-values.yaml  templates  values.yaml

The subdirectory /k8s/demo contains the Kubernetes manifest files to deploy the demo application. The below command will actually send the helm chart to the tiller server, where the templates are rendered. But it won’t install the chart instead returns the generated manifests just to check.

$ helm install --debug --dry-run demo /home/sneppets/demo/hello-helm/k8s/demo/

install.go:173: [debug] Original chart version: ""
install.go:190: [debug] CHART PATH: /home/sneppets/demo/hello-helm/k8s/demo

NAME: demo
LAST DEPLOYED: Tue Apr  6 11:30:59 2021
NAMESPACE: default
STATUS: pending-install
REVISION: 1
TEST SUITE: None
USER-SUPPLIED VALUES:
{}

COMPUTED VALUES:
container:
  image: cloudnatived/demo
  name: demo
  port: 8888
  tag: hello
environment: development
replicas: 1

HOOKS:
MANIFEST:
---
# Source: demo/templates/service.yaml
apiVersion: v1
kind: Service
metadata:
  name: demo-service
  labels:
    app: demo
spec:
  ports:
  - port: 80
    protocol: TCP
    targetPort: 8888
  selector:
    app: demo
  type: LoadBalancer
---
# Source: demo/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: demo
spec:
  replicas: 1
  selector:
    matchLabels:
      app: demo
  template:
    metadata:
      labels:
        app: demo
        environment: development
    spec:
      containers:
        - name: demo
          image: cloudnatived/demo:hello
          ports:
            - containerPort: 8888
          env:
            - name: environment
              value: development

You can also note from the above response that the STATUS of helm install –debug –dry-run command seen as “pending-install“. Therefore, helm dry run install did not actually install the chart.

Also make sure that Kubernetes cluster is reachable when you are trying helm install dry run command. Otherwise you might get the following error as shown below.

$ helm install --debug --dry-run demo /home/sneppets/demo/hello-helm/k8s/demo/

install.go:173: [debug] Original chart version: ""
install.go:190: [debug] CHART PATH: /home/sneppets/demo/hello-helm/k8s/demo

Error: Kubernetes cluster unreachable: Get "https://34.80.233.207/version?timeout=32s": dial tcp 34.80.233.207:443: i/o timeout
helm.go:81: [debug] Get "https://34.80.233.207/version?timeout=32s": dial tcp 34.80.233.207:443: i/o timeout
Kubernetes cluster unreachable
helm.sh/helm/v3/pkg/kube.(*Client).IsReachable
        /home/circleci/helm.sh/helm/pkg/kube/client.go:115
helm.sh/helm/v3/pkg/action.(*Install).Run
        /home/circleci/helm.sh/helm/pkg/action/install.go:176
main.runInstall
        /home/circleci/helm.sh/helm/cmd/helm/install.go:242
main.newInstallCmd.func2
        /home/circleci/helm.sh/helm/cmd/helm/install.go:120
github.com/spf13/cobra.(*Command).execute
        /go/pkg/mod/github.com/spf13/[email protected]/command.go:850
github.com/spf13/cobra.(*Command).ExecuteC
        /go/pkg/mod/github.com/spf13/[email protected]/command.go:958
github.com/spf13/cobra.(*Command).Execute
        /go/pkg/mod/github.com/spf13/[email protected]/command.go:895
main.main
        /home/circleci/helm.sh/helm/cmd/helm/helm.go:80
runtime.main
        /usr/local/go/src/runtime/proc.go:204
runtime.goexit
        /usr/local/go/src/runtime/asm_amd64.s:1374

Therefore make sure that you have created Kubernetes cluster. And connect to that cluster using the following gcloud command in case of GKE cluster.

$ gcloud container clusters get-credentials clus1 --zone europe-north1-c --project sne5g21

Fetching cluster endpoint and auth data.
kubeconfig entry generated for clus1.

That’s it. Hope it helped 🙂

You’ll also like:

References

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments