I need to simply recreate all the pods on certain releases, say 10 in number, on a production cluster. Is there a helm
command to loop over release names and pods under each release should be deleted and then recreated. any hints?
I am familiar with
for nmspc in $namespace_list; do kubectl delete pods -n $nmspc; done
However, I am trying to see if there is an equivalent helm command to do the same, such that once pods are deleted under the releases, they are spun up again.
for rlsz in $release_list; do helm delete pods -n $rlsz; done
Does something like this exist?
You can try
helm upgrade --recreate-pods <release_name> path/to/chart
If your charts are organized in a list of directories, and directory name corresponds to release name (recommended approach), you can use
for d in */ ; do
helm upgrade --recreate-pods "${d%?} "${d}"
done
where ${d%?}
removes trailing slash from directory name.
Note, that by definition, recreate-pods will cause downtime.
If you simply want to restart the pods, and they are all deployed via Helm, you can simply do
kubectl delete pods -n my-namespace --all
Tiller will re-create them, as if they crashed.
@Alex Pakka suggested you right approach with helm upgrade --recreate-pods <release_name> path/to/chart
, but yeah sometimes it depends on chart.
Just for example I took nginx-ingress-1.15.0.tgz
from stable/nginx-ingress
helm fetch stable/nginx-ingress
and installed in standard way
helm install --name nginx-ingress --namespace kube-system nginx-ingress-1.15.0.tgz
After deploying I was able successfully recreate pods with the below command:
helm upgrade --recreate-pods nginx-ingress nginx-ingress-1.15.0.tgz --username "xxxxx" --password "xxxxx"
---
nginx-ingress-controller-cd996946d-95ndx 1/1 Running 0 47s
nginx-ingress-default-backend-77c7c664bb-2nsdp 1/1 Running 0 46s
---
nginx-ingress-controller-cd996946d-95ndx 1/1 Terminating 0 93s
nginx-ingress-controller-cd996946d-dd6dc 0/1 ContainerCreating 0 0s
nginx-ingress-default-backend-77c7c664bb-2nsdp 1/1 Terminating 0 92s
nginx-ingress-default-backend-77c7c664bb-mnrvj 0/1 ContainerCreating 0 0s
---
nginx-ingress-controller-cd996946d-dd6dc 1/1 Running 0 21s
nginx-ingress-default-backend-77c7c664bb-mnrvj 1/1 Running 0 21s