0

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
  • 29,069
  • 61
  • 260
  • 539
  • if you are creating pods using deployment then easy trick will be to scale your deployment to zero replica and then scale it back .. it will refresh your pods with no effort .. example : `kubectl scale deployment nginx --replicas=0` then scale back `kubectl scale deployment chat --replicas=20` – DT. Feb 11 '20 at 15:18

2 Answers2

2

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.
  • 3,351
  • 2
  • 18
  • 32
1

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.

Discombobulate
  • 279
  • 2
  • 8