I have written a bash script to get all deployments on a kubernetes cluster. I have a command to scale all the deployments to zero. The challenge I am having is that, I want to be able to loop through all the deployments and save their name and number of replicas so I scale them back to the original after scaling down.
How do I achieve that? This is what I have done so far.
$ kubectl get deployments
$ kubectl scale deploy -n default --replicas=0 --all
kubectl rollout restart
is the better option. – Liselisetta