When deleting a pod manually kubectl delete
wait for the pod to be deleted and one can include a kubectl wait --for....
condition in a script to wait for the pod to be deleted.
I would like to perform the same wait condition but when scaling down (replicas: 0) a deployment.
From the deployment json, the available/unavailable replicas doesn't count the "terminating" pods and as expected kubectl wait --for=delete deployment test-dep
doesn't wait for pod termination but for deployment deletion.
So I would like to perform on my script:
kubectl scale --replicas=0 deployment foo-bar
kubectl wait --for=deletion-of-pod-from-deploymenent=foo-bar
Is there a way to do that?
Remarks: I would like to have the code as generic as possible so no hard writing the labels from deployment.