As a cluster administrator, you can create an infrastructure where application developers should be deploying pods only onto the nodes closest to their geographical location. You can create a node selector, grouping the U.S. data centers into superregion: us and the APAC data centers into superregion: apac. To maintain an even loading of resources per data center, you can add the desired region to the nodeSelectorLabelBlacklist section of a master configuration. Then, whenever a developer located in the U.S. creates a pod, it is deployed onto a node in one of the regions with the superregion: us label. If the developer tries to target a specific region for their pod (for example, region: us-east), they receive an error. If they try again, without the node selector on their pod, it can still be deployed onto the region they tried to target, because superregion: us is set as the projectlevel node selector, and nodes labeled region: us-east are also labeled superregion: us.
14.2.9.1. Constraining Pod Placement Using Node Name Ensure a pod is deployed onto only a specified node host by assigning it a label and specifying this in the nodeName setting in a pod configuration. 1. Ensure you have the desired labels and node selector set up in your environment. For example, make sure that your pod configuration features the nodeName value indicating the desired label: apiVersion: v1 kind: Pod spec: nodeName:
2. Modify the master configuration file (/etc/origin/master/master-config.yaml ) in two places: a. Add nodeSelectorLabelBlacklist to the admissionConfig section: ... admissionConfig: pluginConfig: PodNodeConstraints: configuration: apiversion: v1 kind: PodNodeConstraintsConfig ...
b. Then, add the same to the kubernetesMasterConfig section to restrict direct pod creation: ... kubernetesMasterConfig: admissionConfig: pluginConfig: PodNodeConstraints: configuration: apiVersion: v1 kind: PodNodeConstraintsConfig ...
3. Restart OpenShift Container Platform for the changes to take effect.
14.2.9.2. Constraining Pod Placement Using a Node Selector Using nodeSelector in a pod configuration, you can ensure that pods are only placed onto nodes with specific labels. 1. 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: : ...
2. Modify the master configuration file (/etc/origin/master/master-config.yaml ) in two places: a. 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 -