0
0
Kubernetesdevops~20 mins

Resource quotas per namespace in Kubernetes - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Resource Quota Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:30remaining
Check current resource quotas in a namespace
You run the command kubectl get resourcequota -n dev. What output do you expect if no resource quotas are set in the dev namespace?
Kubernetes
kubectl get resourcequota -n dev
A
NAME      AGE
cpu-quota  10d
BNo resources found in dev namespace.
CError from server (NotFound): resourcequotas "dev" not found
D
NAME      CPU    MEMORY
quota1    2      4Gi
Attempts:
2 left
💡 Hint
Think about what kubectl shows when no resource quotas exist in a namespace.
Configuration
intermediate
2:00remaining
Define a resource quota limiting CPU and memory
Which YAML snippet correctly defines a resource quota named limit-quota in namespace test that limits CPU to 2 cores and memory to 4Gi?
A
apiVersion: v1
kind: ResourceQuota
metadata:
  name: limit-quota
  namespace: test
spec:
  hard:
    cpu: 2 cores
    memory: 4Gi
B
apiVersion: v1
kind: ResourceQuota
metadata:
  name: limit-quota
spec:
  hard:
    cpu: 2
    memory: 4Gi
  namespace: test
C
apiVersion: v1
kind: ResourceQuota
metadata:
  name: limit-quota
  namespace: test
spec:
  limits:
    cpu: "2"
    memory: 4Gi
D
apiVersion: v1
kind: ResourceQuota
metadata:
  name: limit-quota
  namespace: test
spec:
  hard:
    cpu: "2"
    memory: 4Gi
Attempts:
2 left
💡 Hint
Check the correct placement of namespace and the 'hard' field format.
Troubleshoot
advanced
1:30remaining
Why is a pod creation failing due to resource quota?
You have a resource quota limiting pods to 5 in namespace prod. You try to create a 6th pod and get this error: pods "mypod" is forbidden: exceeded quota: pod-quota, requested: pods=1, used: pods=5, limited: pods=5. What is the root cause?
AThe namespace has reached the maximum allowed pods defined by the resource quota.
BThe pod spec requests more CPU than allowed by the quota.
CThe pod name conflicts with an existing pod in the namespace.
DThe resource quota is not applied to the namespace.
Attempts:
2 left
💡 Hint
Look at the error message details about pods and quota limits.
🔀 Workflow
advanced
2:00remaining
Steps to update an existing resource quota
You want to increase the CPU limit in an existing resource quota named cpu-quota in namespace dev from 2 to 4 cores. Which sequence of commands is correct?
A
kubectl get resourcequota cpu-quota -n dev -o yaml > quota.yaml
Edit quota.yaml to set cpu: "4"
kubectl apply -f quota.yaml -n dev
B
kubectl edit resourcequota cpu-quota -n dev
Change cpu to 4
Save and exit
CAll of the above sequences are correct
Dkubectl patch resourcequota cpu-quota -n dev --type='merge' -p '{"spec":{"hard":{"cpu":"4"}}}'
Attempts:
2 left
💡 Hint
Consider different ways kubectl allows editing resources.
Best Practice
expert
1:30remaining
Why use resource quotas per namespace in a multi-team cluster?
What is the main benefit of applying resource quotas per namespace in a Kubernetes cluster shared by multiple teams?
AIt prevents any single team from using more than their fair share of cluster resources, ensuring fair resource distribution.
BIt automatically scales pods up and down based on team usage.
CIt encrypts all data stored in the namespace to secure team data.
DIt allows teams to bypass cluster-wide security policies.
Attempts:
2 left
💡 Hint
Think about resource fairness and limits in shared environments.