apiVersion: v1 kind: Pod spec: nodeSelector: <key>: <value> ...
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.
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) in two places:
Add nodeSelectorLabelBlacklist
to the admissionConfig
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> ...
Then, add the same to the kubernetesMasterConfig
section to restrict direct pod creation:
... kubernetesMasterConfig: admissionConfig: pluginConfig: PodNodeConstraints: configuration: apiVersion: v1 kind: PodNodeConstraintsConfig nodeSelectorLabelBlacklist: - kubernetes.io/hostname - <label_1> ...
Restart OpenShift Container Platform for the changes to take effect.
# systemctl restart atomic-openshift-master
If you are using node selectors and node affinity in the same pod configuration, note the following:
|