Skip to content

mount single JSON file to Deployment via configMap

Firstly, create configmap from existing json file.

kubectl create configmap my-json-config \
  --from-file=my.config.json

Then update deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: appname
spec:
  replicas: 2
  selector:
    matchLabels:
      app: appname
  template:
    metadata:
      labels:
        app: appname
    spec:
      containers:
      - name: appname
        image: appname/appname
        volumeMounts:
        - name: my-json-config
          mountPath: /app/my.config.json
          subPath: my.config.json
      volumes:
      - name: my-json-config
        configMap:
          name: my-json-config
Published inKubernetes
© 2024 M.Sertaç Bayır - All Rights Reserved