Bird
Raised Fist0
Kubernetesdevops~20 mins

Why scheduling controls Pod placement in Kubernetes - Challenge Your Understanding

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Kubernetes Scheduling Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
How does the Kubernetes scheduler decide where to place a Pod?

In Kubernetes, the scheduler decides which node will run a new Pod. What is the main factor the scheduler uses to make this decision?

AIt selects the node with the most available resources that meet the Pod's requirements.
BIt randomly picks any node without checking resources.
CIt always places Pods on the first node in the cluster list.
DIt places Pods only on nodes labeled as 'master'.
Attempts:
2 left
💡 Hint

Think about how the scheduler ensures Pods have enough CPU and memory.

💻 Command Output
intermediate
2:00remaining
Output of scheduling a Pod with nodeSelector

You create a Pod with a nodeSelector that requires label disktype=ssd. What will happen if no nodes have this label?

Kubernetes
kubectl apply -f - <<EOF
apiVersion: v1
kind: Pod
metadata:
  name: test-pod
spec:
  containers:
  - name: test-container
    image: nginx
  nodeSelector:
    disktype: ssd
EOF
AThe Pod will remain in Pending state indefinitely because no node matches the selector.
BThe Pod will be scheduled on any node ignoring the nodeSelector.
CThe Pod will be deleted automatically by Kubernetes.
DThe Pod will run on the master node regardless of labels.
Attempts:
2 left
💡 Hint

Consider what happens when no nodes match the Pod's scheduling constraints.

🔀 Workflow
advanced
2:30remaining
Order the steps the Kubernetes scheduler follows to place a Pod

Put these steps in the correct order that the Kubernetes scheduler uses to place a Pod on a node.

A3,1,2,4
B1,2,3,4
C1,3,2,4
D2,1,3,4
Attempts:
2 left
💡 Hint

Think about filtering before scoring.

❓ Troubleshoot
advanced
2:00remaining
Why is a Pod stuck in Pending state despite available nodes?

A Pod is stuck in Pending state. The cluster has nodes with enough resources. What could be a reason related to scheduling?

AThe Pod's container command is invalid.
BThe Pod's container image is missing from the registry.
CThe cluster has no network connectivity.
DThe Pod has a <code>nodeSelector</code> that does not match any node labels.
Attempts:
2 left
💡 Hint

Focus on scheduling constraints, not container runtime issues.

✅ Best Practice
expert
2:30remaining
Choosing the best scheduling strategy for high availability

You want to deploy multiple replicas of a Pod to ensure high availability. Which scheduling feature helps spread Pods across nodes to avoid single points of failure?

AUse <code>hostNetwork: true</code> to share network namespace.
BUse <code>nodeSelector</code> to force all Pods on the same node.
CUse <code>podAntiAffinity</code> to spread Pods across different nodes.
DUse <code>tolerations</code> to allow Pods on tainted nodes.
Attempts:
2 left
💡 Hint

Think about spreading Pods to avoid failure impact.

Practice

(1/5)
1. What is the main role of scheduling in Kubernetes Pod placement?
easy
A. To update the container images inside Pods
B. To create new Pods automatically
C. To decide which node a Pod should run on
D. To delete unused Pods from the cluster

Solution

  1. Step 1: Understand scheduling purpose

    Scheduling in Kubernetes is responsible for choosing the best node for a Pod to run on.
  2. Step 2: Differentiate scheduling from other tasks

    Creating, deleting, or updating Pods is handled by other components, not the scheduler.
  3. Final Answer:

    To decide which node a Pod should run on -> Option C
  4. Quick Check:

    Scheduling = Pod node selection [OK]
Hint: Scheduling picks the node for Pods to run on [OK]
Common Mistakes:
  • Confusing scheduling with Pod creation
  • Thinking scheduler updates container images
  • Assuming scheduler deletes Pods
2. Which of the following is a valid Kubernetes scheduler configuration to restrict Pods to nodes with label zone=us-east?
easy
A. nodeAffinity: key: zone operator: NotIn values: [us-east]
B. nodeSelector: region: us-east
C. nodeAffinity: key: zone operator: Exists
D. nodeSelector: zone: us-east

Solution

  1. Step 1: Identify correct nodeSelector syntax

    nodeSelector uses key-value pairs to select nodes; here, zone: us-east is correct.
  2. Step 2: Check other options for correctness

    nodeSelector: region: us-east uses wrong key region. nodeAffinity: key: zone operator: NotIn values: [us-east] excludes us-east nodes. nodeAffinity: key: zone operator: Exists only checks if zone exists, not restricting to us-east.
  3. Final Answer:

    nodeSelector: zone: us-east -> Option D
  4. Quick Check:

    nodeSelector key=value matches node label [OK]
Hint: nodeSelector uses exact key-value pairs for node labels [OK]
Common Mistakes:
  • Using wrong label keys in nodeSelector
  • Confusing nodeAffinity operators
  • Using NotIn instead of In for selection
3. Given this Pod spec snippet, what will happen if no nodes have label disk=ssd?
spec:
  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
        - matchExpressions:
          - key: disk
            operator: In
            values:
            - ssd
medium
A. Pod will be scheduled on any node ignoring the label
B. Pod will remain Pending until a node with disk=ssd is available
C. Pod will be scheduled on nodes without the label but with enough resources
D. Pod will be deleted automatically by the scheduler

Solution

  1. Step 1: Understand requiredDuringScheduling nodeAffinity

    This rule means the Pod must be scheduled only on nodes matching the label disk=ssd.
  2. Step 2: Check behavior if no matching nodes exist

    If no nodes have disk=ssd, the Pod cannot be scheduled and stays in Pending state.
  3. Final Answer:

    Pod will remain Pending until a node with disk=ssd is available -> Option B
  4. Quick Check:

    Required nodeAffinity = Pod waits for matching node [OK]
Hint: Required nodeAffinity blocks scheduling if no matching node [OK]
Common Mistakes:
  • Thinking Pod schedules ignoring required nodeAffinity
  • Assuming Pod gets deleted if unschedulable
  • Confusing required and preferred nodeAffinity
4. You wrote this nodeAffinity in your Pod spec but the Pod is stuck in Pending state:
nodeAffinity:
  requiredDuringSchedulingIgnoredDuringExecution:
    nodeSelectorTerms:
    - matchExpressions:
      - key: gpu
        operator: Exists
      - key: memory
        operator: In
        values:
        - high
What is the likely problem?
medium
A. No nodes have both labels gpu and memory=high
B. The syntax of nodeAffinity is invalid
C. The scheduler ignores nodeAffinity rules
D. Pod spec is missing container image

Solution

  1. Step 1: Analyze nodeAffinity conditions

    Pod requires nodes with label gpu (any value) and memory=high.
  2. Step 2: Check why Pod is Pending

    If no node has both labels, Pod cannot be scheduled and stays Pending.
  3. Final Answer:

    No nodes have both labels gpu and memory=high -> Option A
  4. Quick Check:

    Missing matching nodes = Pod Pending [OK]
Hint: Pod Pending often means no nodes match all affinity labels [OK]
Common Mistakes:
  • Assuming syntax error without checking labels
  • Thinking scheduler ignores affinity rules
  • Blaming unrelated Pod spec parts
5. You want to ensure Pods with label app=frontend only run on nodes with label env=production, but allow Pods with app=backend to run anywhere. Which scheduling configuration achieves this?
hard
A. Add a nodeAffinity with requiredDuringScheduling for env=production only in frontend Pods
B. Use a nodeSelector with env=production in all Pods
C. Use a taint on production nodes and tolerate it in backend Pods
D. Add a preferredDuringScheduling nodeAffinity for env=production in backend Pods

Solution

  1. Step 1: Understand requirement for frontend Pods

    Frontend Pods must run only on nodes labeled env=production. Backend Pods have no restriction.
  2. Step 2: Choose correct scheduling control

    Adding requiredDuringScheduling nodeAffinity to frontend Pods enforces this. Backend Pods without affinity run anywhere.
  3. Final Answer:

    Add a nodeAffinity with requiredDuringScheduling for env=production only in frontend Pods -> Option A
  4. Quick Check:

    Required nodeAffinity limits frontend Pods; backend unrestricted [OK]
Hint: Use required nodeAffinity only on Pods needing strict placement [OK]
Common Mistakes:
  • Applying nodeSelector to all Pods causing backend restriction
  • Using preferred affinity which is not strict
  • Misusing taints and tolerations for this case
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard