Resource Quota
Tips and Tricks
For simulated Practice problems visit KillerCoda.
-
create a namespace
demo
and create a resource quotademo-quota
with hard requestscpu=1
,memory=1Gi
and hard limitscpu=2
,memory=2Gi
.Solution
# create namespace k create ns demo # create resource quota > quota.yaml apiVersion: v1 kind: ResourceQuota metadata: name: demo-quota namespace: demo spec: hard: requests.cpu: "1" requests.memory: 1Gi limits.cpu: "2" limits.memory: 2Gi k create -f quota.yaml k create quota demo-quota -n demo --hard=requests.cpu=1,requests.memory=1Gi,limits.cpu=2,limits.memory=2Gi
-
Try creating a pod
server
withnginx
image indemo
namespace with resources request ofcpu=2.1
andmemory=2.5Gi
. The pod creation will failSolution
# create the server pod k run server --image=nginx --dry-run=client -o yaml > pod.yaml # update resources request and limits in the pod apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: server name: server namespace: demo spec: containers: - image: nginx name: server resources: requests: cpu: "2.1" memory: 2.5Gi dnsPolicy: ClusterFirst restartPolicy: Always
-
Solution
# delete the pod if it exists. k delete po server --force # update resources request and limits in the pod apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: server name: server spec: containers: - image: nginx name: server resources: requests: cpu: "1" memory: 1Gi dnsPolicy: ClusterFirst restartPolicy: Always