From 69eecd6b60b8318c4b51dd2a6c587da693f7d0f9 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 14 Sep 2020 00:12:40 +0200 Subject: [PATCH] helm: add soft-affinity rules for worker and web --- helm/templates/web-deployment.yaml | 18 ++++++++++++++++++ helm/templates/worker-deployment.yaml | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/helm/templates/web-deployment.yaml b/helm/templates/web-deployment.yaml index 4ee223554..2d9dbb322 100644 --- a/helm/templates/web-deployment.yaml +++ b/helm/templates/web-deployment.yaml @@ -22,6 +22,24 @@ spec: app.kubernetes.io/instance: {{ .Release.Name }} k8s.passbook.beryju.org/component: web spec: + affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - labelSelector: + matchExpressions: + - key: app.kubernetes.io/name + operator: In + values: + - {{ include "passbook.name" . }} + - key: app.kubernetes.io/instance + operator: In + values: + - {{ .Release.Name }} + - key: k8s.passbook.beryju.org/component + operator: In + values: + - web + topologyKey: "kubernetes.io/hostname" initContainers: - name: passbook-database-migrations image: "{{ .Values.image.name }}:{{ .Values.image.tag }}" diff --git a/helm/templates/worker-deployment.yaml b/helm/templates/worker-deployment.yaml index 5f6bd98d4..c1774b54c 100644 --- a/helm/templates/worker-deployment.yaml +++ b/helm/templates/worker-deployment.yaml @@ -22,6 +22,24 @@ spec: app.kubernetes.io/instance: {{ .Release.Name }} k8s.passbook.beryju.org/component: worker spec: + affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - labelSelector: + matchExpressions: + - key: app.kubernetes.io/name + operator: In + values: + - {{ include "passbook.name" . }} + - key: app.kubernetes.io/instance + operator: In + values: + - {{ .Release.Name }} + - key: k8s.passbook.beryju.org/component + operator: In + values: + - worker + topologyKey: "kubernetes.io/hostname" containers: - name: {{ .Chart.Name }} image: "{{ .Values.image.name }}:{{ .Values.image.tag }}"