asp.net – Kubectl deployment – how to load env vars from JSON file

You can use following command to create configmap and then mount it to your contianer

kubectl create configmap appsettings --from-file=appsettings.json --dry-run -o yaml

For mounting you should add a volume to your deployment or sts like this:

  volumes:
    - name: config
      configMap:
        name: appsettings

And then mount it to your container:

 volumeMounts:
        - mountPath: /appropriate/path/to/config/appsettings.json
          subPath: appsettings.json
          name: config

Also if you want you can use the config map as your environment variables source like this:

envFrom:
      - configMapRef:
          name: config

Read more here: Source link