Skip to content

Commit 7078c38

Browse files
authored
Merge pull request #33792 from sftim/20220510_assign_pod_node_affinity_updates
Revise scheduling-related docs
2 parents d1164ab + ed58f04 commit 7078c38

File tree

13 files changed

+616
-446
lines changed

13 files changed

+616
-446
lines changed

content/en/blog/_posts/2020-05-05-introducing-podtopologyspread.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Let's see an example of a cluster to understand this API.
6767
As the feature name "PodTopologySpread" implies, the basic usage of this feature
6868
is to run your workload with an absolute even manner (maxSkew=1), or relatively
6969
even manner (maxSkew>=2). See the [official
70-
document](/docs/concepts/workloads/pods/pod-topology-spread-constraints/)
70+
document](/docs/concepts/scheduling-eviction/topology-spread-constraints/)
7171
for more details.
7272

7373
In addition to this basic usage, there are some advanced usage examples that

content/en/blog/_posts/2020-09-30-writing-crl-scheduler/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ To correct the latter issue, we now employ a "hunt and peck" approach to removin
7070
### 1. Upgrade to kubernetes 1.18 and make use of Pod Topology Spread Constraints
7171

7272
While this seems like it could have been the perfect solution, at the time of writing Kubernetes 1.18 was unavailable on the two most common managed Kubernetes services in public cloud, EKS and GKE.
73-
Furthermore, [pod topology spread constraints](/docs/concepts/workloads/pods/pod-topology-spread-constraints/) were still a [beta feature in 1.18](https://v1-18.docs.kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/) which meant that it [wasn't guaranteed to be available in managed clusters](https://cloud.google.com/kubernetes-engine/docs/concepts/types-of-clusters#kubernetes_feature_choices) even when v1.18 became available.
73+
Furthermore, [pod topology spread constraints](/docs/concepts/scheduling-eviction/topology-spread-constraints/) were still a beta feature in 1.18 which meant that it [wasn't guaranteed to be available in managed clusters](https://cloud.google.com/kubernetes-engine/docs/concepts/types-of-clusters#kubernetes_feature_choices) even when v1.18 became available.
7474
The entire endeavour was concerningly reminiscent of checking [caniuse.com](https://caniuse.com/) when Internet Explorer 8 was still around.
7575

7676
### 2. Deploy a statefulset _per zone_.

content/en/docs/concepts/scheduling-eviction/_index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ of terminating one or more Pods on Nodes.
2323
* [Kubernetes Scheduler](/docs/concepts/scheduling-eviction/kube-scheduler/)
2424
* [Assigning Pods to Nodes](/docs/concepts/scheduling-eviction/assign-pod-node/)
2525
* [Pod Overhead](/docs/concepts/scheduling-eviction/pod-overhead/)
26+
* [Pod Topology Spread Constraints](/docs/concepts/scheduling-eviction/topology-spread-constraints/)
2627
* [Taints and Tolerations](/docs/concepts/scheduling-eviction/taint-and-toleration/)
2728
* [Scheduling Framework](/docs/concepts/scheduling-eviction/scheduling-framework)
2829
* [Scheduler Performance Tuning](/docs/concepts/scheduling-eviction/scheduler-perf-tuning/)

content/en/docs/concepts/scheduling-eviction/assign-pod-node.md

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,27 @@ weight: 20
1111

1212
<!-- overview -->
1313

14-
You can constrain a {{< glossary_tooltip text="Pod" term_id="pod" >}} so that it can only run on particular set of
15-
{{< glossary_tooltip text="node(s)" term_id="node" >}}.
14+
You can constrain a {{< glossary_tooltip text="Pod" term_id="pod" >}} so that it is
15+
_restricted_ to run on particular {{< glossary_tooltip text="node(s)" term_id="node" >}},
16+
or to _prefer_ to run on particular nodes.
1617
There are several ways to do this and the recommended approaches all use
1718
[label selectors](/docs/concepts/overview/working-with-objects/labels/) to facilitate the selection.
18-
Generally such constraints are unnecessary, as the scheduler will automatically do a reasonable placement
19+
Often, you do not need to set any such constraints; the
20+
{{< glossary_tooltip text="scheduler" term_id="kube-scheduler" >}} will automatically do a reasonable placement
1921
(for example, spreading your Pods across nodes so as not place Pods on a node with insufficient free resources).
2022
However, there are some circumstances where you may want to control which node
21-
the Pod deploys to, for example, to ensure that a Pod ends up on a node with an SSD attached to it, or to co-locate Pods from two different
22-
services that communicate a lot into the same availability zone.
23+
the Pod deploys to, for example, to ensure that a Pod ends up on a node with an SSD attached to it,
24+
or to co-locate Pods from two different services that communicate a lot into the same availability zone.
2325

2426
<!-- body -->
2527

2628
You can use any of the following methods to choose where Kubernetes schedules
27-
specific Pods:
29+
specific Pods:
2830

2931
* [nodeSelector](#nodeselector) field matching against [node labels](#built-in-node-labels)
3032
* [Affinity and anti-affinity](#affinity-and-anti-affinity)
3133
* [nodeName](#nodename) field
34+
* [Pod topology spread constraints](#pod-topology-spread-constraints)
3235

3336
## Node labels {#built-in-node-labels}
3437

@@ -337,13 +340,15 @@ null `namespaceSelector` matches the namespace of the Pod where the rule is defi
337340
Inter-pod affinity and anti-affinity can be even more useful when they are used with higher
338341
level collections such as ReplicaSets, StatefulSets, Deployments, etc. These
339342
rules allow you to configure that a set of workloads should
340-
be co-located in the same defined topology, eg., the same node.
343+
be co-located in the same defined topology; for example, preferring to place two related
344+
Pods onto the same node.
341345

342-
Take, for example, a three-node cluster running a web application with an
343-
in-memory cache like redis. You could use inter-pod affinity and anti-affinity
344-
to co-locate the web servers with the cache as much as possible.
346+
For example: imagine a three-node cluster. You use the cluster to run a web application
347+
and also an in-memory cache (such as Redis). For this example, also assume that latency between
348+
the web application and the memory cache should be as low as is practical. You could use inter-pod
349+
affinity and anti-affinity to co-locate the web servers with the cache as much as possible.
345350

346-
In the following example Deployment for the redis cache, the replicas get the label `app=store`. The
351+
In the following example Deployment for the Redis cache, the replicas get the label `app=store`. The
347352
`podAntiAffinity` rule tells the scheduler to avoid placing multiple replicas
348353
with the `app=store` label on a single node. This creates each cache in a
349354
separate node.
@@ -378,10 +383,10 @@ spec:
378383
image: redis:3.2-alpine
379384
```
380385

381-
The following Deployment for the web servers creates replicas with the label `app=web-store`. The
382-
Pod affinity rule tells the scheduler to place each replica on a node that has a
383-
Pod with the label `app=store`. The Pod anti-affinity rule tells the scheduler
384-
to avoid placing multiple `app=web-store` servers on a single node.
386+
The following example Deployment for the web servers creates replicas with the label `app=web-store`.
387+
The Pod affinity rule tells the scheduler to place each replica on a node that has a Pod
388+
with the label `app=store`. The Pod anti-affinity rule tells the scheduler never to place
389+
multiple `app=web-store` servers on a single node.
385390

386391
```yaml
387392
apiVersion: apps/v1
@@ -430,6 +435,10 @@ where each web server is co-located with a cache, on three separate nodes.
430435
| *webserver-1* | *webserver-2* | *webserver-3* |
431436
| *cache-1* | *cache-2* | *cache-3* |
432437

438+
The overall effect is that each cache instance is likely to be accessed by a single client, that
439+
is running on the same node. This approach aims to minimize both skew (imbalanced load) and latency.
440+
441+
You might have other reasons to use Pod anti-affinity.
433442
See the [ZooKeeper tutorial](/docs/tutorials/stateful-application/zookeeper/#tolerating-node-failure)
434443
for an example of a StatefulSet configured with anti-affinity for high
435444
availability, using the same technique as this example.
@@ -468,6 +477,16 @@ spec:
468477

469478
The above Pod will only run on the node `kube-01`.
470479

480+
## Pod topology spread constraints
481+
482+
You can use _topology spread constraints_ to control how {{< glossary_tooltip text="Pods" term_id="Pod" >}}
483+
are spread across your cluster among failure-domains such as regions, zones, nodes, or among any other
484+
topology domains that you define. You might do this to improve performance, expected availability, or
485+
overall utilization.
486+
487+
Read [Pod topology spread constraints](/docs/concepts/scheduling-eviction/topology-spread-constraints/)
488+
to learn more about how these work.
489+
471490
## {{% heading "whatsnext" %}}
472491

473492
* Read more about [taints and tolerations](/docs/concepts/scheduling-eviction/taint-and-toleration/) .

content/en/docs/concepts/scheduling-eviction/kube-scheduler.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ of the scheduler:
8383
## {{% heading "whatsnext" %}}
8484

8585
* Read about [scheduler performance tuning](/docs/concepts/scheduling-eviction/scheduler-perf-tuning/)
86-
* Read about [Pod topology spread constraints](/docs/concepts/workloads/pods/pod-topology-spread-constraints/)
86+
* Read about [Pod topology spread constraints](/docs/concepts/scheduling-eviction/topology-spread-constraints/)
8787
* Read the [reference documentation](/docs/reference/command-line-tools-reference/kube-scheduler/) for kube-scheduler
8888
* Read the [kube-scheduler config (v1beta3)](/docs/reference/config-api/kube-scheduler-config.v1beta3/) reference
8989
* Learn about [configuring multiple schedulers](/docs/tasks/extend-kubernetes/configure-multiple-schedulers/)

0 commit comments

Comments
 (0)