Skip to content

Commit

Permalink
Merge pull request #3 from Commvault/initcontainer
Browse files Browse the repository at this point in the history
Initcontainer
  • Loading branch information
cvltmaheshp authored Mar 6, 2024
2 parents 08c8a53 + 336aea2 commit f49676f
Show file tree
Hide file tree
Showing 19 changed files with 511 additions and 0 deletions.
61 changes: 61 additions & 0 deletions charts/accessnode/templates/_cv.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/}}
Expand Down Expand Up @@ -144,6 +159,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
*/}}
Expand Down Expand Up @@ -189,6 +216,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 }}
Expand All @@ -201,6 +229,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'
Expand Down Expand Up @@ -248,3 +277,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 }}
4 changes: 4 additions & 0 deletions charts/accessnode/templates/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,22 @@ spec:
spec:
{{- include "cv.imagePullSecret" . }}
{{- include "cv.additionalPodspecs" . }}
{{- include "cv.initContainer" . }}
containers:
# access node
- name: {{ $objectname }}
image: {{ include "cv.image" . }}
{{- include "cv.resources" . }}
{{- include "cv.additionalContainerspecs" . }}
envFrom:
- 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
Expand Down
10 changes: 10 additions & 0 deletions charts/accessnode/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
61 changes: 61 additions & 0 deletions charts/commandcenter/templates/_cv.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/}}
Expand Down Expand Up @@ -144,6 +159,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
*/}}
Expand Down Expand Up @@ -189,6 +216,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 }}
Expand All @@ -201,6 +229,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'
Expand Down Expand Up @@ -248,3 +277,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 }}
4 changes: 4 additions & 0 deletions charts/commandcenter/templates/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,22 @@ spec:
spec:
{{- include "cv.imagePullSecret" . }}
{{- include "cv.additionalPodspecs" . }}
{{- include "cv.initContainer" . }}
containers:
# Command center
- name: {{ $objectname }}
image: {{ include "cv.image" . }}
{{- include "cv.resources" . }}
{{- include "cv.additionalContainerspecs" . }}
envFrom:
- 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
Expand Down
10 changes: 10 additions & 0 deletions charts/commandcenter/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
61 changes: 61 additions & 0 deletions charts/config/templates/_cv.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/}}
Expand Down Expand Up @@ -144,6 +159,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
*/}}
Expand Down Expand Up @@ -189,6 +216,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 }}
Expand All @@ -201,6 +229,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'
Expand Down Expand Up @@ -248,3 +277,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 }}
Loading

0 comments on commit f49676f

Please sign in to comment.