From e002378c13e91bef4a3b0ba718c191ec791ce3f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reinhard=20N=C3=A4gele?= Date: Mon, 7 Aug 2017 19:23:15 +0200 Subject: [PATCH] [stable/mongodb-replicaset] Add pod anti-affinity (#1606) Adds pod anti-affinity with "soft" and "hard" option, "soft" being the default. --- stable/mongodb-replicaset/Chart.yaml | 2 +- .../templates/mongodb-statefulset.yaml | 21 +++++++++++++++++++ stable/mongodb-replicaset/values.yaml | 2 ++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/stable/mongodb-replicaset/Chart.yaml b/stable/mongodb-replicaset/Chart.yaml index 5b236007a6..d61a107820 100644 --- a/stable/mongodb-replicaset/Chart.yaml +++ b/stable/mongodb-replicaset/Chart.yaml @@ -1,6 +1,6 @@ name: mongodb-replicaset home: https://github.com/mongodb/mongo -version: 1.1.0 +version: 1.2.0 description: NoSQL document-oriented database that stores JSON-like documents with dynamic schemas, simplifying the integration of data in content-driven applications. icon: https://webassets.mongodb.com/_com_assets/cms/mongodb-logo-rgb-j6w271g1xn.jpg sources: diff --git a/stable/mongodb-replicaset/templates/mongodb-statefulset.yaml b/stable/mongodb-replicaset/templates/mongodb-statefulset.yaml index f5f26ce161..ca31b73b3b 100644 --- a/stable/mongodb-replicaset/templates/mongodb-statefulset.yaml +++ b/stable/mongodb-replicaset/templates/mongodb-statefulset.yaml @@ -160,6 +160,27 @@ spec: mountPath: /keydir readOnly: true {{- end }} + {{- if eq .Values.podAntiAffinity "hard" }} + affinity: + podAntiAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + - topologyKey: "kubernetes.io/hostname" + labelSelector: + matchLabels: + app: "{{ template "name" . }}" + release: "{{ .Release.Name }}" + {{- else if eq .Values.podAntiAffinity "soft" }} + affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 1 + podAffinityTerm: + topologyKey: kubernetes.io/hostname + labelSelector: + matchLabels: + app: "{{ template "name" . }}" + release: "{{ .Release.Name }}" + {{- end }} volumes: - name: config configMap: diff --git a/stable/mongodb-replicaset/values.yaml b/stable/mongodb-replicaset/values.yaml index bbbf0dc854..2fbfe0c0ce 100644 --- a/stable/mongodb-replicaset/values.yaml +++ b/stable/mongodb-replicaset/values.yaml @@ -25,6 +25,8 @@ image: # Annotations to be added to MongoDB pods podAnnotations: {} +podAntiAffinity: "soft" + resources: {} # limits: # cpu: 100m