📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials Kubernetes Kubernetes ConfigMap and Secret Volumes

Kubernetes ConfigMap and Secret Volumes

4 min read
Mount ConfigMaps and Secrets as files or environment variables inside pod containers.

Config and Secret Volumes

# Mount ConfigMap as files
volumes:
  - name: config
    configMap:
      name: app-config
      items:
        - key: app.properties
          path: app.properties

volumeMounts:
  - name: config
    mountPath: /etc/config

# Mount Secret as files
volumes:
  - name: certs
    secret:
      secretName: tls-secret
      defaultMode: 0400  # read-only

volumeMounts:
  - name: certs
    mountPath: /etc/ssl/certs
    readOnly: true

# Environment from secret
envFrom:
  - secretRef:
      name: db-creds