kubernetes batch restart all namespace pod to make new config map config works

2/11/2020

I am modify config maps environment from DEV to FAT, and now I want to make it works in all my pods in dabai-fat name space.How to restart all pods in the namespace? If I modify one by one it is too slow, and my deployment service have more than 20 now. How to enable the config the easy way?

-- Dolphin
kubernetes

2 Answers

2/11/2020

You should prefer mounted config maps for your solution where you will not need POD restart.

Kubelet is checking whether the mounted ConfigMap is fresh on every periodic sync.

Total delay from the moment when the ConfigMap is updated to the moment when new keys are projected to the pod can be as long as kubelet sync period (1 minute by default) + ttl of ConfigMaps cache (1 minute by default) in kubelet. You can trigger an immediate refresh by updating one of the pod’s annotations. Important to remember that container using a ConfigMap as a subPath volume will not receive ConfigMap updates.

How to Add ConfigMap data to a Volume

-- DT.
Source: StackOverflow

2/11/2020

You should not edit already existing ConfigMap.

This question Restart pods when configmap updates in Kubernetes? is the best possible answer to your question.

First, use Deployments so it's easy to scale everything.

Second, create new ConfigMap and point Deployment to it. If new ConfigMap is broken the Deployment won't scale and if it's correct, the Deployment will scale to 0 and reschedule new pods that will be using new ConfigMap.

-- Spook
Source: StackOverflow