Scale down Kubernetes pods
You are doing the correct action; traditionally the scale
verb is applied just to the resource name, as in kubectl scale deploy my-awesome-deployment --replicas=0
, which removes the need to always point at the specific file that describes that deployment, but there's nothing wrong (that I know of) with using the file if that is more convenient for you.
Here we go. Scales down all deployments in a whole namespace:
kubectl get deploy -n <namespace> -o name | xargs -I % kubectl scale % --replicas=0 -n <namespace>
To scale up set --replicas=1
(or any other required number) accordingly
The solution is pretty easy and straightforward
kubectl scale deploy -n <namespace> --replicas=0 --all