Bootstrap FreeKB - Helm - Templating a config map
Helm - Templating a config map

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 that make up your chart.

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

 

And let's say requirements.txt contains the following.

certifi==2024.2.2
fastapi==0.115.6
pycurl==7.45.3
pytz==2025.1
requests==2.31.0
uvicorn==0.34.0

 

Here is what you could have in configmap.yaml so that the configmap contains the requirements.txt file.

apiVersion: v1
kind: ConfigMap
metadata:
  name: my-config-map
data:
  requirements.txt: |-
    {{- .Files.Get "files/requirements.txt" | nindent 4 }}

 

The helm template command should return the following.

~]$ 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

 




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 8430f3 in the box below so that we can be sure you are a human.