From 76440b211079bd930107b964cffdb6964207446f Mon Sep 17 00:00:00 2001 From: Michael Burke Date: Wed, 24 Jan 2018 20:50:31 -0500 Subject: [PATCH] reorg'd scheduler doc and new pod placement topic --- _topic_map.yml | 2 + admin_guide/revhistory_admin_guide.adoc | 24 + admin_guide/scheduling/index.adoc | 5 + admin_guide/scheduling/pod_placement.adoc | 380 ++++++ admin_guide/scheduling/scheduler.adoc | 1181 +++++++++-------- .../admission_controllers.adoc | 8 +- welcome/revhistory_full.adoc | 4 + 7 files changed, 1049 insertions(+), 555 deletions(-) create mode 100644 admin_guide/scheduling/pod_placement.adoc diff --git a/_topic_map.yml b/_topic_map.yml index c7910737bfca..b22eaeb51ff8 100644 --- a/_topic_map.yml +++ b/_topic_map.yml @@ -573,6 +573,8 @@ Topics: File: scheduler - Name: Custom Scheduling File: custom_scheduler + - Name: Controlling Pod Placement + File: pod_placement - Name: Advanced Scheduling File: scheduler-advanced - Name: Advanced Scheduling and Node Affinity diff --git a/admin_guide/revhistory_admin_guide.adoc b/admin_guide/revhistory_admin_guide.adoc index 37f405dd3f91..499e43ae14cc 100644 --- a/admin_guide/revhistory_admin_guide.adoc +++ b/admin_guide/revhistory_admin_guide.adoc @@ -8,6 +8,30 @@ // do-release: revhist-tables +== Fri Feb 23 2018 + +// tag::admin_guide_fri_feb_23_2018[] +[cols="1,3",options="header"] +|=== + +|Affected Topic |Description of Change +//Fri Feb 23 2018 +n|xref:../admin_guide/scheduling/scheduler.adoc#admin-guide-scheduler[Default Scheduling] +|Reorganized topic and updated the list of predicates and policies in the xref:../admin_guide/scheduling/scheduler.adoc#scheduler-policy[Scheduler Policy] section. + +|xref:../admin_guide/scheduling/pod_placement.adoc#controlling-pod-placement[Controlling Pod Placement] +|Created new topic from the Controlling Pod Placement section of the xref:../admin_guide/scheduling/scheduler.adoc#admin-guide-scheduler[Default Scheduling] topic. No change to the content. + +|xref:../admin_guide/manage_scc.adoc#admin-guide-manage-scc[Managing Security Context Constraints] +|Noted the importance of `-z` flag usage when xref:../admin_guide/manage_scc.adoc#add-scc-to-user-group-project[granting access to service accounts]. + +|xref:../admin_guide/service_accounts.adoc#admin-guide-service-accounts[Configuring Service Accounts] +|Noted the importance of `-z` flag usage when xref:../admin_guide/service_accounts.adoc#admin-sa-user-names-and-groups[granting access to service accounts]. +|=== + +// end::admin_guide_fri_feb_23_2018[]] + + == Tues Feb 20 2018 // tag::admin_guide_tues_feb_20_2018[] diff --git a/admin_guide/scheduling/index.adoc b/admin_guide/scheduling/index.adoc index 3a22455f6e1a..e2e9d32a5b69 100644 --- a/admin_guide/scheduling/index.adoc +++ b/admin_guide/scheduling/index.adoc @@ -16,6 +16,10 @@ toc::[] Pod scheduling is an internal process that determines placement of new pods onto nodes within the cluster. +The scheduler code has a clean separation that watches new pods +as they get created and identifies the most suitable node to host them. It then +creates bindings (pod to node bindings) for the pods using the master API. + [[admin-guide-scheduling-index-default]] == Default scheduling @@ -36,3 +40,4 @@ For information about advanced scheduling, see xref:../../admin_guide/scheduling {product-title} also allows you to use your own or third-party schedulers by editing the pod specification. For more information, see xref:../../admin_guide/scheduling/custom_scheduler.adoc#admin-guide-sched-custom[Custom Schedulers]. + diff --git a/admin_guide/scheduling/pod_placement.adoc b/admin_guide/scheduling/pod_placement.adoc new file mode 100644 index 000000000000..fc62c28a0f56 --- /dev/null +++ b/admin_guide/scheduling/pod_placement.adoc @@ -0,0 +1,380 @@ +[[controlling-pod-placement]] += Controlling Pod Placement +{product-author} +{product-version} +:data-uri: +:icons: +:experimental: +:toc: macro +:toc-title: + +toc::[] + +== Overview + +As a cluster administrator, you can set a policy to prevent application +developers with certain roles from targeting specific nodes when scheduling +pods. + +The Pod Node Constraints admission controller ensures that pods +are deployed onto only specified node hosts using labels] +and prevents users without a specific role from using the +`nodeSelector` field to schedule pods. + +[[constraining-pod-placement-labels]] +== Constraining Pod Placement Using Node Name + +Use the Pod Node Constraints admission controller to 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. + +. Ensure you have the desired labels +ifdef::openshift-enterprise,openshift-origin[] +(see xref:../../admin_guide/manage_nodes.adoc#updating-labels-on-nodes[Updating +Labels on Nodes] for details) +endif::openshift-enterprise,openshift-origin[] +ifdef::openshift-dedicated[] +(request changes by opening a support case on the +https://access.redhat.com/support/[Red Hat Customer Portal]) +endif::openshift-dedicated[] +and xref:../../admin_guide/managing_projects.adoc#using-node-selectors[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: +---- + +. Modify the master configuration file +(*_/etc/origin/master/master-config.yaml_*) in two places: ++ +.. Add `PodNodeConstraints` to the `admissionConfig` section: ++ +---- +... +admissionConfig: + pluginConfig: + PodNodeConstraints: + configuration: + apiversion: v1 + kind: PodNodeConstraintsConfig +... +---- + +.. Then, add the same to the `kubernetesMasterConfig` section: ++ +---- +... +kubernetesMasterConfig: + admissionConfig: + pluginConfig: + PodNodeConstraints: + configuration: + apiVersion: v1 + kind: PodNodeConstraintsConfig +... +---- + +. Restart {product-title} for the changes to take effect. +ifdef::openshift-origin[] ++ +---- +# systemctl restart origin-master +---- +endif::[] +ifdef::openshift-enterprise[] ++ +---- +# systemctl restart atomic-openshift-master +---- +endif::[] + + +[[constraining-pod-placement-nodeselector]] +== Constraining Pod Placement Using a Node Selector + +Using xref:../../admin_guide/managing_projects.adoc#using-node-selectors[node selectors], +you can ensure that pods are only placed onto nodes with specific labels. As a cluster administrator, you can +use the Pod Node Constraints admission controller to set a policy that prevents users without the *pods/binding* permission +from using node selectors to schedule pods. + +The `nodeSelectorLabelBlacklist` field of a master configuration file gives you +control over the labels that certain roles can specify in a pod configuration's +`nodeSelector` field. Users, service accounts, and groups that have the +*pods/binding* permission xref:../../admin_guide/manage_rbac.adoc#admin-guide-manage-rbac[role] + can specify any node selector. Those without the +*pods/binding* permission are prohibited from setting a `nodeSelector` for any +label that appears in `nodeSelectorLabelBlacklist`. + +For example, an {product-title} cluster might consist of five data +centers spread across two regions. In the U.S., "us-east", "us-central", and +"us-west"; and in the Asia-Pacific region (APAC), "apac-east" and "apac-west". +Each node in each geographical region is labeled accordingly. For example, +`region: us-east`. + +[NOTE] +==== +ifdef::openshift-enterprise,openshift-origin[] +See xref:../../admin_guide/manage_nodes.adoc#updating-labels-on-nodes[Updating +Labels on Nodes] for details on assigning labels. +endif::openshift-enterprise,openshift-origin[] +ifdef::openshift-dedicated[] +(request changes by opening a support case on the +https://access.redhat.com/support/[Red Hat Customer Portal]) +endif::openshift-dedicated[] +==== + +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 project-level node selector, +and nodes labeled `region: us-east` are also labeled `superregion: us`. + + +. Ensure you have the desired labels +ifdef::openshift-enterprise,openshift-origin[] +(see xref:../../admin_guide/manage_nodes.adoc#updating-labels-on-nodes[Updating +Labels on Nodes] for details) +endif::openshift-enterprise,openshift-origin[] +ifdef::openshift-dedicated[] +(request changes by opening a support case on the +https://access.redhat.com/support/[Red Hat Customer Portal]) +endif::openshift-dedicated[] +and xref:../../admin_guide/managing_projects.adoc#using-node-selectors[node selector] +set up in your environment. +//tag::node-selectors[] ++ +For example, make sure that your pod configuration features the `nodeSelector` +value indicating the desired label: ++ +---- +apiVersion: v1 +kind: Pod +spec: + nodeSelector: + : +... +---- + +. 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 + -