Helm - Templating a config map
by
Jeremy Canfield |
Updated: November 20 2025
| 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 