From 26cd36eb1f7cd965fc942ae43a780b7b9346123e Mon Sep 17 00:00:00 2001 From: Philipp Bandow Date: Tue, 7 Feb 2023 13:08:55 +0100 Subject: [PATCH] Add options to pass addition environment variables * directly via `extraEnv` * indirectly via `extraEnvCM` or `extraEnvSecret` Add option to use existing secrets for * postgresql * mq password --- templates/netmaker-statefulset.yaml | 28 ++++++++++++++++++++++++++++ values.yaml | 20 ++++++++++++++++++-- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/templates/netmaker-statefulset.yaml b/templates/netmaker-statefulset.yaml index caddbf0..cf9c9e3 100644 --- a/templates/netmaker-statefulset.yaml +++ b/templates/netmaker-statefulset.yaml @@ -81,7 +81,14 @@ spec: - name: SQL_USER value: {{ index .Values "postgresql-ha" "postgresql" "username" }} - name: SQL_PASS + {{- if index .Values "postgresql-ha" "postgresql" "existingSecret" }} + valueFrom: + secretKeyRef: + name: {{ index .Values "postgresql-ha" "postgresql" "existingSecret" }} + key: password + {{- else }} value: {{ index .Values "postgresql-ha" "postgresql" "password" }} + {{- end }} - name: DATABASE value: postgres - name: DISPLAY_KEYS @@ -93,11 +100,32 @@ spec: - name: MQ_SERVER_PORT value: "1883" - name: MQ_ADMIN_PASSWORD + {{- if or (index .Values "mq" "existingSecretName") (index .Values "mq" "existingSecretKey") }} + valueFrom: + secretKeyRef: + name: {{ index .Values "mq" "existingSecretName" }} + key: {{ index .Values "mq" "existingSecretKey" }} + {{- else }} value: {{ .Values.mq.password }} + {{- end }} - name: PLATFORM value: "Kubernetes" - name: VERBOSITY value: "3" + {{- if .Values.extraEnv }} + {{- tpl (.Values.extraEnv | toYaml) . | nindent 8 }} + {{- end }} + {{- if or .Values.extraEnvCM .Values.extraEnvSecret }} + envFrom: + {{- if .Values.extraEnvCM }} + - configMapRef: + name: {{ .Values.extraEnvCM }} + {{- end }} + {{- if .Values.extraEnvSecret }} + - secretRef: + name: {{ .Values.extraEnvSecret }} + {{- end }} + {{- end }} image: {{ .Values.image.repository }}:{{ .Values.image.tag }} imagePullPolicy: {{ .Values.image.pullPolicy }} name: {{ include "netmaker.fullname" . }} diff --git a/values.yaml b/values.yaml index 892a38a..e0cf1ac 100644 --- a/values.yaml +++ b/values.yaml @@ -34,6 +34,15 @@ podAnnotations: {} podSecurityContext: {} # fsGroup: 2000 +# -- extra environment variables from a config map +# extraEnvCM: "configmap-name" +# -- extra environment variables from a secret +# extraEnvSecret: "secret-name" +## -- extra environment variables, passed through helm tpl +# extraEnv: +# - name: TEST_VARIABLE +# value: "TEST_VALUE" + ui: # -- how many UI replicas to create replicas: 2 @@ -44,6 +53,10 @@ mq: singlenode: false storageSize: 128Mi password: 3yyerWGdds43yegGR + # -- specify a secret containing the mq password + # existingSecretName: "" + # -- key in the existing secret that contains the password for mq + # existingSecretKey: "" RWX: storageClassName: "" @@ -121,10 +134,13 @@ postgresql-ha: username: netmaker # -- postgres pass to generate password: netmaker - # -- postgress db to generate + # -- postgres db to generate database: netmaker - # -- postgress number of replicas to deploy + # -- postgres number of replicas to deploy replicaCount: 2 + # -- postgres use existing secret for passwords + # -- secret must contain values for keys postgres-password, password and repmgr-password + # existingSecret: "" persistence: # -- size of postgres DB size: 1Gi