0
0
Kubernetesdevops~20 mins

Node selectors for simple scheduling in Kubernetes - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Node Selector Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
What does a node selector do in Kubernetes scheduling?

In Kubernetes, what is the primary purpose of using a nodeSelector in a Pod specification?

AIt restricts the Pod to be scheduled only on nodes that have matching labels specified in the nodeSelector.
BIt automatically scales the number of Pods based on node CPU usage.
CIt assigns a static IP address to the Pod within the cluster network.
DIt encrypts the Pod's data at rest on the node's disk.
Attempts:
2 left
💡 Hint

Think about how Kubernetes decides where to place Pods based on node labels.

💻 Command Output
intermediate
1:30remaining
Output of kubectl get pods with nodeSelector applied

You have a Pod with the following nodeSelector:

nodeSelector:
  disktype: ssd

After applying this Pod manifest, what will kubectl get pods -o wide show in the NODE column?

Kubernetes
apiVersion: v1
kind: Pod
metadata:
  name: test-pod
spec:
  containers:
  - name: nginx
    image: nginx
  nodeSelector:
    disktype: ssd
AAn error message indicating invalid nodeSelector.
BThe name of any node in the cluster, regardless of labels.
C<none> because the Pod is pending and not scheduled.
DThe name of a node that has the label 'disktype=ssd'.
Attempts:
2 left
💡 Hint

Check how nodeSelector affects Pod scheduling and node assignment.

Configuration
advanced
2:00remaining
Correct nodeSelector syntax in Pod manifest

Which of the following Pod YAML snippets correctly uses nodeSelector to schedule the Pod on nodes labeled zone: us-east-1?

A
spec:
  nodeSelector:
    - zone: us-east-1
  containers:
  - name: app
    image: myapp
B
spec:
  nodeSelector:
    zone: "us-east-1"
  containers:
  - name: app
    image: myapp
C
spec:
  nodeSelector:
    zone: us-east-1
  containers:
  - name: app
    image: myapp
D
spec:
  nodeSelector:
    zone: [us-east-1]
  containers:
  - name: app
    image: myapp
Attempts:
2 left
💡 Hint

Remember that nodeSelector expects a map of key-value pairs with string values.

Troubleshoot
advanced
2:00remaining
Pod stuck in Pending state with nodeSelector

You created a Pod with this nodeSelector:

nodeSelector:
  gpu: "true"

The Pod remains in Pending state indefinitely. What is the most likely cause?

ANo nodes in the cluster have the label <code>gpu=true</code>.
BThe Pod image is invalid and cannot be pulled.
CThe nodeSelector syntax is incorrect and causes a scheduling error.
DThe Pod's resource requests exceed the node capacity.
Attempts:
2 left
💡 Hint

Check if any node matches the nodeSelector labels.

Best Practice
expert
2:30remaining
Best practice for nodeSelector usage in multi-environment clusters

You manage a Kubernetes cluster shared by multiple teams and environments. Which approach is best to use nodeSelector for simple scheduling to isolate workloads by environment?

AUse nodeSelector with random labels to distribute Pods evenly across all nodes.
BAvoid nodeSelector and rely only on resource requests for scheduling decisions.
CLabel nodes with environment names (e.g., <code>env=dev</code>, <code>env=prod</code>) and use matching nodeSelectors in Pod specs.
DLabel Pods with environment names and use nodeSelector to match Pod labels.
Attempts:
2 left
💡 Hint

Think about how nodeSelector matches node labels, not Pod labels.