I am attempting to enforce a limit on the number of pods per deployment within a namespace / cluster from a single configuration point. I have two non-production environments, and I want to deploy fewer replicas on these as they do not need the redundancy.
I've read this but I'm unable to find out how to do it on the deployment level. Is it possible to enforce this globally without going into each one of them?
Are you looking for something like this,
$ kubectl autoscale deployment <deployment-name> --min=1 --max=3 --cpu-percent=80 --namespace=<dev|staging>
Here, you can set the upper limit of the pod count for your deployment.
Since the replicas is a fixed value on a deployment YAML file, you may better to use helm to make a template for adding some flexibility in your application.