DEV Community

Cover image for How to apply GKE config map changes
Rei Allen Ramos
Rei Allen Ramos

Posted on

How to apply GKE config map changes

I'm a developer by job title, but recently my tasks have been looming on the edge of being a devops. And my latest adventure involved modifying a GKE config map (setting environment variables). Let me share how I applied the changes to the affected pods.

Scale your deployment

Once you've saved your changes in the config map, the trick is to scale down your deployment to 0. WARNING: Make sure you're aware of the current replica set count before proceeding.

kubectl scale deployment service_name --replicas=0

A quick kubectl get pods will tell you the deployment is currently scaling down and existing pods are being terminated.

service_name-6bc55776bb-ncpsg           0/1     Terminating   0          9m45s

This should at most take a minute. In my case, it took just under 30secs to fully terminate the pod. Once the pod isn't listed anymore, scale it back to your original number (in my case it was 1).

kubectl scale deployment service_name --replicas=1

kubectl get pods

service_name-6bc55776bb-ncpsg           0/1     ContainerCreating   0          9m45s

That's it! Any modifications in your config map should now be reflected in the pod. If you know a more efficient way, please don't hesitate to share it!

Discussion (1)

Collapse
ip999 profile image
ip999

would using "kubectl rollout restart" be more efficient?