– 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:

    - name: config
        name: appsettings

And then mount it to your container:

        - 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:

      - configMapRef:
          name: config

Read more here: Source link