Set quotas and default limits per team
In this task you'll cap what a team's namespace can use, with sensible defaults.
A ResourceQuota caps a namespace's total requests, limits and object counts. A LimitRange gives containers default requests and limits when they don't set their own.
Once a quota covers requests and limits, every new pod must have them, which is why the defaults matter. Neither changes pods that are already running.
Example. Two teams share Fernhill Cloud's test cluster; each namespace is capped at 1 CPU of requests, so one team's runaway job can't starve the other.
Costs money. This task creates resources that are charged while they exist. Delete them as soon as you finish.
Before you start
You need: An AKS cluster. Time: 15 minutes.
Where to look
- kubectl apply
- describe quota
Steps
- Apply a ResourceQuota and a LimitRange (type Container, default and defaultRequest) to each team namespace.
kubectl describe quota -n <ns>shows used against hard.- Restart existing deployments so their pods pick up the defaults.
Commands
# Connect kubectl to the cluster first
az aks get-credentials -g <group> -n <cluster>
kubectl apply -n team-a -f team.yaml
kubectl describe quota -n team-a
kubectl rollout restart deploy -n team-a
Watch out for
- Cost
- Free.
- Security
- Quotas also limit the damage of a compromised workload that tries to mine crypto.
- Common mistakes
- Setting a quota with no LimitRange, so every pod without resources is rejected.
Clean up
kubectl delete resourcequota,limitrange --all -n <ns>.
Words to know
- ResourceQuota
- Totals a namespace may use.
- LimitRange
- Defaults and bounds for each container.
Tick off each step and track your progress in the guide.
Open this task in DevOps, Hands On