Note: The Listed platform will permanently shut down December 31, 2026. Your data published on Listed will still be available in your personal Standard Notes account. Learn more

Write ConfigMap Value as File

To write a value from a ConfigMap to a file inside a container use a volume mount with a subPath

ConfigMap.yaml

kind: ConfigMap
apiVersion: v1
metadata:
  name: my-config
data:
  appsettings.json: |-
    {
      "ApplicationName": "My Application",
        "OtherSettings" : {
      ...
        }
     }

Deployment.yaml

apiVersion: apps/v1
kind: Deployment
spec:
  template:
    spec:
      volumes:
      - name: config-volume
        configMap:
          name: my-config
      containers:
      - name: MyDeployment
        image: MyImage
        volumeMounts:
          - name: config-volume
            mountPath: /app/Conf/appsettings.json
            subPath: appsettings.json
            readOnly: true

More from David Strain
All posts