0
0
Kubernetesdevops~5 mins

Node selectors for simple scheduling in Kubernetes - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a node selector in Kubernetes?
A node selector is a simple way to tell Kubernetes to schedule a pod only on nodes that have specific labels. It helps control where pods run.
Click to reveal answer
beginner
How do you specify a node selector in a pod's YAML file?
You add a nodeSelector field under spec with key-value pairs matching node labels. For example:<br>
spec:
  nodeSelector:
    disktype: ssd
Click to reveal answer
beginner
What happens if no nodes match the node selector labels?
The pod will stay in a pending state and will not be scheduled until a matching node becomes available.
Click to reveal answer
intermediate
Can a node selector use multiple labels?
Yes, you can specify multiple key-value pairs in nodeSelector. The pod will only schedule on nodes that have all those labels.
Click to reveal answer
beginner
How do you label a node in Kubernetes?
Use the command: kubectl label nodes <node-name> key=value. This adds a label to the node that can be matched by node selectors.
Click to reveal answer
What does a node selector do in Kubernetes?
AUpdates node software
BAutomatically scales nodes
CDeletes pods on nodes
DSchedules pods only on nodes with matching labels
Where do you specify the node selector in a pod YAML file?
AUnder metadata.labels
BUnder spec.nodeSelector
CUnder spec.containers
DUnder status.conditions
What happens if no nodes match the node selector labels?
APod is deleted automatically
BPod is scheduled on any node
CPod stays pending and is not scheduled
DPod runs on the master node
How do you add a label to a node?
Akubectl label nodes <node-name> key=value
Bkubectl add label <node-name> key=value
Ckubectl set label pod <pod-name> key=value
Dkubectl node label add key=value
Can a node selector require multiple labels?
AYes, all labels must match on the node
BNo, only one label is allowed
CYes, but only one label needs to match
DNo, node selectors do not use labels
Explain how node selectors control pod scheduling in Kubernetes.
Think about how pods find the right nodes to run on.
You got /5 concepts.
    Describe the steps to label a node and use that label to schedule a pod.
    Start from labeling the node, then tell the pod to use that label.
    You got /4 concepts.