From 30f4fc862a16ef5a695139c1fdcc16b38c3a54ac Mon Sep 17 00:00:00 2001 From: "Choi, James [USA]" Date: Fri, 4 Oct 2024 10:24:38 -0400 Subject: [PATCH] #96 support node affinities and tolerations in spark history v2 --- .../aissemble-spark-history-chart/README.md | 2 + .../templates/deployment.yaml | 8 ++++ .../tests/deployment_test.yaml | 38 +++++++++++++++++++ .../aissemble-spark-history-chart/values.yaml | 2 + 4 files changed, 50 insertions(+) diff --git a/extensions/extensions-helm/extensions-helm-spark-infrastructure/aissemble-spark-history-chart/README.md b/extensions/extensions-helm/extensions-helm-spark-infrastructure/aissemble-spark-history-chart/README.md index e285aec2c..a4b3aac5e 100644 --- a/extensions/extensions-helm/extensions-helm-spark-infrastructure/aissemble-spark-history-chart/README.md +++ b/extensions/extensions-helm/extensions-helm-spark-infrastructure/aissemble-spark-history-chart/README.md @@ -31,6 +31,8 @@ _**NOTE:**_ *the version should match the aiSSEMBLE project version.* | deployment.envFromSecret | Environment variables to pull from a Secret. Format:
`ENV_VAR.secretName: k8s_secret_name`
`ENV_VAR.key: k8s_secret_key` | {} | | deployment.volumes | Volumes to attach to the Spark History Server Deployment. | [] | | deployment.volumeMounts | Volume mounts to attach to the Spark History Server Deployment. | [] | +| deployment.affinity | Node Affinity rule to constrain which nodes your Pod can be scheduled on based on node labels. | {} | | +| deployment.tolerations | Tolerations rule to ensure that pods are not scheduled onto inappropriate nodes. | [] | | dependencies.packages | List of packages to install in the Spark History Server Deployment. | [] | | dependencies.jars | List of jars to install in the Spark History Server Deployment. | [] | | ingress.enabled | Enable or disable the Spark History Server Ingress. | true | diff --git a/extensions/extensions-helm/extensions-helm-spark-infrastructure/aissemble-spark-history-chart/templates/deployment.yaml b/extensions/extensions-helm/extensions-helm-spark-infrastructure/aissemble-spark-history-chart/templates/deployment.yaml index 0dabc8f18..47c3fa5a7 100644 --- a/extensions/extensions-helm/extensions-helm-spark-infrastructure/aissemble-spark-history-chart/templates/deployment.yaml +++ b/extensions/extensions-helm/extensions-helm-spark-infrastructure/aissemble-spark-history-chart/templates/deployment.yaml @@ -32,6 +32,10 @@ spec: {{ toYaml .Values.deployment.labels }} {{- end }} spec: + {{- if .Values.deployment.affinity }} + affinity: + {{- toYaml .Values.deployment.affinity | nindent 8 }} + {{- end }} {{- if or (not (empty .Values.dependencies.packages)) (not (empty .Values.dependencies.jars)) }} initContainers: - name: "populate-jar-volume" @@ -120,4 +124,8 @@ spec: {{- if .Values.deployment.volumes }} {{- toYaml .Values.deployment.volumes }} {{- end }} + {{- if .Values.deployment.tolerations }} + tolerations: + {{- toYaml .Values.deployment.tolerations | nindent 8 }} + {{- end }} {{- end }} diff --git a/extensions/extensions-helm/extensions-helm-spark-infrastructure/aissemble-spark-history-chart/tests/deployment_test.yaml b/extensions/extensions-helm/extensions-helm-spark-infrastructure/aissemble-spark-history-chart/tests/deployment_test.yaml index 9130af599..2165732b2 100644 --- a/extensions/extensions-helm/extensions-helm-spark-infrastructure/aissemble-spark-history-chart/tests/deployment_test.yaml +++ b/extensions/extensions-helm/extensions-helm-spark-infrastructure/aissemble-spark-history-chart/tests/deployment_test.yaml @@ -378,3 +378,41 @@ tests: - equal: path: spec.template.spec.containers[0].ports[0].name value: "port-name" + + - it: When specifying tolerations, the appropriate tolerations are configured + set: + deployment.tolerations: + - key: "node.kubernetes.io/not-ready-test" + operator: "Exists" + effect: "NoSchedule" + asserts: + - contains: + path: spec.template.spec.tolerations + any: true + content: + key: "node.kubernetes.io/not-ready-test" + operator: "Exists" + effect: "NoSchedule" + + - it: When specifying node affinities, the appropriate affinities are configured + set: + deployment.affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: kubernetes.io/arch + operator: In + values: + - arm64 + asserts: + - contains: + path: spec.template.spec.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms + any: true + content: + matchExpressions: + - key: kubernetes.io/arch + operator: In + values: + - arm64 + diff --git a/extensions/extensions-helm/extensions-helm-spark-infrastructure/aissemble-spark-history-chart/values.yaml b/extensions/extensions-helm/extensions-helm-spark-infrastructure/aissemble-spark-history-chart/values.yaml index 3f335b0a7..ad4849cc0 100644 --- a/extensions/extensions-helm/extensions-helm-spark-infrastructure/aissemble-spark-history-chart/values.yaml +++ b/extensions/extensions-helm/extensions-helm-spark-infrastructure/aissemble-spark-history-chart/values.yaml @@ -16,6 +16,8 @@ deployment: envFromSecret: {} volumes: [] volumeMounts: [] + tolerations: [] + affinity: {} dependencies: packages: []