Skip to content

Commit

Permalink
add examples for interpod configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
dhilipkumars committed Aug 1, 2017
1 parent 5d96613 commit b786c23
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion docs/concepts/configuration/assign-pod-node.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ zone XYZ, but if it's not possible, then allow some to run elsewhere".

Node affinity is specified as field `nodeAffinity` of field `affinity` in the PodSpec.

Here's an example of a pod that uses node affinity:
#### An example of a pod that uses node affinity:

{% include code.html language="yaml" file="pod-with-node-affinity.yaml" ghlink="/docs/concepts/configuration/pod-with-node-affinity.yaml" %}

Expand All @@ -139,6 +139,31 @@ If you specify multiple `nodeSelectorTerms` associated with `nodeAffinity` types

If you specify multiple `matchExpressions` associated with `nodeSelectorTerms`, then the pod can be scheduled onto a node **only if all** `matchExpressions` can be satisfied.

#### More Practical Usage

Than directly using with pods Interpod Affinity and AnitAffinity will be more useful when they are used with higher
level objects such as Statefulset, Deployments, etc. One can easily configure and prefer if two workloads should
always be co-located in the same node or never be co-located in the same node.

##### Always co-located in the same node

A web application has an in-memory cache such as redis, one may prefer to co-locate their web server along with the cache as much as possible so that they have minimum latency like below.

| node-1 | node-2 | node-3 |
|:--------------------:|:-------------------:|:------------------:|
| *webserver-1* | *webserver-2* | *webserver-3* |
| *cache-1* | *cache-2* | *cache-3* |

##### Never co-located in the same node

Highly Available database statefulset has one master and three replicas, one may prefer none of the database instances to be co-located in the same node.

| node-1 | node-2 | node-3 | node-4 |
|:--------------------:|:-------------------:|:------------------:|:------------------:|
| *DB-MASTER* | *DB-REPLICA-1* | *DB-REPLICA-2* | *DB-REPLICA-3* |

[Here](https://kubernetes.io/docs/tutorials/stateful-application/zookeeper/#tolerating-node-failure) is an example of zookeper statefulset configued with anti-affinity for high availablity.

For more information on node affinity, see the design doc
[here](https://git.k8s.io/community/contributors/design-proposals/nodeaffinity.md).

Expand Down

0 comments on commit b786c23

Please sign in to comment.