From 51526293d106f84a6353fc3f5029e25e3822c163 Mon Sep 17 00:00:00 2001 From: Amey Karandikar Date: Thu, 22 Feb 2024 16:35:45 -0500 Subject: [PATCH 1/2] added initial support for init container --- charts/accessnode/templates/_cv.tpl | 46 +++++++++++++++++++++ charts/accessnode/templates/deploy.yaml | 3 ++ charts/commandcenter/templates/_cv.tpl | 46 +++++++++++++++++++++ charts/commandcenter/templates/deploy.yaml | 3 ++ charts/config/templates/_cv.tpl | 46 +++++++++++++++++++++ charts/cs/templates/_cv.tpl | 46 +++++++++++++++++++++ charts/cs/templates/deploy.yaml | 3 ++ charts/mediaagent/templates/_cv.tpl | 46 +++++++++++++++++++++ charts/mediaagent/templates/deploy.yaml | 3 ++ charts/networkgateway/templates/_cv.tpl | 46 +++++++++++++++++++++ charts/networkgateway/templates/deploy.yaml | 3 ++ charts/webserver/templates/_cv.tpl | 46 +++++++++++++++++++++ charts/webserver/templates/deploy.yaml | 3 ++ 13 files changed, 340 insertions(+) diff --git a/charts/accessnode/templates/_cv.tpl b/charts/accessnode/templates/_cv.tpl index 7f94a84..7c19fdb 100644 --- a/charts/accessnode/templates/_cv.tpl +++ b/charts/accessnode/templates/_cv.tpl @@ -144,6 +144,18 @@ Values in defaults.yaml gets the last priority {{- end -}} {{ end }} + +{{- define "cv.useInitContainer" }} +{{- $defaults := (fromYaml (.Files.Get "defaults.yaml")) }} +{{- $initContainer := false }} +{{- if eq (include "cv.utils.isMinVersion" (list . 11 40)) "true" }} +{{- $initContainer = true }} +{{- end }} +{{- $initContainer = ternary $defaults.initContainer $initContainer (hasKey $defaults "initContainer") }} +{{- $initContainer = ternary .Values.initContainer $initContainer (hasKey .Values "initContainer") }} +{{- $initContainer | toString }} +{{- end }} + {{/* cv.commonenv creates environment variables that are common to all deployments */}} @@ -189,6 +201,7 @@ cv.commonenv creates environment variables that are common to all deployments - name: CV_CSHOSTNAME value: {{ .Values.csOrGatewayHostName }} {{- end }} + {{- if eq (include "cv.useInitContainer" .) "false" }} {{- if ((.Values).secret).user }} - name: CV_COMMCELL_USER value: {{ .Values.secret.user }} @@ -201,6 +214,7 @@ cv.commonenv creates environment variables that are common to all deployments - name: CV_CSAUTH_CODE value: {{ .Values.secret.authcode }} {{- end }} + {{- end }} {{- if .Values.pause }} - name: CV_PAUSE value: 'true' @@ -248,3 +262,35 @@ cv.commondeploymentpecs creates pod specifications that are common to all deploy revisionHistoryLimit: 0 {{- end -}} + +{{- define "cv.initContainer" }} +{{- $objectname := include "cv.metadataname" . }} +{{- if eq (include "cv.useInitContainer" .) "true" }} + initContainers: + - name: {{ $objectname }}-init + image: {{ include "cv.image" . }} + command: ["/bin/sh", "-c"] + args: + - echo -e "CV_COMMCELL_USER=$(echo ${CV_COMMCELL_USER})\nCV_COMMCELL_PWD=$(echo ${CV_COMMCELL_PWD})\nCV_CSAUTH_CODE=$(echo ${CV_CSAUTH_CODE})" > /tmp/artifact/creds.txt + env: + {{- if ((.Values).secret).user }} + - name: CV_COMMCELL_USER + value: {{ .Values.secret.user }} + {{- end }} + {{- if ((.Values).secret).password }} + - name: CV_COMMCELL_PWD + value: {{ .Values.secret.password }} + {{- end }} + {{- if ((.Values).secret).authcode }} + - name: CV_CSAUTH_CODE + value: {{ .Values.secret.authcode }} + {{- end }} + envFrom: + - secretRef: + name: {{ include "cv.metadataname2" (list . "cvcreds") }} + optional: true + volumeMounts: + - name: tmp + mountPath: /tmp/artifact +{{- end }} +{{- end }} diff --git a/charts/accessnode/templates/deploy.yaml b/charts/accessnode/templates/deploy.yaml index da2aef2..5b6b837 100644 --- a/charts/accessnode/templates/deploy.yaml +++ b/charts/accessnode/templates/deploy.yaml @@ -21,6 +21,7 @@ spec: spec: {{- include "cv.imagePullSecret" . }} {{- include "cv.additionalPodspecs" . }} + {{- include "cv.initContainer" . }} containers: # access node - name: {{ $objectname }} @@ -30,9 +31,11 @@ spec: - configMapRef: name: {{ include "cv.metadataname2" (list . "cvconfig") }} optional: true + {{- if eq (include "cv.useInitContainer" .) "false" }} - secretRef: name: {{ include "cv.metadataname2" (list . "cvcreds") }} optional: true + {{- end }} env: {{- include "cv.commonenv" . }} # ports can be left default diff --git a/charts/commandcenter/templates/_cv.tpl b/charts/commandcenter/templates/_cv.tpl index 7f94a84..7c19fdb 100644 --- a/charts/commandcenter/templates/_cv.tpl +++ b/charts/commandcenter/templates/_cv.tpl @@ -144,6 +144,18 @@ Values in defaults.yaml gets the last priority {{- end -}} {{ end }} + +{{- define "cv.useInitContainer" }} +{{- $defaults := (fromYaml (.Files.Get "defaults.yaml")) }} +{{- $initContainer := false }} +{{- if eq (include "cv.utils.isMinVersion" (list . 11 40)) "true" }} +{{- $initContainer = true }} +{{- end }} +{{- $initContainer = ternary $defaults.initContainer $initContainer (hasKey $defaults "initContainer") }} +{{- $initContainer = ternary .Values.initContainer $initContainer (hasKey .Values "initContainer") }} +{{- $initContainer | toString }} +{{- end }} + {{/* cv.commonenv creates environment variables that are common to all deployments */}} @@ -189,6 +201,7 @@ cv.commonenv creates environment variables that are common to all deployments - name: CV_CSHOSTNAME value: {{ .Values.csOrGatewayHostName }} {{- end }} + {{- if eq (include "cv.useInitContainer" .) "false" }} {{- if ((.Values).secret).user }} - name: CV_COMMCELL_USER value: {{ .Values.secret.user }} @@ -201,6 +214,7 @@ cv.commonenv creates environment variables that are common to all deployments - name: CV_CSAUTH_CODE value: {{ .Values.secret.authcode }} {{- end }} + {{- end }} {{- if .Values.pause }} - name: CV_PAUSE value: 'true' @@ -248,3 +262,35 @@ cv.commondeploymentpecs creates pod specifications that are common to all deploy revisionHistoryLimit: 0 {{- end -}} + +{{- define "cv.initContainer" }} +{{- $objectname := include "cv.metadataname" . }} +{{- if eq (include "cv.useInitContainer" .) "true" }} + initContainers: + - name: {{ $objectname }}-init + image: {{ include "cv.image" . }} + command: ["/bin/sh", "-c"] + args: + - echo -e "CV_COMMCELL_USER=$(echo ${CV_COMMCELL_USER})\nCV_COMMCELL_PWD=$(echo ${CV_COMMCELL_PWD})\nCV_CSAUTH_CODE=$(echo ${CV_CSAUTH_CODE})" > /tmp/artifact/creds.txt + env: + {{- if ((.Values).secret).user }} + - name: CV_COMMCELL_USER + value: {{ .Values.secret.user }} + {{- end }} + {{- if ((.Values).secret).password }} + - name: CV_COMMCELL_PWD + value: {{ .Values.secret.password }} + {{- end }} + {{- if ((.Values).secret).authcode }} + - name: CV_CSAUTH_CODE + value: {{ .Values.secret.authcode }} + {{- end }} + envFrom: + - secretRef: + name: {{ include "cv.metadataname2" (list . "cvcreds") }} + optional: true + volumeMounts: + - name: tmp + mountPath: /tmp/artifact +{{- end }} +{{- end }} diff --git a/charts/commandcenter/templates/deploy.yaml b/charts/commandcenter/templates/deploy.yaml index c08b3f0..2911582 100644 --- a/charts/commandcenter/templates/deploy.yaml +++ b/charts/commandcenter/templates/deploy.yaml @@ -21,6 +21,7 @@ spec: spec: {{- include "cv.imagePullSecret" . }} {{- include "cv.additionalPodspecs" . }} + {{- include "cv.initContainer" . }} containers: # Command center - name: {{ $objectname }} @@ -30,9 +31,11 @@ spec: - configMapRef: name: {{ include "cv.metadataname2" (list . "cvconfig") }} optional: true + {{- if eq (include "cv.useInitContainer" .) "false" }} - secretRef: name: {{ include "cv.metadataname2" (list . "cvcreds") }} optional: true + {{- end }} env: {{- include "cv.commonenv" . }} - name: CV_WS_CLIENT_NAME diff --git a/charts/config/templates/_cv.tpl b/charts/config/templates/_cv.tpl index 7f94a84..7c19fdb 100644 --- a/charts/config/templates/_cv.tpl +++ b/charts/config/templates/_cv.tpl @@ -144,6 +144,18 @@ Values in defaults.yaml gets the last priority {{- end -}} {{ end }} + +{{- define "cv.useInitContainer" }} +{{- $defaults := (fromYaml (.Files.Get "defaults.yaml")) }} +{{- $initContainer := false }} +{{- if eq (include "cv.utils.isMinVersion" (list . 11 40)) "true" }} +{{- $initContainer = true }} +{{- end }} +{{- $initContainer = ternary $defaults.initContainer $initContainer (hasKey $defaults "initContainer") }} +{{- $initContainer = ternary .Values.initContainer $initContainer (hasKey .Values "initContainer") }} +{{- $initContainer | toString }} +{{- end }} + {{/* cv.commonenv creates environment variables that are common to all deployments */}} @@ -189,6 +201,7 @@ cv.commonenv creates environment variables that are common to all deployments - name: CV_CSHOSTNAME value: {{ .Values.csOrGatewayHostName }} {{- end }} + {{- if eq (include "cv.useInitContainer" .) "false" }} {{- if ((.Values).secret).user }} - name: CV_COMMCELL_USER value: {{ .Values.secret.user }} @@ -201,6 +214,7 @@ cv.commonenv creates environment variables that are common to all deployments - name: CV_CSAUTH_CODE value: {{ .Values.secret.authcode }} {{- end }} + {{- end }} {{- if .Values.pause }} - name: CV_PAUSE value: 'true' @@ -248,3 +262,35 @@ cv.commondeploymentpecs creates pod specifications that are common to all deploy revisionHistoryLimit: 0 {{- end -}} + +{{- define "cv.initContainer" }} +{{- $objectname := include "cv.metadataname" . }} +{{- if eq (include "cv.useInitContainer" .) "true" }} + initContainers: + - name: {{ $objectname }}-init + image: {{ include "cv.image" . }} + command: ["/bin/sh", "-c"] + args: + - echo -e "CV_COMMCELL_USER=$(echo ${CV_COMMCELL_USER})\nCV_COMMCELL_PWD=$(echo ${CV_COMMCELL_PWD})\nCV_CSAUTH_CODE=$(echo ${CV_CSAUTH_CODE})" > /tmp/artifact/creds.txt + env: + {{- if ((.Values).secret).user }} + - name: CV_COMMCELL_USER + value: {{ .Values.secret.user }} + {{- end }} + {{- if ((.Values).secret).password }} + - name: CV_COMMCELL_PWD + value: {{ .Values.secret.password }} + {{- end }} + {{- if ((.Values).secret).authcode }} + - name: CV_CSAUTH_CODE + value: {{ .Values.secret.authcode }} + {{- end }} + envFrom: + - secretRef: + name: {{ include "cv.metadataname2" (list . "cvcreds") }} + optional: true + volumeMounts: + - name: tmp + mountPath: /tmp/artifact +{{- end }} +{{- end }} diff --git a/charts/cs/templates/_cv.tpl b/charts/cs/templates/_cv.tpl index 7f94a84..7c19fdb 100644 --- a/charts/cs/templates/_cv.tpl +++ b/charts/cs/templates/_cv.tpl @@ -144,6 +144,18 @@ Values in defaults.yaml gets the last priority {{- end -}} {{ end }} + +{{- define "cv.useInitContainer" }} +{{- $defaults := (fromYaml (.Files.Get "defaults.yaml")) }} +{{- $initContainer := false }} +{{- if eq (include "cv.utils.isMinVersion" (list . 11 40)) "true" }} +{{- $initContainer = true }} +{{- end }} +{{- $initContainer = ternary $defaults.initContainer $initContainer (hasKey $defaults "initContainer") }} +{{- $initContainer = ternary .Values.initContainer $initContainer (hasKey .Values "initContainer") }} +{{- $initContainer | toString }} +{{- end }} + {{/* cv.commonenv creates environment variables that are common to all deployments */}} @@ -189,6 +201,7 @@ cv.commonenv creates environment variables that are common to all deployments - name: CV_CSHOSTNAME value: {{ .Values.csOrGatewayHostName }} {{- end }} + {{- if eq (include "cv.useInitContainer" .) "false" }} {{- if ((.Values).secret).user }} - name: CV_COMMCELL_USER value: {{ .Values.secret.user }} @@ -201,6 +214,7 @@ cv.commonenv creates environment variables that are common to all deployments - name: CV_CSAUTH_CODE value: {{ .Values.secret.authcode }} {{- end }} + {{- end }} {{- if .Values.pause }} - name: CV_PAUSE value: 'true' @@ -248,3 +262,35 @@ cv.commondeploymentpecs creates pod specifications that are common to all deploy revisionHistoryLimit: 0 {{- end -}} + +{{- define "cv.initContainer" }} +{{- $objectname := include "cv.metadataname" . }} +{{- if eq (include "cv.useInitContainer" .) "true" }} + initContainers: + - name: {{ $objectname }}-init + image: {{ include "cv.image" . }} + command: ["/bin/sh", "-c"] + args: + - echo -e "CV_COMMCELL_USER=$(echo ${CV_COMMCELL_USER})\nCV_COMMCELL_PWD=$(echo ${CV_COMMCELL_PWD})\nCV_CSAUTH_CODE=$(echo ${CV_CSAUTH_CODE})" > /tmp/artifact/creds.txt + env: + {{- if ((.Values).secret).user }} + - name: CV_COMMCELL_USER + value: {{ .Values.secret.user }} + {{- end }} + {{- if ((.Values).secret).password }} + - name: CV_COMMCELL_PWD + value: {{ .Values.secret.password }} + {{- end }} + {{- if ((.Values).secret).authcode }} + - name: CV_CSAUTH_CODE + value: {{ .Values.secret.authcode }} + {{- end }} + envFrom: + - secretRef: + name: {{ include "cv.metadataname2" (list . "cvcreds") }} + optional: true + volumeMounts: + - name: tmp + mountPath: /tmp/artifact +{{- end }} +{{- end }} diff --git a/charts/cs/templates/deploy.yaml b/charts/cs/templates/deploy.yaml index 03e5960..e4e2388 100644 --- a/charts/cs/templates/deploy.yaml +++ b/charts/cs/templates/deploy.yaml @@ -21,15 +21,18 @@ spec: spec: {{- include "cv.imagePullSecret" . }} {{- include "cv.additionalPodspecs" . }} + {{- include "cv.initContainer" . }} containers: # Commserve - name: {{ $objectname }} image: {{ include "cv.image" . }} {{- include "cv.resources" . }} envFrom: + {{- if eq (include "cv.useInitContainer" .) "false" }} - secretRef: name: {{ include "cv.metadataname2" (list . "cvcreds") }} optional: true + {{- end }} env: {{- include "cv.commonenv" . }} {{- if .Values.email }} diff --git a/charts/mediaagent/templates/_cv.tpl b/charts/mediaagent/templates/_cv.tpl index 7f94a84..7c19fdb 100644 --- a/charts/mediaagent/templates/_cv.tpl +++ b/charts/mediaagent/templates/_cv.tpl @@ -144,6 +144,18 @@ Values in defaults.yaml gets the last priority {{- end -}} {{ end }} + +{{- define "cv.useInitContainer" }} +{{- $defaults := (fromYaml (.Files.Get "defaults.yaml")) }} +{{- $initContainer := false }} +{{- if eq (include "cv.utils.isMinVersion" (list . 11 40)) "true" }} +{{- $initContainer = true }} +{{- end }} +{{- $initContainer = ternary $defaults.initContainer $initContainer (hasKey $defaults "initContainer") }} +{{- $initContainer = ternary .Values.initContainer $initContainer (hasKey .Values "initContainer") }} +{{- $initContainer | toString }} +{{- end }} + {{/* cv.commonenv creates environment variables that are common to all deployments */}} @@ -189,6 +201,7 @@ cv.commonenv creates environment variables that are common to all deployments - name: CV_CSHOSTNAME value: {{ .Values.csOrGatewayHostName }} {{- end }} + {{- if eq (include "cv.useInitContainer" .) "false" }} {{- if ((.Values).secret).user }} - name: CV_COMMCELL_USER value: {{ .Values.secret.user }} @@ -201,6 +214,7 @@ cv.commonenv creates environment variables that are common to all deployments - name: CV_CSAUTH_CODE value: {{ .Values.secret.authcode }} {{- end }} + {{- end }} {{- if .Values.pause }} - name: CV_PAUSE value: 'true' @@ -248,3 +262,35 @@ cv.commondeploymentpecs creates pod specifications that are common to all deploy revisionHistoryLimit: 0 {{- end -}} + +{{- define "cv.initContainer" }} +{{- $objectname := include "cv.metadataname" . }} +{{- if eq (include "cv.useInitContainer" .) "true" }} + initContainers: + - name: {{ $objectname }}-init + image: {{ include "cv.image" . }} + command: ["/bin/sh", "-c"] + args: + - echo -e "CV_COMMCELL_USER=$(echo ${CV_COMMCELL_USER})\nCV_COMMCELL_PWD=$(echo ${CV_COMMCELL_PWD})\nCV_CSAUTH_CODE=$(echo ${CV_CSAUTH_CODE})" > /tmp/artifact/creds.txt + env: + {{- if ((.Values).secret).user }} + - name: CV_COMMCELL_USER + value: {{ .Values.secret.user }} + {{- end }} + {{- if ((.Values).secret).password }} + - name: CV_COMMCELL_PWD + value: {{ .Values.secret.password }} + {{- end }} + {{- if ((.Values).secret).authcode }} + - name: CV_CSAUTH_CODE + value: {{ .Values.secret.authcode }} + {{- end }} + envFrom: + - secretRef: + name: {{ include "cv.metadataname2" (list . "cvcreds") }} + optional: true + volumeMounts: + - name: tmp + mountPath: /tmp/artifact +{{- end }} +{{- end }} diff --git a/charts/mediaagent/templates/deploy.yaml b/charts/mediaagent/templates/deploy.yaml index dd2e87a..d872908 100644 --- a/charts/mediaagent/templates/deploy.yaml +++ b/charts/mediaagent/templates/deploy.yaml @@ -21,6 +21,7 @@ spec: spec: {{- include "cv.imagePullSecret" . }} {{- include "cv.additionalPodspecs" . }} + {{- include "cv.initContainer" . }} containers: # Mediaagent - name: {{ $objectname }} @@ -30,9 +31,11 @@ spec: - configMapRef: name: {{ include "cv.metadataname2" (list . "cvconfig") }} optional: true + {{- if eq (include "cv.useInitContainer" .) "false" }} - secretRef: name: {{ include "cv.metadataname2" (list . "cvcreds") }} optional: true + {{- end }} env: {{- include "cv.commonenv" . }} # ports can be left default diff --git a/charts/networkgateway/templates/_cv.tpl b/charts/networkgateway/templates/_cv.tpl index 7f94a84..7c19fdb 100644 --- a/charts/networkgateway/templates/_cv.tpl +++ b/charts/networkgateway/templates/_cv.tpl @@ -144,6 +144,18 @@ Values in defaults.yaml gets the last priority {{- end -}} {{ end }} + +{{- define "cv.useInitContainer" }} +{{- $defaults := (fromYaml (.Files.Get "defaults.yaml")) }} +{{- $initContainer := false }} +{{- if eq (include "cv.utils.isMinVersion" (list . 11 40)) "true" }} +{{- $initContainer = true }} +{{- end }} +{{- $initContainer = ternary $defaults.initContainer $initContainer (hasKey $defaults "initContainer") }} +{{- $initContainer = ternary .Values.initContainer $initContainer (hasKey .Values "initContainer") }} +{{- $initContainer | toString }} +{{- end }} + {{/* cv.commonenv creates environment variables that are common to all deployments */}} @@ -189,6 +201,7 @@ cv.commonenv creates environment variables that are common to all deployments - name: CV_CSHOSTNAME value: {{ .Values.csOrGatewayHostName }} {{- end }} + {{- if eq (include "cv.useInitContainer" .) "false" }} {{- if ((.Values).secret).user }} - name: CV_COMMCELL_USER value: {{ .Values.secret.user }} @@ -201,6 +214,7 @@ cv.commonenv creates environment variables that are common to all deployments - name: CV_CSAUTH_CODE value: {{ .Values.secret.authcode }} {{- end }} + {{- end }} {{- if .Values.pause }} - name: CV_PAUSE value: 'true' @@ -248,3 +262,35 @@ cv.commondeploymentpecs creates pod specifications that are common to all deploy revisionHistoryLimit: 0 {{- end -}} + +{{- define "cv.initContainer" }} +{{- $objectname := include "cv.metadataname" . }} +{{- if eq (include "cv.useInitContainer" .) "true" }} + initContainers: + - name: {{ $objectname }}-init + image: {{ include "cv.image" . }} + command: ["/bin/sh", "-c"] + args: + - echo -e "CV_COMMCELL_USER=$(echo ${CV_COMMCELL_USER})\nCV_COMMCELL_PWD=$(echo ${CV_COMMCELL_PWD})\nCV_CSAUTH_CODE=$(echo ${CV_CSAUTH_CODE})" > /tmp/artifact/creds.txt + env: + {{- if ((.Values).secret).user }} + - name: CV_COMMCELL_USER + value: {{ .Values.secret.user }} + {{- end }} + {{- if ((.Values).secret).password }} + - name: CV_COMMCELL_PWD + value: {{ .Values.secret.password }} + {{- end }} + {{- if ((.Values).secret).authcode }} + - name: CV_CSAUTH_CODE + value: {{ .Values.secret.authcode }} + {{- end }} + envFrom: + - secretRef: + name: {{ include "cv.metadataname2" (list . "cvcreds") }} + optional: true + volumeMounts: + - name: tmp + mountPath: /tmp/artifact +{{- end }} +{{- end }} diff --git a/charts/networkgateway/templates/deploy.yaml b/charts/networkgateway/templates/deploy.yaml index 95f678b..5b1898c 100644 --- a/charts/networkgateway/templates/deploy.yaml +++ b/charts/networkgateway/templates/deploy.yaml @@ -21,6 +21,7 @@ spec: spec: {{- include "cv.imagePullSecret" . }} {{- include "cv.additionalPodspecs" . }} + {{- include "cv.initContainer" . }} containers: # networkgateway - name: {{ $objectname }} @@ -30,9 +31,11 @@ spec: - configMapRef: name: {{ include "cv.metadataname2" (list . "cvconfig") }} optional: true + {{- if eq (include "cv.useInitContainer" .) "false" }} - secretRef: name: {{ include "cv.metadataname2" (list . "cvcreds") }} optional: true + {{- end }} env: {{- include "cv.commonenv" . }} # ports can be left default diff --git a/charts/webserver/templates/_cv.tpl b/charts/webserver/templates/_cv.tpl index 7f94a84..7c19fdb 100644 --- a/charts/webserver/templates/_cv.tpl +++ b/charts/webserver/templates/_cv.tpl @@ -144,6 +144,18 @@ Values in defaults.yaml gets the last priority {{- end -}} {{ end }} + +{{- define "cv.useInitContainer" }} +{{- $defaults := (fromYaml (.Files.Get "defaults.yaml")) }} +{{- $initContainer := false }} +{{- if eq (include "cv.utils.isMinVersion" (list . 11 40)) "true" }} +{{- $initContainer = true }} +{{- end }} +{{- $initContainer = ternary $defaults.initContainer $initContainer (hasKey $defaults "initContainer") }} +{{- $initContainer = ternary .Values.initContainer $initContainer (hasKey .Values "initContainer") }} +{{- $initContainer | toString }} +{{- end }} + {{/* cv.commonenv creates environment variables that are common to all deployments */}} @@ -189,6 +201,7 @@ cv.commonenv creates environment variables that are common to all deployments - name: CV_CSHOSTNAME value: {{ .Values.csOrGatewayHostName }} {{- end }} + {{- if eq (include "cv.useInitContainer" .) "false" }} {{- if ((.Values).secret).user }} - name: CV_COMMCELL_USER value: {{ .Values.secret.user }} @@ -201,6 +214,7 @@ cv.commonenv creates environment variables that are common to all deployments - name: CV_CSAUTH_CODE value: {{ .Values.secret.authcode }} {{- end }} + {{- end }} {{- if .Values.pause }} - name: CV_PAUSE value: 'true' @@ -248,3 +262,35 @@ cv.commondeploymentpecs creates pod specifications that are common to all deploy revisionHistoryLimit: 0 {{- end -}} + +{{- define "cv.initContainer" }} +{{- $objectname := include "cv.metadataname" . }} +{{- if eq (include "cv.useInitContainer" .) "true" }} + initContainers: + - name: {{ $objectname }}-init + image: {{ include "cv.image" . }} + command: ["/bin/sh", "-c"] + args: + - echo -e "CV_COMMCELL_USER=$(echo ${CV_COMMCELL_USER})\nCV_COMMCELL_PWD=$(echo ${CV_COMMCELL_PWD})\nCV_CSAUTH_CODE=$(echo ${CV_CSAUTH_CODE})" > /tmp/artifact/creds.txt + env: + {{- if ((.Values).secret).user }} + - name: CV_COMMCELL_USER + value: {{ .Values.secret.user }} + {{- end }} + {{- if ((.Values).secret).password }} + - name: CV_COMMCELL_PWD + value: {{ .Values.secret.password }} + {{- end }} + {{- if ((.Values).secret).authcode }} + - name: CV_CSAUTH_CODE + value: {{ .Values.secret.authcode }} + {{- end }} + envFrom: + - secretRef: + name: {{ include "cv.metadataname2" (list . "cvcreds") }} + optional: true + volumeMounts: + - name: tmp + mountPath: /tmp/artifact +{{- end }} +{{- end }} diff --git a/charts/webserver/templates/deploy.yaml b/charts/webserver/templates/deploy.yaml index e8c2146..6265454 100644 --- a/charts/webserver/templates/deploy.yaml +++ b/charts/webserver/templates/deploy.yaml @@ -21,6 +21,7 @@ spec: spec: {{- include "cv.imagePullSecret" . }} {{- include "cv.additionalPodspecs" . }} + {{- include "cv.initContainer" . }} containers: # Webserver - name: {{ $objectname }} @@ -30,9 +31,11 @@ spec: - configMapRef: name: {{ include "cv.metadataname2" (list . "cvconfig") }} optional: true + {{- if eq (include "cv.useInitContainer" .) "false" }} - secretRef: name: {{ include "cv.metadataname2" (list . "cvcreds") }} optional: true + {{- end }} env: {{- include "cv.commonenv" . }} # ports can be left default From 336aea21afb529bd50bfb4a49ae4c34747eb4e49 Mon Sep 17 00:00:00 2001 From: Amey Karandikar Date: Wed, 6 Mar 2024 12:26:14 -0500 Subject: [PATCH 2/2] added support for additionalContainerSpec --- charts/accessnode/templates/_cv.tpl | 15 +++++++++++++++ charts/accessnode/templates/deploy.yaml | 1 + charts/accessnode/values.yaml | 10 ++++++++++ charts/commandcenter/templates/_cv.tpl | 15 +++++++++++++++ charts/commandcenter/templates/deploy.yaml | 1 + charts/commandcenter/values.yaml | 10 ++++++++++ charts/config/templates/_cv.tpl | 15 +++++++++++++++ charts/cs/templates/_cv.tpl | 15 +++++++++++++++ charts/cs/templates/deploy.yaml | 1 + charts/cs/values.yaml | 10 ++++++++++ charts/mediaagent/templates/_cv.tpl | 15 +++++++++++++++ charts/mediaagent/templates/deploy.yaml | 1 + charts/mediaagent/values.yaml | 10 ++++++++++ charts/networkgateway/templates/_cv.tpl | 15 +++++++++++++++ charts/networkgateway/templates/deploy.yaml | 1 + charts/networkgateway/values.yaml | 10 ++++++++++ charts/webserver/templates/_cv.tpl | 15 +++++++++++++++ charts/webserver/templates/deploy.yaml | 1 + charts/webserver/values.yaml | 10 ++++++++++ 19 files changed, 171 insertions(+) diff --git a/charts/accessnode/templates/_cv.tpl b/charts/accessnode/templates/_cv.tpl index 7c19fdb..10bf142 100644 --- a/charts/accessnode/templates/_cv.tpl +++ b/charts/accessnode/templates/_cv.tpl @@ -106,6 +106,21 @@ Values in defaults.yaml gets the last priority {{- end -}} {{- end }} +{{/* +cv.additionalContainerspecs is a function that allows the user to specify additional container specifications that are not mentioned in the deployment templates +Use "additionalContainerspecs" as the section name to enter the additional pod specifications. pod specifications can be specified at both global and local values +and will be merged to provide a single set of additional container specifications that will be added to the final deployment +There is also a provision to have chart level defaults which can be specified by having a defaults.yaml in chart directory. +Values in defaults.yaml gets the last priority +*/}} +{{- define "cv.additionalContainerspecs" }} +{{- $defaults := (fromYaml (.Files.Get "defaults.yaml")) }} +{{- if or (.Values.global).additionalContainerspecs .Values.additionalContainerspecs $defaults.additionalContainerspecs }} +{{- $combinedYaml := fromYaml ((include "cv.utils.getCombinedYaml" (list (.Values.global).additionalContainerspecs $defaults.additionalContainerspecs $ 8 false ))) }} +{{- include "cv.utils.getCombinedYaml" (list .Values.additionalContainerspecs $combinedYaml $ 8 false ) }} +{{- end -}} +{{- end }} + {{/* cv.commonContainerSpecs adds container specifications that are common for all commvault images */}} diff --git a/charts/accessnode/templates/deploy.yaml b/charts/accessnode/templates/deploy.yaml index 5b6b837..3781b98 100644 --- a/charts/accessnode/templates/deploy.yaml +++ b/charts/accessnode/templates/deploy.yaml @@ -27,6 +27,7 @@ spec: - name: {{ $objectname }} image: {{ include "cv.image" . }} {{- include "cv.resources" . }} + {{- include "cv.additionalContainerspecs" . }} envFrom: - configMapRef: name: {{ include "cv.metadataname2" (list . "cvconfig") }} diff --git a/charts/accessnode/values.yaml b/charts/accessnode/values.yaml index 737fab5..32051a8 100644 --- a/charts/accessnode/values.yaml +++ b/charts/accessnode/values.yaml @@ -30,6 +30,11 @@ # nodeSelector: # disktype: ssd +# Optional. Use this to add additional values to the container specifications. These will merge and override any global additionalContainerspecs +#Example: +#additionalContainerspecs: +# imagePullPolicy: Always + # Optional. Deployment requests and limits. Enable only those values that need to be set. This also overrides any global values #resources: # requests: @@ -76,6 +81,11 @@ # nodeSelector: # disktype: ssd + # Optional. Use this to add additional values to the container specifications. These will be merged with any local additionalContainerspecs + #Example: + #additionalContainerspecs: + # imagePullPolicy: Always + # Optional. Deployment requests and limits. Enable only those values that need to be set. #resources: # requests: diff --git a/charts/commandcenter/templates/_cv.tpl b/charts/commandcenter/templates/_cv.tpl index 7c19fdb..10bf142 100644 --- a/charts/commandcenter/templates/_cv.tpl +++ b/charts/commandcenter/templates/_cv.tpl @@ -106,6 +106,21 @@ Values in defaults.yaml gets the last priority {{- end -}} {{- end }} +{{/* +cv.additionalContainerspecs is a function that allows the user to specify additional container specifications that are not mentioned in the deployment templates +Use "additionalContainerspecs" as the section name to enter the additional pod specifications. pod specifications can be specified at both global and local values +and will be merged to provide a single set of additional container specifications that will be added to the final deployment +There is also a provision to have chart level defaults which can be specified by having a defaults.yaml in chart directory. +Values in defaults.yaml gets the last priority +*/}} +{{- define "cv.additionalContainerspecs" }} +{{- $defaults := (fromYaml (.Files.Get "defaults.yaml")) }} +{{- if or (.Values.global).additionalContainerspecs .Values.additionalContainerspecs $defaults.additionalContainerspecs }} +{{- $combinedYaml := fromYaml ((include "cv.utils.getCombinedYaml" (list (.Values.global).additionalContainerspecs $defaults.additionalContainerspecs $ 8 false ))) }} +{{- include "cv.utils.getCombinedYaml" (list .Values.additionalContainerspecs $combinedYaml $ 8 false ) }} +{{- end -}} +{{- end }} + {{/* cv.commonContainerSpecs adds container specifications that are common for all commvault images */}} diff --git a/charts/commandcenter/templates/deploy.yaml b/charts/commandcenter/templates/deploy.yaml index 2911582..f69ce63 100644 --- a/charts/commandcenter/templates/deploy.yaml +++ b/charts/commandcenter/templates/deploy.yaml @@ -27,6 +27,7 @@ spec: - name: {{ $objectname }} image: {{ include "cv.image" . }} {{- include "cv.resources" . }} + {{- include "cv.additionalContainerspecs" . }} envFrom: - configMapRef: name: {{ include "cv.metadataname2" (list . "cvconfig") }} diff --git a/charts/commandcenter/values.yaml b/charts/commandcenter/values.yaml index 265ff60..652b0bd 100644 --- a/charts/commandcenter/values.yaml +++ b/charts/commandcenter/values.yaml @@ -34,6 +34,11 @@ # nodeSelector: # disktype: ssd +# Optional. Use this to add additional values to the container specifications. These will merge and override any global additionalContainerspecs +#Example: +#additionalContainerspecs: +# imagePullPolicy: Always + # Optional. Deployment requests and limits. Enable only those values that need to be set. This also overrides any global values #resources: # requests: @@ -79,6 +84,11 @@ # nodeSelector: # disktype: ssd + # Optional. Use this to add additional values to the container specifications. These will be merged with any local additionalContainerspecs + #Example: + #additionalContainerspecs: + # imagePullPolicy: Always + # Optional. Deployment requests and limits. Enable only those values that need to be set. #resources: # requests: diff --git a/charts/config/templates/_cv.tpl b/charts/config/templates/_cv.tpl index 7c19fdb..10bf142 100644 --- a/charts/config/templates/_cv.tpl +++ b/charts/config/templates/_cv.tpl @@ -106,6 +106,21 @@ Values in defaults.yaml gets the last priority {{- end -}} {{- end }} +{{/* +cv.additionalContainerspecs is a function that allows the user to specify additional container specifications that are not mentioned in the deployment templates +Use "additionalContainerspecs" as the section name to enter the additional pod specifications. pod specifications can be specified at both global and local values +and will be merged to provide a single set of additional container specifications that will be added to the final deployment +There is also a provision to have chart level defaults which can be specified by having a defaults.yaml in chart directory. +Values in defaults.yaml gets the last priority +*/}} +{{- define "cv.additionalContainerspecs" }} +{{- $defaults := (fromYaml (.Files.Get "defaults.yaml")) }} +{{- if or (.Values.global).additionalContainerspecs .Values.additionalContainerspecs $defaults.additionalContainerspecs }} +{{- $combinedYaml := fromYaml ((include "cv.utils.getCombinedYaml" (list (.Values.global).additionalContainerspecs $defaults.additionalContainerspecs $ 8 false ))) }} +{{- include "cv.utils.getCombinedYaml" (list .Values.additionalContainerspecs $combinedYaml $ 8 false ) }} +{{- end -}} +{{- end }} + {{/* cv.commonContainerSpecs adds container specifications that are common for all commvault images */}} diff --git a/charts/cs/templates/_cv.tpl b/charts/cs/templates/_cv.tpl index 7c19fdb..10bf142 100644 --- a/charts/cs/templates/_cv.tpl +++ b/charts/cs/templates/_cv.tpl @@ -106,6 +106,21 @@ Values in defaults.yaml gets the last priority {{- end -}} {{- end }} +{{/* +cv.additionalContainerspecs is a function that allows the user to specify additional container specifications that are not mentioned in the deployment templates +Use "additionalContainerspecs" as the section name to enter the additional pod specifications. pod specifications can be specified at both global and local values +and will be merged to provide a single set of additional container specifications that will be added to the final deployment +There is also a provision to have chart level defaults which can be specified by having a defaults.yaml in chart directory. +Values in defaults.yaml gets the last priority +*/}} +{{- define "cv.additionalContainerspecs" }} +{{- $defaults := (fromYaml (.Files.Get "defaults.yaml")) }} +{{- if or (.Values.global).additionalContainerspecs .Values.additionalContainerspecs $defaults.additionalContainerspecs }} +{{- $combinedYaml := fromYaml ((include "cv.utils.getCombinedYaml" (list (.Values.global).additionalContainerspecs $defaults.additionalContainerspecs $ 8 false ))) }} +{{- include "cv.utils.getCombinedYaml" (list .Values.additionalContainerspecs $combinedYaml $ 8 false ) }} +{{- end -}} +{{- end }} + {{/* cv.commonContainerSpecs adds container specifications that are common for all commvault images */}} diff --git a/charts/cs/templates/deploy.yaml b/charts/cs/templates/deploy.yaml index e4e2388..5e00c54 100644 --- a/charts/cs/templates/deploy.yaml +++ b/charts/cs/templates/deploy.yaml @@ -27,6 +27,7 @@ spec: - name: {{ $objectname }} image: {{ include "cv.image" . }} {{- include "cv.resources" . }} + {{- include "cv.additionalContainerspecs" . }} envFrom: {{- if eq (include "cv.useInitContainer" .) "false" }} - secretRef: diff --git a/charts/cs/values.yaml b/charts/cs/values.yaml index eaccad0..4c131c3 100644 --- a/charts/cs/values.yaml +++ b/charts/cs/values.yaml @@ -42,6 +42,11 @@ # nodeSelector: # disktype: ssd +# Optional. Use this to add additional values to the container specifications. These will merge and override any global additionalContainerspecs +#Example: +#additionalContainerspecs: +# imagePullPolicy: Always + # Optional. Deployment requests and limits. Enable only those values that need to be set. This also overrides any global values #resources: # requests: @@ -87,6 +92,11 @@ # nodeSelector: # disktype: ssd + # Optional. Use this to add additional values to the container specifications. These will be merged with any local additionalContainerspecs + #Example: + #additionalContainerspecs: + # imagePullPolicy: Always + # Optional. Deployment requests and limits. Enable only those values that need to be set. #resources: # requests: diff --git a/charts/mediaagent/templates/_cv.tpl b/charts/mediaagent/templates/_cv.tpl index 7c19fdb..10bf142 100644 --- a/charts/mediaagent/templates/_cv.tpl +++ b/charts/mediaagent/templates/_cv.tpl @@ -106,6 +106,21 @@ Values in defaults.yaml gets the last priority {{- end -}} {{- end }} +{{/* +cv.additionalContainerspecs is a function that allows the user to specify additional container specifications that are not mentioned in the deployment templates +Use "additionalContainerspecs" as the section name to enter the additional pod specifications. pod specifications can be specified at both global and local values +and will be merged to provide a single set of additional container specifications that will be added to the final deployment +There is also a provision to have chart level defaults which can be specified by having a defaults.yaml in chart directory. +Values in defaults.yaml gets the last priority +*/}} +{{- define "cv.additionalContainerspecs" }} +{{- $defaults := (fromYaml (.Files.Get "defaults.yaml")) }} +{{- if or (.Values.global).additionalContainerspecs .Values.additionalContainerspecs $defaults.additionalContainerspecs }} +{{- $combinedYaml := fromYaml ((include "cv.utils.getCombinedYaml" (list (.Values.global).additionalContainerspecs $defaults.additionalContainerspecs $ 8 false ))) }} +{{- include "cv.utils.getCombinedYaml" (list .Values.additionalContainerspecs $combinedYaml $ 8 false ) }} +{{- end -}} +{{- end }} + {{/* cv.commonContainerSpecs adds container specifications that are common for all commvault images */}} diff --git a/charts/mediaagent/templates/deploy.yaml b/charts/mediaagent/templates/deploy.yaml index d872908..5042f42 100644 --- a/charts/mediaagent/templates/deploy.yaml +++ b/charts/mediaagent/templates/deploy.yaml @@ -27,6 +27,7 @@ spec: - name: {{ $objectname }} image: {{ include "cv.image" . }} {{- include "cv.resources" . }} + {{- include "cv.additionalContainerspecs" . }} envFrom: - configMapRef: name: {{ include "cv.metadataname2" (list . "cvconfig") }} diff --git a/charts/mediaagent/values.yaml b/charts/mediaagent/values.yaml index fc65d71..0f3149e 100644 --- a/charts/mediaagent/values.yaml +++ b/charts/mediaagent/values.yaml @@ -34,6 +34,11 @@ # nodeSelector: # disktype: ssd +# Optional. Use this to add additional values to the container specifications. These will merge and override any global additionalContainerspecs +#Example: +#additionalContainerspecs: +# imagePullPolicy: Always + # Optional. Deployment requests and limits. Enable only those values that need to be set. This also overrides any global values #resources: # requests: @@ -84,6 +89,11 @@ # nodeSelector: # disktype: ssd + # Optional. Use this to add additional values to the container specifications. These will be merged with any local additionalContainerspecs + #Example: + #additionalContainerspecs: + # imagePullPolicy: Always + # Optional. Deployment requests and limits. Enable only those values that need to be set. #resources: # requests: diff --git a/charts/networkgateway/templates/_cv.tpl b/charts/networkgateway/templates/_cv.tpl index 7c19fdb..10bf142 100644 --- a/charts/networkgateway/templates/_cv.tpl +++ b/charts/networkgateway/templates/_cv.tpl @@ -106,6 +106,21 @@ Values in defaults.yaml gets the last priority {{- end -}} {{- end }} +{{/* +cv.additionalContainerspecs is a function that allows the user to specify additional container specifications that are not mentioned in the deployment templates +Use "additionalContainerspecs" as the section name to enter the additional pod specifications. pod specifications can be specified at both global and local values +and will be merged to provide a single set of additional container specifications that will be added to the final deployment +There is also a provision to have chart level defaults which can be specified by having a defaults.yaml in chart directory. +Values in defaults.yaml gets the last priority +*/}} +{{- define "cv.additionalContainerspecs" }} +{{- $defaults := (fromYaml (.Files.Get "defaults.yaml")) }} +{{- if or (.Values.global).additionalContainerspecs .Values.additionalContainerspecs $defaults.additionalContainerspecs }} +{{- $combinedYaml := fromYaml ((include "cv.utils.getCombinedYaml" (list (.Values.global).additionalContainerspecs $defaults.additionalContainerspecs $ 8 false ))) }} +{{- include "cv.utils.getCombinedYaml" (list .Values.additionalContainerspecs $combinedYaml $ 8 false ) }} +{{- end -}} +{{- end }} + {{/* cv.commonContainerSpecs adds container specifications that are common for all commvault images */}} diff --git a/charts/networkgateway/templates/deploy.yaml b/charts/networkgateway/templates/deploy.yaml index 5b1898c..8fa0577 100644 --- a/charts/networkgateway/templates/deploy.yaml +++ b/charts/networkgateway/templates/deploy.yaml @@ -27,6 +27,7 @@ spec: - name: {{ $objectname }} image: {{ include "cv.image" . }} {{- include "cv.resources" . }} + {{- include "cv.additionalContainerspecs" . }} envFrom: - configMapRef: name: {{ include "cv.metadataname2" (list . "cvconfig") }} diff --git a/charts/networkgateway/values.yaml b/charts/networkgateway/values.yaml index 50673a6..dd5f371 100644 --- a/charts/networkgateway/values.yaml +++ b/charts/networkgateway/values.yaml @@ -28,6 +28,11 @@ # nodeSelector: # disktype: ssd +# Optional. Use this to add additional values to the container specifications. These will merge and override any global additionalContainerspecs +#Example: +#additionalContainerspecs: +# imagePullPolicy: Always + # Optional. Deployment requests and limits. Enable only those values that need to be set. This also overrides any global values #resources: # requests: @@ -72,6 +77,11 @@ # nodeSelector: # disktype: ssd + # Optional. Use this to add additional values to the container specifications. These will be merged with any local additionalContainerspecs + #Example: + #additionalContainerspecs: + # imagePullPolicy: Always + # Optional. Deployment requests and limits. Enable only those values that need to be set. #resources: # requests: diff --git a/charts/webserver/templates/_cv.tpl b/charts/webserver/templates/_cv.tpl index 7c19fdb..10bf142 100644 --- a/charts/webserver/templates/_cv.tpl +++ b/charts/webserver/templates/_cv.tpl @@ -106,6 +106,21 @@ Values in defaults.yaml gets the last priority {{- end -}} {{- end }} +{{/* +cv.additionalContainerspecs is a function that allows the user to specify additional container specifications that are not mentioned in the deployment templates +Use "additionalContainerspecs" as the section name to enter the additional pod specifications. pod specifications can be specified at both global and local values +and will be merged to provide a single set of additional container specifications that will be added to the final deployment +There is also a provision to have chart level defaults which can be specified by having a defaults.yaml in chart directory. +Values in defaults.yaml gets the last priority +*/}} +{{- define "cv.additionalContainerspecs" }} +{{- $defaults := (fromYaml (.Files.Get "defaults.yaml")) }} +{{- if or (.Values.global).additionalContainerspecs .Values.additionalContainerspecs $defaults.additionalContainerspecs }} +{{- $combinedYaml := fromYaml ((include "cv.utils.getCombinedYaml" (list (.Values.global).additionalContainerspecs $defaults.additionalContainerspecs $ 8 false ))) }} +{{- include "cv.utils.getCombinedYaml" (list .Values.additionalContainerspecs $combinedYaml $ 8 false ) }} +{{- end -}} +{{- end }} + {{/* cv.commonContainerSpecs adds container specifications that are common for all commvault images */}} diff --git a/charts/webserver/templates/deploy.yaml b/charts/webserver/templates/deploy.yaml index 6265454..3683da0 100644 --- a/charts/webserver/templates/deploy.yaml +++ b/charts/webserver/templates/deploy.yaml @@ -27,6 +27,7 @@ spec: - name: {{ $objectname }} image: {{ include "cv.image" . }} {{- include "cv.resources" . }} + {{- include "cv.additionalContainerspecs" . }} envFrom: - configMapRef: name: {{ include "cv.metadataname2" (list . "cvconfig") }} diff --git a/charts/webserver/values.yaml b/charts/webserver/values.yaml index 6263410..a898a38 100644 --- a/charts/webserver/values.yaml +++ b/charts/webserver/values.yaml @@ -32,6 +32,11 @@ # nodeSelector: # disktype: ssd +# Optional. Use this to add additional values to the container specifications. These will merge and override any global additionalContainerspecs +#Example: +#additionalContainerspecs: +# imagePullPolicy: Always + # Optional. Deployment requests and limits. Enable only those values that need to be set. This also overrides any global values #resources: # requests: @@ -79,6 +84,11 @@ # nodeSelector: # disktype: ssd + # Optional. Use this to add additional values to the container specifications. These will be merged with any local additionalContainerspecs + #Example: + #additionalContainerspecs: + # imagePullPolicy: Always + # Optional. Deployment requests and limits. Enable only those values that need to be set. #resources: # requests: