Setting Default CPU/Memory Requests For A Namespace

Today, I ran into the problem of trying to enforce a minimum amount of resources requested for a Kubernetes namespace.

We have a namespace that developers deploy all of our microservices. Not all of the deployments have a minimum CPU/memory set.

One way you can do this is to use a LimitRange.

It looks like this:

apiVersion: v1
kind: LimitRange
  name: mem-limit-range
  namespace: <your namespace here>
  - default:
      memory: 512Mi
      memory: 256Mi
    type: Container

If you’re an operator of a Kubernetes cluster, consider using LimitRanges to reduce the effects of noisy neighbors on your cluster.

Join the 80/20 DevOps Newsletter

If you're an engineering leader or developer, you should subscribe to my 80/20 DevOps Newsletter. Give me 1 minute of your day, and I'll teach you essential DevOps skills. I cover topics like Kubernetes, AWS, Infrastructure as Code, and more.

Not sure yet? Check out the archive.

Unsubscribe at any time.