Creating quotas

  1. Create a compute quota object:
    apiVersion: v1
    kind: ResourceQuota
    metadata:
      name: compute-quota
    spec:
      hard:
        pods: "2"
        requests.cpu: "1"
        requests.memory: 20Mi
        limits.cpu: "2"
        limits.memory: 2Gi
    
    > kubectl create -f compute-quota.yaml
    resourcequota "compute-quota" created
  1. Next, let's add a count quota object:
    apiVersion: v1
    kind: ResourceQuota
    metadata:
      name: object-counts-quota
    spec:
      hard:
        configmaps: "10"
        persistentvolumeclaims: "4"
        replicationcontrollers: "20"
        secrets: "10"
        services: "10"
        services.loadbalancers: "2"
    
    > kubectl create -f object-count-quota.yaml
    resourcequota "object-counts-quota" created 
  1. We can observe all the quotas:
    > kubectl get quota
    NAME                     AGE
    compute-resources        17m
    object-counts 15m ...

Get Mastering Kubernetes now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.