From 89a8eda43e4af3cf146f89a25e96c37dbaa5fa88 Mon Sep 17 00:00:00 2001 From: "anthony.bellino" Date: Fri, 17 May 2019 23:23:49 +0000 Subject: [PATCH] Add pod affinity to Shipyard and Airflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PS adds pod anti-affinity to airflow/shipyard pods, so that the scheduler can constrain pods against labels on other pods running on the node. The default soft rule is in place so that if the scheduler can’t satisfy the the requirement, the pod will still be scheduled, and is overridable. Change-Id: I67d0792a1f624044f8975c9540ab691f4e638b3f --- charts/shipyard/templates/deployment-airflow-scheduler.yaml | 2 ++ charts/shipyard/templates/deployment-shipyard.yaml | 2 ++ charts/shipyard/templates/statefulset-airflow-worker.yaml | 2 ++ charts/shipyard/values.yaml | 6 ++++++ 4 files changed, 12 insertions(+) diff --git a/charts/shipyard/templates/deployment-airflow-scheduler.yaml b/charts/shipyard/templates/deployment-airflow-scheduler.yaml index c8fccf11..40471329 100644 --- a/charts/shipyard/templates/deployment-airflow-scheduler.yaml +++ b/charts/shipyard/templates/deployment-airflow-scheduler.yaml @@ -47,6 +47,8 @@ spec: configmap-etc-hash: {{ tuple "configmap-airflow-etc.yaml" . | include "helm-toolkit.utils.hash" }} spec: serviceAccountName: {{ $serviceAccountName }} + affinity: +{{ tuple $envAll "airflow" "scheduler" | include "helm-toolkit.snippets.kubernetes_pod_anti_affinity" | indent 8 }} nodeSelector: {{ .Values.labels.airflow.node_selector_key }}: {{ .Values.labels.airflow.node_selector_value }} restartPolicy: Always diff --git a/charts/shipyard/templates/deployment-shipyard.yaml b/charts/shipyard/templates/deployment-shipyard.yaml index ba50073f..96f434a0 100644 --- a/charts/shipyard/templates/deployment-shipyard.yaml +++ b/charts/shipyard/templates/deployment-shipyard.yaml @@ -42,6 +42,8 @@ spec: spec: {{ dict "envAll" $envAll "application" "shipyard" | include "helm-toolkit.snippets.kubernetes_pod_security_context" | indent 6 }} serviceAccountName: {{ $serviceAccountName }} + affinity: +{{ tuple $envAll "shipyard" "api" | include "helm-toolkit.snippets.kubernetes_pod_anti_affinity" | indent 8 }} nodeSelector: {{ .Values.labels.shipyard.node_selector_key }}: {{ .Values.labels.shipyard.node_selector_value }} terminationGracePeriodSeconds: {{ .Values.pod.lifecycle.termination_grace_period.shipyard.timeout | default "30" }} diff --git a/charts/shipyard/templates/statefulset-airflow-worker.yaml b/charts/shipyard/templates/statefulset-airflow-worker.yaml index 64a3997e..9fcc5a31 100644 --- a/charts/shipyard/templates/statefulset-airflow-worker.yaml +++ b/charts/shipyard/templates/statefulset-airflow-worker.yaml @@ -75,6 +75,8 @@ spec: {{ tuple $envAll "airflow" "worker" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }} spec: serviceAccountName: {{ $serviceAccountName }} + affinity: +{{ tuple $envAll "airflow" "worker" | include "helm-toolkit.snippets.kubernetes_pod_anti_affinity" | indent 8 }} nodeSelector: {{ .Values.labels.airflow.node_selector_key }}: {{ .Values.labels.airflow.node_selector_value }} initContainers: diff --git a/charts/shipyard/values.yaml b/charts/shipyard/values.yaml index 38f4c564..6dbccfc4 100644 --- a/charts/shipyard/values.yaml +++ b/charts/shipyard/values.yaml @@ -734,6 +734,12 @@ pod: shipyard_db_sync: init_container: null shipyard_db_sync: + affinity: + anti: + type: + default: preferredDuringSchedulingIgnoredDuringExecution + topologyKey: + default: kubernetes.io/hostname replicas: shipyard: api: 2