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!

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (1)

Collapse
 
ip999 profile image
ip999

would using "kubectl rollout restart" be more efficient?

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Instrument, monitor, fix: a hands-on debugging session

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️