From 9a05beee8fb6f3909237f55277956b2dac52288e Mon Sep 17 00:00:00 2001 From: Robbie Blaine Date: Mon, 4 Apr 2022 18:08:48 +0200 Subject: [PATCH] Feat: Add custom affinity config Add the ability to customize affinity config --- .../templates/_helpers_coordinator.tpl | 13 +++++++++- .../dremio_v2/templates/_helpers_executor.tpl | 16 +++++++++++- .../dremio_v2/templates/_helpers_general.tpl | 13 +++++++++- .../templates/_helpers_zookeeper.tpl | 13 +++++++++- charts/dremio_v2/templates/dremio-admin.yaml | 1 + .../templates/dremio-coordinator.yaml | 4 ++- .../dremio_v2/templates/dremio-executor.yaml | 1 + charts/dremio_v2/templates/dremio-master.yaml | 11 +------- .../templates/dremio-service-client.yaml | 2 +- charts/dremio_v2/templates/zookeeper.yaml | 11 +------- charts/dremio_v2/values.yaml | 25 ++++++++++++++++++- 11 files changed, 83 insertions(+), 27 deletions(-) diff --git a/charts/dremio_v2/templates/_helpers_coordinator.tpl b/charts/dremio_v2/templates/_helpers_coordinator.tpl index 81cd5d29..f1fc4796 100644 --- a/charts/dremio_v2/templates/_helpers_coordinator.tpl +++ b/charts/dremio_v2/templates/_helpers_coordinator.tpl @@ -150,4 +150,15 @@ Coordinator - Pod Tolerations tolerations: {{- toYaml $coordinatorTolerations | nindent 2 }} {{- end -}} -{{- end -}} \ No newline at end of file +{{- end -}} + +{{/* +Coordinator - Pod Affinity +*/}} +{{- define "dremio.coordinator.affinity" -}} +{{- $coordinatorAffinity := coalesce $.Values.coordinator.affinity $.Values.affinity -}} +{{- if $coordinatorAffinity -}} +affinity: + {{- toYaml $coordinatorAffinity | nindent 2 }} +{{- end -}} +{{- end -}} diff --git a/charts/dremio_v2/templates/_helpers_executor.tpl b/charts/dremio_v2/templates/_helpers_executor.tpl index d8ae6d21..26a00c8c 100644 --- a/charts/dremio_v2/templates/_helpers_executor.tpl +++ b/charts/dremio_v2/templates/_helpers_executor.tpl @@ -329,4 +329,18 @@ Executor - Pod Tolerations tolerations: {{- toYaml $engineTolerations | nindent 2 }} {{- end -}} -{{- end -}} \ No newline at end of file +{{- end -}} + +{{/* +Executor - Pod Affinity +*/}} +{{- define "dremio.executor.affinity" -}} +{{- $context := index . 0 -}} +{{- $engineName := index . 1 -}} +{{- $engineConfiguration := default (dict) (get (default (dict) $context.Values.executor.engineOverride) $engineName) -}} +{{- $engineAffinity := coalesce $engineConfiguration.affinity $context.Values.executor.affinity $context.Values.affinity -}} +{{- if $engineAffinity -}} +affinity: + {{- toYaml $engineAffinity | nindent 2 }} +{{- end -}} +{{- end -}} diff --git a/charts/dremio_v2/templates/_helpers_general.tpl b/charts/dremio_v2/templates/_helpers_general.tpl index 9d5f2c55..bcfa9871 100644 --- a/charts/dremio_v2/templates/_helpers_general.tpl +++ b/charts/dremio_v2/templates/_helpers_general.tpl @@ -83,4 +83,15 @@ Admin - Pod Tolerations tolerations: {{- toYaml $adminPodTolerations | nindent 2 }} {{- end -}} -{{- end -}} \ No newline at end of file +{{- end -}} + +{{/* +Admin - Pod Affinity +*/}} +{{- define "dremio.admin.affinity" -}} +{{- $adminPodAffinity := coalesce $.Values.coordinator.affinity $.Values.affinity -}} +{{- if $adminPodAffinity -}} +affinity: + {{- toYaml $adminPodAffinity | nindent 2 }} +{{- end -}} +{{- end -}} diff --git a/charts/dremio_v2/templates/_helpers_zookeeper.tpl b/charts/dremio_v2/templates/_helpers_zookeeper.tpl index f3774a00..6f089b11 100644 --- a/charts/dremio_v2/templates/_helpers_zookeeper.tpl +++ b/charts/dremio_v2/templates/_helpers_zookeeper.tpl @@ -89,4 +89,15 @@ Zookeeper - Pod Tolerations tolerations: {{- toYaml $zookeeperTolerations | nindent 2 }} {{- end -}} -{{- end -}} \ No newline at end of file +{{- end -}} + +{{/* +Zookeeper - Pod Affinity +*/}} +{{- define "dremio.zookeeper.affinity" -}} +{{- $zookeeperAffinity := coalesce $.Values.zookeeper.affinity $.Values.affinity -}} +{{- if $zookeeperAffinity -}} +affinity: + {{- toYaml $zookeeperAffinity | nindent 2 }} +{{- end -}} +{{- end -}} diff --git a/charts/dremio_v2/templates/dremio-admin.yaml b/charts/dremio_v2/templates/dremio-admin.yaml index 10de4317..957457e6 100644 --- a/charts/dremio_v2/templates/dremio-admin.yaml +++ b/charts/dremio_v2/templates/dremio-admin.yaml @@ -31,6 +31,7 @@ spec: {{- include "dremio.imagePullSecrets" $ | nindent 2 }} {{- include "dremio.admin.nodeSelector" $ | nindent 2 }} {{- include "dremio.admin.tolerations" $ | nindent 2 }} + {{- include "dremio.admin.affinity" $ | nindent 2 }} volumes: - name: dremio-master-volume persistentVolumeClaim: diff --git a/charts/dremio_v2/templates/dremio-coordinator.yaml b/charts/dremio_v2/templates/dremio-coordinator.yaml index dc5d8426..b4e56b19 100644 --- a/charts/dremio_v2/templates/dremio-coordinator.yaml +++ b/charts/dremio_v2/templates/dremio-coordinator.yaml @@ -25,6 +25,8 @@ spec: spec: {{- include "dremio.coordinator.serviceAccount" $ | nindent 6 }} terminationGracePeriodSeconds: 120 + affinity: + {{- include "dremio.coordinator.affinity" $ | nindent 8 }} {{- include "dremio.coordinator.nodeSelector" $ | nindent 6 }} {{- include "dremio.coordinator.tolerations" $ | nindent 6 }} containers: @@ -176,4 +178,4 @@ spec: {{- end }} {{- include "dremio.coordinator.extraVolumes" $ | nindent 6 }} {{- include "dremio.imagePullSecrets" $ | nindent 6}} -{{- end -}} \ No newline at end of file +{{- end -}} diff --git a/charts/dremio_v2/templates/dremio-executor.yaml b/charts/dremio_v2/templates/dremio-executor.yaml index fffdc53c..40fde457 100644 --- a/charts/dremio_v2/templates/dremio-executor.yaml +++ b/charts/dremio_v2/templates/dremio-executor.yaml @@ -30,6 +30,7 @@ spec: terminationGracePeriodSeconds: 120 {{- include "dremio.executor.nodeSelector" (list $ $engineName) | nindent 6}} {{- include "dremio.executor.tolerations" (list $ $engineName) | nindent 6}} + {{- include "dremio.executor.affinity" (list $ $engineName) | nindent 6}} containers: - name: dremio-executor image: {{ $.Values.image }}:{{ $.Values.imageTag }} diff --git a/charts/dremio_v2/templates/dremio-master.yaml b/charts/dremio_v2/templates/dremio-master.yaml index f2f9b792..dd4cee26 100644 --- a/charts/dremio_v2/templates/dremio-master.yaml +++ b/charts/dremio_v2/templates/dremio-master.yaml @@ -23,16 +23,7 @@ spec: {{- include "dremio.coordinator.podAnnotations" $ | nindent 8}} spec: {{- include "dremio.coordinator.serviceAccount" $ | nindent 6 }} - affinity: - podAntiAffinity: - requiredDuringSchedulingIgnoredDuringExecution: - - labelSelector: - matchExpressions: - - key: "app" - operator: In - values: - - dremio-coordinator - topologyKey: "kubernetes.io/hostname" + {{- include "dremio.coordinator.affinity" $ | nindent 6 }} terminationGracePeriodSeconds: 120 {{- include "dremio.coordinator.nodeSelector" $ | nindent 6 }} {{- include "dremio.coordinator.tolerations" $ | nindent 6 }} diff --git a/charts/dremio_v2/templates/dremio-service-client.yaml b/charts/dremio_v2/templates/dremio-service-client.yaml index 7de85817..ae95cbae 100644 --- a/charts/dremio_v2/templates/dremio-service-client.yaml +++ b/charts/dremio_v2/templates/dremio-service-client.yaml @@ -38,4 +38,4 @@ spec: clusterIP: None selector: role: dremio-cluster-pod -{{- end -}} \ No newline at end of file +{{- end -}} diff --git a/charts/dremio_v2/templates/zookeeper.yaml b/charts/dremio_v2/templates/zookeeper.yaml index c5494513..67f9c25a 100644 --- a/charts/dremio_v2/templates/zookeeper.yaml +++ b/charts/dremio_v2/templates/zookeeper.yaml @@ -63,16 +63,7 @@ spec: {{- include "dremio.zookeeper.podAnnotations" $ | nindent 8 }} spec: {{- include "dremio.zookeeper.serviceAccount" $ | nindent 6 }} - affinity: - podAntiAffinity: - requiredDuringSchedulingIgnoredDuringExecution: - - labelSelector: - matchExpressions: - - key: "app" - operator: In - values: - - zk - topologyKey: "kubernetes.io/hostname" + {{- include "dremio.zookeeper.affinity" $ | nindent 6 }} {{- include "dremio.zookeeper.nodeSelector" $ | nindent 6 }} {{- include "dremio.zookeeper.tolerations" $ | nindent 6 }} containers: diff --git a/charts/dremio_v2/values.yaml b/charts/dremio_v2/values.yaml index 2afd07de..8542a3da 100644 --- a/charts/dremio_v2/values.yaml +++ b/charts/dremio_v2/values.yaml @@ -26,6 +26,7 @@ labels: {} podLabels: {} nodeSelector: {} tolerations: [] +affinity: {} # Dremio Coordinator coordinator: @@ -78,6 +79,16 @@ coordinator: #podLabels: {} #nodeSelector: {} #tolerations: [] + affinity: + podAntiAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + - labelSelector: + matchExpressions: + - key: "app" + operator: In + values: + - dremio-coordinator + topologyKey: "kubernetes.io/hostname" # Web UI web: @@ -180,7 +191,7 @@ executor: volumes: - size: 100Gi - # These values, when defined and not empty, override the provided shared annotations, labels, node selectors, or tolerations. + # These values, when defined and not empty, override the provided shared annotations, labels, node selectors, tolerations, or affinity. # Uncomment only if you are trying to override the chart's shared values. #annotations: {} #podAnnotations: {} @@ -188,6 +199,7 @@ executor: #podLabels: {} #nodeSelector: {} #tolerations: [] + #affinity: {} # Engine Overrides # @@ -216,6 +228,7 @@ executor: # podLabels: {} # nodeSelector: {} # tolerations: [] + # affinity: {} # # serviceAccount: "" # @@ -275,6 +288,16 @@ zookeeper: #podLabels: {} #nodeSelector: {} #tolerations: [] + affinity: + podAntiAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + - labelSelector: + matchExpressions: + - key: "app" + operator: In + values: + - zk + topologyKey: "kubernetes.io/hostname" # Control where uploaded files are stored for Dremio. # For more information, see https://docs.dremio.com/deployment/distributed-storage.html