Complete the code to specify the node selector for a Pod.
spec:
nodeSelector:
disktype: [1]The nodeSelector key is used to specify the node label that the Pod should be scheduled on. Here, disktype: ssd means the Pod will be placed on nodes labeled with disktype=ssd.
Complete the command to view the scheduler logs.
kubectl logs -n kube-system [1]The scheduler runs as a pod named kube-scheduler in the kube-system namespace. Viewing its logs helps understand Pod placement decisions.
Fix the error in the Pod spec to correctly use node affinity.
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: [1]
operator: In
values:
- ssdThe key must match the exact node label key. Commonly, disktype is used as a label key without underscores or camelCase.
Fill both blanks to create a Pod affinity rule that prefers nodes running Pods labeled 'zone=us-east'.
spec:
affinity:
podAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchExpressions:
- key: [1]
operator: In
values:
- [2]The affinity rule uses the label key zone and value us-east to prefer scheduling Pods on nodes already running other Pods labeled zone=us-east.
Fill all three blanks to define a Pod anti-affinity rule that avoids nodes running Pods with label 'app=frontend'.
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
labelSelector:
matchExpressions:
- key: [1]
operator: [2]
values:
- [3]The anti-affinity rule uses app as the key, In as the operator to match the Pods to avoid, and frontend as the value to avoid nodes running frontend Pods.