Limiting the maximum number of pods per deployment within a namespace / cluster

8/15/2018

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?

-- Alexander
google-kubernetes-engine
kubernetes

2 Answers

8/22/2018

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.

-- Narendra
Source: StackOverflow

8/16/2018

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.

-- Eric Ho
Source: StackOverflow