Storing and updating config files for my applications with kubernetes

3/25/2017

My application uses a config file. How to push updates to it? How they should be stored for convenient updates? In volumes?

The pipeline for the app is Git -> CI -> deb repo -> docker registry. So the updates to it is just to tell kubernetes to select a new image.

What to do for the config file? Maybe the same chain and then just spin up an container with NFS on it? Also, the app has to be notified about the parameters change via a SIGHUP. How to add that hook?

-- Velkan
docker
kubernetes

1 Answer

4/1/2017

You can use kubernetes configMaps for configs. Don't bake the configs inside the container image.

You can expose the configs as evironment variable or can be mounted as volumes inside pod.

ConfigMap can be generated from a file as well.

In your case it seems like you are reading from config file which is at specific location so you can use configMap and then mount this configMap at the same location from where your app will read, so you don't need to make any changes in your app.

And when you need to update the config just update the configMap and then the new pods that come up will start reading the config. I don't know how to update the config in running pod, what I have tried is scale up and then scale down.

configMaps: https://kubernetes.io/docs/user-guide/configmap/

HTH

-- surajd
Source: StackOverflow