Best practice for adding app configuration files into kubernetes pods Best practice for adding app configuration files into kubernetes pods kubernetes kubernetes

Best practice for adding app configuration files into kubernetes pods


You can use a configmap for this, but the configmap includes your config file. You can create a configmap with the content of your config file via the following:

kubectl create configmap my-config --from-file=my-config.ini=/path/to/your/config.ini

and the bind it as a volume in your pod:

apiVersion: v1kind: Podmetadata:  name: my-podspec:  containers:  - name: mypod    ...    volumeMounts:    - name: config      mountPath: "/config"      readOnly: true  volumes:  - name: config    configMap:      name: my-config #the name of your configmap

Afterwards your config is available in your pod under /config/my-config.ini