Advanced Scheduling and Node Selectors
Overview
A node selector specifies a map of key-value pairs. The rules are defined using custom labels on nodes and selectors specified in pods.
For the pod to be eligible to run on a node, the pod must have the indicated key-value pairs as the label on the node.
If you are using node affinity and node selectors in the same pod configuration, see the important considerations below.
Configuring Node Selectors
Using nodeSelector
in a pod configuration, you can ensure that pods are only placed onto nodes with specific labels.
Ensure you have the desired labels (see Updating Labels on Nodes for details) and node selector set up in your environment.
For example, make sure that your pod configuration features the
nodeSelector
value indicating the desired label:apiVersion: v1
kind: Pod
spec:
nodeSelector:
<key>: <value>
...
Modify the master configuration file, /etc/origin/master/master-config.yaml, to add
nodeSelectorLabelBlacklist
to theadmissionConfig
section with the labels that are assigned to the node hosts you want to deny pod placement:...
admissionConfig:
pluginConfig:
PodNodeConstraints:
configuration:
apiversion: v1
kind: PodNodeConstraintsConfig
nodeSelectorLabelBlacklist:
- kubernetes.io/hostname
- <label>
...
Restart OKD for the changes to take effect.
# master-restart api
# master-restart controllers
If you are using node selectors and node affinity in the same pod configuration, note the following:
|