Bootstrap FreeKB - Helm - Dry run using the helm template command
Helm - Dry run using the helm template command

Updated:   |  Helm articles

You may want to first check out my article FreeKB - OpenShift - Deploy Hello Openshift.

This also assumes you've already installed the helm CLI on the system that you want to use to create the Helm chart to deploy Hello OpenShift.

Let's say you have the following files and directories for your Helm Chart. 

├── my-chart (directory)
│   ├── Chart.yaml
│   ├── values.yaml
│   ├── charts (directory)
│   └── templates (directory)
│       └── configmap.yaml
│       └── deployment.yaml
│       └── files (directory)
│           └── requirements.txt

 

The helm lint command can be used to determine if there are any syntax errors in the files in the my-chart directory. If there are no syntax errors, the failed count should be 0.

~]$ helm lint my-chart
==> Linting my-chart


1 chart(s) linted, 0 chart(s) failed

 

The helm template command can then be used as a sort of dry run, to see the YAML files that would be created by the helm install command.

~]$ helm template my-chart
---
# Source: my-chart/templates/configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: my-config-map
data:
  requirements.txt: |-
    certifi==2024.2.2
    fastapi==0.115.6
    pycurl==7.45.3
    pytz==2025.1
    requests==2.31.0
    uvicorn==0.34.0
---
# Source: my-chart/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: my-app
  name: my-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: my-app
  template:
    metadata:
      labels:
        app: my-app
    spec:
      containers:
      - command:
        - /bin/sh
        - -c
        - cd /tmp/empty-dir; HOME=/tmp/empty-dir;
          pip install --upgrade pip; pip install --requirement /opt/app-root/src/requirements.txt;
          python /opt/app-root/src/example.py
        image: registry.digital.example.com/python:3.12
        imagePullPolicy: IfNotPresent
        name: my-deployment
        ports:
        - containerPort: 8080
          protocol: TCP
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        volumeMounts:
        - mountPath: /opt/app-root/src/example.py
          name: my-config-map
          subPath: example.py
        - mountPath: /opt/app-root/src/requirements.txt
          name: my-config-map
          subPath: requirements.txt
        - mountPath: /tmp/empty-dir
          name: my-empty-dir
      volumes:
      - configMap:
          defaultMode: 420
          name: my-config-map
        name: my-config-map
      - emptyDir: {}
        name: my-empty-dir

 

 

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter e07b0b in the box below so that we can be sure you are a human.