What are other ways to provide configuration information to pods other than ConfigMap

4/15/2020

I have a deployment in which I want to populate pod with config files without using ConfigMap.

-- user9263173
kubernetes

2 Answers

4/15/2020

You can use environment variable and read the value from environment. Or you

-- hoque
Source: StackOverflow

4/15/2020

You could also store your config files on a PersistentVolume and read those files at container startup. For more details on that topic please take a look at the K8S reference docs: https://kubernetes.io/docs/concepts/storage/persistent-volumes/

Please note: I would not consider this good practice. I used this approach in the early beginning of a project where a legacy app was migrated to Kubernetes: The application consisted of tons of config files that were read by the application at startup.

Later on I switched to creating ConfigMaps from my configuration files, as the latter approach allows to store the K8S object (yaml file) in Git and I found managing/editing a ConfigMap way easier/faster, especially in a multi-node K8S environment:

kubectl create configmap app-config --from-file=./app-config1.properties --from-file=./app-config2.properties

If you go for the "config files in persistent volume" approach you need to take different aspects into account... e.g. how to bring your configuration files on that volume, potentially not on a single but multiple nodes, and how to keep them in sync.

-- Tommy Brettschneider
Source: StackOverflow