Skip to content

Instantly share code, notes, and snippets.

@fabiand
Last active June 27, 2022 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabiand/1ecdcf45c75b38e8fb226e3f978b1fe0 to your computer and use it in GitHub Desktop.
Save fabiand/1ecdcf45c75b38e8fb226e3f978b1fe0 to your computer and use it in GitHub Desktop.
ResourceQuota without resource limits
# https://kubernetes.io/docs/tasks/administer-cluster/manage-resources/quota-memory-cpu-namespace/
[fabiand@toolbox Downloads]$ minikube kubectl -- apply -f - <<EOF
apiVersion: v1
kind: ResourceQuota
metadata:
name: mem-cpu-demo
spec:
hard:
requests.cpu: "1"
requests.memory: 1Gi
EOF
resourcequota/mem-cpu-demo created
[fabiand@toolbox Downloads]$ minikube kubectl -- get resourcequota mem-cpu-demo --output=yaml
apiVersion: v1
kind: ResourceQuota
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"v1","kind":"ResourceQuota","metadata":{"annotations":{},"name":"mem-cpu-demo","namespace":"default"},"spec":{"hard":{"requests.cpu":"1","requests.memory":"1Gi"}}}
creationTimestamp: "2022-06-27T16:58:38Z"
name: mem-cpu-demo
namespace: default
resourceVersion: "492"
uid: 0a1e8c41-653a-419c-9d77-d0b04dcbf38b
spec:
hard:
requests.cpu: "1"
requests.memory: 1Gi
status:
hard:
requests.cpu: "1"
requests.memory: 1Gi
used:
requests.cpu: "0"
requests.memory: "0"
[fabiand@toolbox Downloads]$ minikube kubectl -- create -f - <<EOF
apiVersion: v1
kind: Pod
metadata:
generateName: quota-mem-cpu-demo-
spec:
containers:
- name: quota-mem-cpu-demo-ctr
image: nginx
resources:
requests:
memory: "600Mi"
cpu: "400m"
EOF
pod/quota-mem-cpu-demo-h8t8t created
# (Above) No complaint about missing limits
# (Below) Just checking if it will now fail …
[fabiand@toolbox Downloads]$ minikube kubectl -- create -f - <<EOF
apiVersion: v1
kind: Pod
metadata:
generateName: quota-mem-cpu-demo-
spec:
containers:
- name: quota-mem-cpu-demo-ctr
image: nginx
resources:
limits:
requests:
memory: "600Mi"
cpu: "400m"
EOF
Error from server (Forbidden): error when creating "STDIN": pods "quota-mem-cpu-demo-66bxq" is forbidden: exceeded quota: mem-cpu-demo, requested: requests.memory=600Mi, used: requests.memory=600Mi, limited: requests.memory=1Gi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment