From 297c665eca30e517e688f97d107fdd750eec7b82 Mon Sep 17 00:00:00 2001 From: Guangya Liu Date: Thu, 4 May 2017 16:21:48 +0800 Subject: [PATCH] Added example for pod preferredDuringSchedulingIgnoredDuringExecution. --- docs/concepts/configuration/assign-pod-node.md | 7 ++++--- .../configuration/pod-with-pod-affinity.yaml | 18 ++++++++++-------- .../node-selection/pod-with-pod-affinity.yaml | 18 ++++++++++-------- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/docs/concepts/configuration/assign-pod-node.md b/docs/concepts/configuration/assign-pod-node.md index 4180db15cc..31d2f21921 100644 --- a/docs/concepts/configuration/assign-pod-node.md +++ b/docs/concepts/configuration/assign-pod-node.md @@ -173,14 +173,15 @@ Here's an example of a pod that uses pod affinity: {% include code.html language="yaml" file="pod-with-pod-affinity.yaml" ghlink="/docs/concepts/configuration/pod-with-pod-affinity.yaml" %} -The affinity on this pod defines one pod affinity rule and one pod anti-affinity rule. Both -must be satisfied for the pod to schedule onto a node. The +The affinity on this pod defines one pod affinity rule and one pod anti-affinity rule. In this example, the +`podAffinity` is `requiredDuringSchedulingIgnoredDuringExecution` +while the `podAntiAffinity` is `preferredDuringSchedulingIgnoredDuringExecution`. The pod affinity rule says that the pod can schedule onto a node only if that node is in the same zone as at least one already-running pod that has a label with key "security" and value "S1". (More precisely, the pod is eligible to run on node N if node N has a label with key `failure-domain.beta.kubernetes.io/zone` and some value V such that there is at least one node in the cluster with key `failure-domain.beta.kubernetes.io/zone` and value V that is running a pod that has a label with key "security" and value "S1".) The pod anti-affinity -rule says that the pod cannot schedule onto a node if that node is already running a pod with label +rule says that the pod prefer to not schedule onto a node if that node is already running a pod with label having key "security" and value "S2". (If the `topologyKey` were `failure-domain.beta.kubernetes.io/zone` then it would mean that the pod cannot schedule onto a node if that node is in the same zone as a pod with label having key "security" and value "S2".) See the [design doc](https://github.com/kubernetes/kubernetes/blob/{{page.githubbranch}}/docs/design/podaffinity.md). diff --git a/docs/concepts/configuration/pod-with-pod-affinity.yaml b/docs/concepts/configuration/pod-with-pod-affinity.yaml index ef5113564e..3728537d5a 100644 --- a/docs/concepts/configuration/pod-with-pod-affinity.yaml +++ b/docs/concepts/configuration/pod-with-pod-affinity.yaml @@ -14,14 +14,16 @@ spec: - S1 topologyKey: failure-domain.beta.kubernetes.io/zone podAntiAffinity: - requiredDuringSchedulingIgnoredDuringExecution: - - labelSelector: - matchExpressions: - - key: security - operator: In - values: - - S2 - topologyKey: kubernetes.io/hostname + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 100 + podAffinityTerm: + labelSelector: + matchExpressions: + - key: security + operator: In + values: + - S2 + topologyKey: kubernetes.io/hostname containers: - name: with-pod-affinity image: gcr.io/google_containers/pause:2.0 diff --git a/docs/user-guide/node-selection/pod-with-pod-affinity.yaml b/docs/user-guide/node-selection/pod-with-pod-affinity.yaml index ef5113564e..3728537d5a 100644 --- a/docs/user-guide/node-selection/pod-with-pod-affinity.yaml +++ b/docs/user-guide/node-selection/pod-with-pod-affinity.yaml @@ -14,14 +14,16 @@ spec: - S1 topologyKey: failure-domain.beta.kubernetes.io/zone podAntiAffinity: - requiredDuringSchedulingIgnoredDuringExecution: - - labelSelector: - matchExpressions: - - key: security - operator: In - values: - - S2 - topologyKey: kubernetes.io/hostname + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 100 + podAffinityTerm: + labelSelector: + matchExpressions: + - key: security + operator: In + values: + - S2 + topologyKey: kubernetes.io/hostname containers: - name: with-pod-affinity image: gcr.io/google_containers/pause:2.0