From a6cd9bac16fa1091f1e5d72154a5eb35538310ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Dulko?= Date: Tue, 20 Jun 2017 15:48:03 +0200 Subject: [PATCH] Use k8s 1.6 syntax of declaring affinity K8s 1.6 has affinity/antiaffinity funtionalities as a beta feature. This means we don't need to declare them using annotations. This commit switches usages of affinity to 1.6 syntax. Change-Id: Ia68f4ab28a018617bd44b1295fea58cd30eb4a39 --- ceph/templates/statefulset-mon.yaml | 34 ++++++++---------- doc/source/devref/getting-started/labels.rst | 37 +++++++++----------- mariadb/templates/statefulset.yaml | 36 ++++++++----------- rabbitmq/templates/deployment.yaml | 29 +++++++-------- 4 files changed, 57 insertions(+), 79 deletions(-) diff --git a/ceph/templates/statefulset-mon.yaml b/ceph/templates/statefulset-mon.yaml index 5aa86a1564..47a8ebc279 100644 --- a/ceph/templates/statefulset-mon.yaml +++ b/ceph/templates/statefulset-mon.yaml @@ -29,27 +29,21 @@ spec: labels: app: ceph daemon: mon - annotations: - # alanmeadows: this soft requirement allows single - # host deployments to spawn several ceph-mon - # containers - scheduler.alpha.kubernetes.io/affinity: > - { - "podAntiAffinity": { - "preferredDuringSchedulingIgnoredDuringExecution": [{ - "labelSelector": { - "matchExpressions": [{ - "key": "daemon", - "operator": "In", - "values":["mon"] - }] - }, - "topologyKey": "kubernetes.io/hostname", - "weight": 10 - }] - } - } spec: + # alanmeadows: this soft requirement allows single + # host deployments to spawn several ceph-mon + # containers + affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - podAffinityTerm: + labelSelector: + matchExpressions: + - key: app + operator: In + values: ["mon"] + topologyKey: kubernetes.io/hostname + weight: 10 nodeSelector: {{ .Values.labels.node_selector_key }}: {{ .Values.labels.node_selector_value }} serviceAccount: default diff --git a/doc/source/devref/getting-started/labels.rst b/doc/source/devref/getting-started/labels.rst index c0d853b68d..ebb74907ba 100644 --- a/doc/source/devref/getting-started/labels.rst +++ b/doc/source/devref/getting-started/labels.rst @@ -84,24 +84,19 @@ single host environment: :: - annotations: - # this soft requirement allows single - # host deployments to spawn several mariadb containers - # but in a larger environment, would attempt to spread - # them out - scheduler.alpha.kubernetes.io/affinity: > - { - "podAntiAffinity": { - "preferredDuringSchedulingIgnoredDuringExecution": [{ - "labelSelector": { - "matchExpressions": [{ - "key": "app", - "operator": "In", - "values":["mariadb"] - }] - }, - "topologyKey": "kubernetes.io/hostname", - "weight": 10 - }] - } - } + # alanmeadows: this soft requirement allows single + # host deployments to spawn several mariadb containers + # but in a larger environment, would attempt to spread + # them out + affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - podAffinityTerm: + labelSelector: + matchExpressions: + - key: app + operator: In + values: ["mariadb"] + topologyKey: kubernetes.io/hostname + weight: 10 + diff --git a/mariadb/templates/statefulset.yaml b/mariadb/templates/statefulset.yaml index dc4a53f936..c4cccf7a83 100644 --- a/mariadb/templates/statefulset.yaml +++ b/mariadb/templates/statefulset.yaml @@ -25,28 +25,22 @@ spec: labels: app: {{ .Values.service_name }} galera: enabled - annotations: - # alanmeadows: this soft requirement allows single - # host deployments to spawn several mariadb containers - # but in a larger environment, would attempt to spread - # them out - scheduler.alpha.kubernetes.io/affinity: > - { - "podAntiAffinity": { - "preferredDuringSchedulingIgnoredDuringExecution": [{ - "labelSelector": { - "matchExpressions": [{ - "key": "app", - "operator": "In", - "values":["mariadb"] - }] - }, - "topologyKey": "kubernetes.io/hostname", - "weight": 10 - }] - } - } spec: + # alanmeadows: this soft requirement allows single + # host deployments to spawn several mariadb containers + # but in a larger environment, would attempt to spread + # them out + affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - podAffinityTerm: + labelSelector: + matchExpressions: + - key: app + operator: In + values: ["mariadb"] + topologyKey: kubernetes.io/hostname + weight: 10 nodeSelector: {{ .Values.labels.node_selector_key }}: {{ .Values.labels.node_selector_value }} containers: diff --git a/rabbitmq/templates/deployment.yaml b/rabbitmq/templates/deployment.yaml index 86c3b1d878..864af8a2fe 100644 --- a/rabbitmq/templates/deployment.yaml +++ b/rabbitmq/templates/deployment.yaml @@ -35,24 +35,19 @@ spec: annotations: configmap-bin-hash: {{ tuple "configmap-bin.yaml" . | include "helm-toolkit.utils.hash" }} configmap-etc-hash: {{ tuple "configmap-etc.yaml" . | include "helm-toolkit.utils.hash" }} - # TODO: this needs to be moved to common. - scheduler.alpha.kubernetes.io/affinity: > - { - "podAntiAffinity": { - "preferredDuringSchedulingIgnoredDuringExecution": [{ - "labelSelector": { - "matchExpressions": [{ - "key": "app", - "operator": "In", - "values":["rabbitmq"] - }] - }, - "topologyKey": "kubernetes.io/hostname", - "weight": 10 - }] - } - } spec: + # TODO: this needs to be moved to common. + affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - podAffinityTerm: + labelSelector: + matchExpressions: + - key: app + operator: In + values: ["rabbitmq"] + topologyKey: kubernetes.io/hostname + weight: 10 nodeSelector: {{ .Values.labels.node_selector_key }}: {{ .Values.labels.node_selector_value }} volumes: