CKAD field manual
k8s ResourceQuota YAML example
A Quota rejects the create if the namespace would go over. A LimitRange mutates the Pod if requests were omitted.
kubectl create quota app --hard=pods=5,cpu=2,memory=2Gi -n app
apiVersion: v1
kind: ResourceQuota
metadata:
name: app
namespace: app
spec:
hard:
pods: "5"
requests.cpu: "2"
requests.memory: 2Gi
limits.cpu: "4"
limits.memory: 4Gi
apiVersion: v1
kind: LimitRange
metadata:
name: app
namespace: app
spec:
limits:
- type: Container
default:
cpu: "200m"
memory: 256Mi
defaultRequest:
cpu: "100m"
memory: 128Mi
max:
cpu: "500m"
memory: 1Gi
Fields
- hard
- Ceiling for the whole namespace. pods, cpu, memory, requests.cpu, limits.memory.
- default
- LimitRange. Injected as the container limit when the Pod omitted it.
- defaultRequest
- Injected as the request when the Pod omitted it. Quota often needs this.
- max
- Per-container ceiling. Over this, the Pod is rejected.
- kubectl create quota
- --hard=pods=5,cpu=2,memory=2Gi. Memory 2Gi and 2G are the same quantity.
Watch
- A Quota on requests.cpu rejects a Pod with no CPU request. Put a LimitRange defaultRequest next to it.
- LimitRange default is the limit, defaultRequest is the request. max is per container, not the namespace.
- 2Gi and 2G are the same. Do not fight kubectl over the suffix.
Official docs Resource Quotas Limit Ranges