Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

in kubernetes, how to update pods to use updated configmap

I'm running more than one replicas of pods with kubernetes deployment and I'd like to update the replicas to use updated configmap in a rolling way. same like rolling-update works.

So that kubernetes will terminate pod and start sending traffic to the newly updated pods one at a time until all pods will be updated.

Can I use rolling-update with deployment?

like image 238
Maoz Zadok Avatar asked Jan 28 '23 18:01

Maoz Zadok


2 Answers

Applying a change to the Deployment object will trigger a rolling-update. From the docs:

A Deployment’s rollout is triggered if and only if the Deployment’s pod template (that is, .spec.template) is changed, for example if the labels or container images of the template are updated. Other updates, such as scaling the Deployment, do not trigger a rollout.

So if you want to trigger a rolling update to update your configmap I would suggest you update a metadata label. Perhaps a CONFIG_VER key.

like image 69
Zach Avatar answered Jan 30 '23 07:01

Zach


To automatically perform a rolling update of deployment on configmap update, you can also use a tool that my team has built and opensourced: Reloader which we are also using in production clusters of our customers.

Reloader watches changes in ConfigMap and Secret and updates the associated Deployments, Deamonsets and Statefulsets, based on the configured update strategy.

like image 20
Ahmad Avatar answered Jan 30 '23 08:01

Ahmad