CKAD · Question #3
You are required to create a pod that requests a certain amount of CPU and memory, so it gets scheduled to a node that has those resources available. Create a pod named nginx-resources in the…
This question tests your ability to define Kubernetes resource requests for a pod, which influence the scheduler's placement decisions by ensuring the pod lands on a node with sufficient CPU and memory capacity.
Question
- Create a pod named nginx-resources in the pod-resources namespace that requests a minimum of 200m CPU and 1Gi memory for its container
- The pod should use the nginx image
- The pod-resources namespace has already been created
Explanation
This question tests your ability to define Kubernetes resource requests for a pod, which influence the scheduler's placement decisions by ensuring the pod lands on a node with sufficient CPU and memory capacity.
Approach. Create the pod in the 'pod-resources' namespace using 'kubectl run' with the '--overrides' flag or apply a YAML manifest that includes a 'resources.requests' block under the container spec. The correct manifest sets 'requests.cpu: 200m' (200 millicores) and 'requests.memory: 1Gi' under the nginx container. The imperative command would be: kubectl run nginx-resources --image=nginx --namespace=pod-resources --requests='cpu=200m,memory=1Gi'. Alternatively, write a Pod YAML with spec.containers[0].resources.requests.cpu=200m and spec.containers[0].resources.requests.memory=1Gi, then apply it with 'kubectl apply -f pod.yaml'. Resource requests (not limits) are what the scheduler uses to find a qualifying node.
Concept tested. Kubernetes Pod resource requests (CPU and memory) and how they interact with the scheduler to ensure pod placement on nodes with adequate available capacity.
Reference. https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
Topics
Community Discussion
No community discussion yet for this question.