Node Selectors
Node selectors are used assign pods to specific nodes. Pods are assigned by selecting the nodes using labels.
apiVersion: v1
kind: Pod
metadata:
name: nginx
spec:
containers:
- name: nginx
image: nginx
nodeSelector:
- type: powerful
With this, pod can be assigned to any node with label type=powerful
.
We can assigned label to node using following command,
kubectl label nodes kube type=powerful
Limitation
Assigning pods to node selectively using this method has some limitations. We can specify complex conditions to choose a node for pods. For example, assign pod to type=large
and type=medium
size node. This where node affinity comes into picture.