Specifying the Node Label

The nodeSelector field in a pod specification provides a straightforward way to target a node or a set of nodes, using one or more key-value pairs.

spec:
  containers:
  - name: redis
    image: redis
  nodeSelector:
    net: fast

Setting the nodeSelector tells the scheduler to place the pod on a node that matches the labels. All listed selectors must be met, but the node could have more labels. In the example above, any node with a key of net set to fast would be a candidate for scheduling. Remember that labels are administrator-created tags, with no tie to actual resources. This node could have a slow network.

The pod would remain Pending until a node is found with the matching labels.

The use of affinity/anti-affinity should be able to express every feature as nodeSelector.

Last updated