From 91b5193fdfa3745ea345294558b61a96c77e4826 Mon Sep 17 00:00:00 2001 From: Gaspard FEREY Date: Wed, 30 Oct 2024 16:27:14 +0100 Subject: [PATCH] Add extraenv secret --- .../jupyter-python/templates/statefulset.yaml | 8 ++--- charts/library-chart/Chart.yaml | 2 +- charts/library-chart/templates/_secret.tpl | 33 ++++++++++++++++--- .../vscode-python/templates/statefulset.yaml | 8 ++--- 4 files changed, 37 insertions(+), 14 deletions(-) diff --git a/charts/jupyter-python/templates/statefulset.yaml b/charts/jupyter-python/templates/statefulset.yaml index f50bf408..97e719aa 100644 --- a/charts/jupyter-python/templates/statefulset.yaml +++ b/charts/jupyter-python/templates/statefulset.yaml @@ -191,10 +191,6 @@ spec: - name: DARK_MODE value: "true" {{- end }} - {{- range .Values.extraEnvVars }} - - name: {{ .name }} - value: {{ tpl .value $.Values }} - {{- end }} envFrom: - secretRef: name: {{ include "library-chart.secretNameToken" . }} @@ -222,6 +218,10 @@ spec: - secretRef: name: {{ include "library-chart.secretNameMLFlow" . }} {{- end }} + {{- if .Values.extraEnvVars }} + - secretRef: + name: {{ include "library-chart.secretNameExtraEnv" . }} + {{- end }} livenessProbe: httpGet: path: / diff --git a/charts/library-chart/Chart.yaml b/charts/library-chart/Chart.yaml index 4aff5f6a..3bede0d8 100644 --- a/charts/library-chart/Chart.yaml +++ b/charts/library-chart/Chart.yaml @@ -1,4 +1,4 @@ apiVersion: v2 name: library-chart -version: 1.5.28 +version: 1.5.29 type: library diff --git a/charts/library-chart/templates/_secret.tpl b/charts/library-chart/templates/_secret.tpl index 5176a5db..ea62738a 100644 --- a/charts/library-chart/templates/_secret.tpl +++ b/charts/library-chart/templates/_secret.tpl @@ -178,8 +178,8 @@ stringData: {{/* Secret for CoreSite.xml Metastore */}} {{- define "library-chart.coreSite" -}} {{ printf "" }} -{{ printf "" }} -{{ printf ""}} +{{ printf "" }} +{{ printf ""}} {{ printf ""}} {{ printf "fs.s3a.connection.ssl.enabled" | indent 4}} {{ printf "true" | indent 4}} @@ -255,8 +255,8 @@ stringData: {{/* Secret for Hive Metastore */}} {{- define "hiveMetastore.secret" -}} {{- printf "\n" }} -{{- printf "\n" }} -{{- printf "\n"}} +{{- printf "\n" }} +{{- printf "\n"}} {{- range $index, $secret := (lookup "v1" "Secret" .Release.Namespace "").items }} {{- if (index $secret "metadata" "annotations") }} {{- if and (index $secret "metadata" "annotations" "onyxia/discovery") (eq "hive" (index $secret "metadata" "annotations" "onyxia/discovery" | toString)) }} @@ -422,7 +422,6 @@ Flag to disable certificate checking for Spark {{- end }} {{- end }} - {{/* Template to generate a Secret for SparkConf */}} {{- define "library-chart.secretSparkConf" -}} {{- if .Values.spark.default -}} @@ -473,3 +472,27 @@ stringData: {{- end }} {{- end }} {{- end }} + + + +{{/* Name of the extraEnv secret */}} +{{- define "library-chart.secretNameExtraEnv" -}} +{{- printf "%s-secretextraenv" (include "library-chart.fullname" .) }} +{{- end }} + +{{/* Template to generate a secret for extra environment variables */}} +{{- define "library-chart.secretExtraEnv" -}} +{{- if .Values.extraEnvVars }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "library-chart.secretNameExtraEnv" . }} + labels: + {{- include "library-chart.labels" . | nindent 4 }} +type: Opaque +stringData: + {{- range .Values.extraEnvVars }} + {{ .name | trim }}: {{ tpl .value $.Values | quote }} + {{- end }} +{{- end }} +{{- end }} diff --git a/charts/vscode-python/templates/statefulset.yaml b/charts/vscode-python/templates/statefulset.yaml index e6017523..2213a404 100644 --- a/charts/vscode-python/templates/statefulset.yaml +++ b/charts/vscode-python/templates/statefulset.yaml @@ -177,10 +177,6 @@ spec: - name: DARK_MODE value: "true" {{- end }} - {{- range .Values.extraEnvVars }} - - name: {{ .name }} - value: {{ tpl .value $.Values }} - {{- end }} envFrom: - secretRef: name : {{ include "library-chart.secretNameToken" . }} @@ -208,6 +204,10 @@ spec: - secretRef: name: {{ include "library-chart.secretNameMLFlow" . }} {{- end }} + {{- if .Values.extraEnvVars }} + - secretRef: + name: {{ include "library-chart.secretNameExtraEnv" . }} + {{- end }} livenessProbe: httpGet: path: /