Skip to content

Commit

Permalink
Merge pull request #4 from Commvault/initcontainer
Browse files Browse the repository at this point in the history
added support for init container
  • Loading branch information
cvltmaheshp authored Mar 15, 2024
2 parents f49676f + edc9587 commit 0406e21
Show file tree
Hide file tree
Showing 22 changed files with 243 additions and 201 deletions.
30 changes: 9 additions & 21 deletions charts/accessnode/templates/_cv.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ Values in defaults.yaml gets the last priority
{{- if eq (include "cv.utils.isMinVersion" (list . 11 40)) "true" }}
{{- $initContainer = true }}
{{- end }}
{{- if .Release.IsUpgrade -}}
{{- $initContainer = false }}
{{- end }}
{{- $initContainer = ternary $defaults.initContainer $initContainer (hasKey $defaults "initContainer") }}
{{- $initContainer = ternary .Values.initContainer $initContainer (hasKey .Values "initContainer") }}
{{- $initContainer | toString }}
Expand Down Expand Up @@ -281,31 +284,16 @@ cv.commondeploymentpecs creates pod specifications that are common to all deploy
{{- define "cv.initContainer" }}
{{- $objectname := include "cv.metadataname" . }}
{{- if eq (include "cv.useInitContainer" .) "true" }}
initContainers:
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
- cp /tmp/secretcontents/* /opt/{{include "cv.utils.getOemPath" .}}/Base64/Temp/k8ssecrets
volumeMounts:
- name: tmp
mountPath: /tmp/artifact
- name: configsecrets
mountPath: /opt/{{include "cv.utils.getOemPath" .}}/Base64/Temp/k8ssecrets
- name: cv-storage-secretssvolume
mountPath: /tmp/secretcontents
{{- end }}
{{- end }}
23 changes: 23 additions & 0 deletions charts/accessnode/templates/_pvc.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,31 @@ storageClass:
- name: cv-storage-certsandlogs
mountPath: /opt/{{include "cv.utils.getOemPath" .}}/appdata
subPath: certificates
{{- if eq (include "cv.useInitContainer" .) "true" }}
- name: configsecrets
mountPath: /opt/{{include "cv.utils.getOemPath" .}}/Base64/Temp/k8ssecrets
subPath: k8ssecrets
{{- end }}
{{- end }}

{{- define "cv.commonVolumes" }}
- name: podinfo
downwardAPI:
items:
- path: "labels"
fieldRef:
fieldPath: metadata.labels
- path: "annotations"
fieldRef:
fieldPath: metadata.annotations
{{- if eq (include "cv.useInitContainer" .) "true" }}
- name: cv-storage-secretssvolume
secret:
secretName: {{ include "cv.metadataname2" (list . "cvcreds") }}
- name: configsecrets
emptyDir: {}
{{- end }}
{{- end }}

{{- define "cv.deployment.volumes" }}
{{- $root := index . 0 }}
Expand Down
10 changes: 1 addition & 9 deletions charts/accessnode/templates/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,7 @@ spec:
{{ include "cv.commonContainerSpecs" . }}

volumes:
- name: podinfo
downwardAPI:
items:
- path: "labels"
fieldRef:
fieldPath: metadata.labels
- path: "annotations"
fieldRef:
fieldPath: metadata.annotations
{{- include "cv.commonVolumes" . }}
{{- if not $statefulset }}
{{- include "cv.deployment.volumes" (list . "certsandlogs" "10Gi") }}
{{- include "cv.deployment.volumes" (list . "jobresults" "20Gi") }}
Expand Down
30 changes: 9 additions & 21 deletions charts/commandcenter/templates/_cv.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ Values in defaults.yaml gets the last priority
{{- if eq (include "cv.utils.isMinVersion" (list . 11 40)) "true" }}
{{- $initContainer = true }}
{{- end }}
{{- if .Release.IsUpgrade -}}
{{- $initContainer = false }}
{{- end }}
{{- $initContainer = ternary $defaults.initContainer $initContainer (hasKey $defaults "initContainer") }}
{{- $initContainer = ternary .Values.initContainer $initContainer (hasKey .Values "initContainer") }}
{{- $initContainer | toString }}
Expand Down Expand Up @@ -281,31 +284,16 @@ cv.commondeploymentpecs creates pod specifications that are common to all deploy
{{- define "cv.initContainer" }}
{{- $objectname := include "cv.metadataname" . }}
{{- if eq (include "cv.useInitContainer" .) "true" }}
initContainers:
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
- cp /tmp/secretcontents/* /opt/{{include "cv.utils.getOemPath" .}}/Base64/Temp/k8ssecrets
volumeMounts:
- name: tmp
mountPath: /tmp/artifact
- name: configsecrets
mountPath: /opt/{{include "cv.utils.getOemPath" .}}/Base64/Temp/k8ssecrets
- name: cv-storage-secretssvolume
mountPath: /tmp/secretcontents
{{- end }}
{{- end }}
23 changes: 23 additions & 0 deletions charts/commandcenter/templates/_pvc.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,31 @@ storageClass:
- name: cv-storage-certsandlogs
mountPath: /opt/{{include "cv.utils.getOemPath" .}}/appdata
subPath: certificates
{{- if eq (include "cv.useInitContainer" .) "true" }}
- name: configsecrets
mountPath: /opt/{{include "cv.utils.getOemPath" .}}/Base64/Temp/k8ssecrets
subPath: k8ssecrets
{{- end }}
{{- end }}

{{- define "cv.commonVolumes" }}
- name: podinfo
downwardAPI:
items:
- path: "labels"
fieldRef:
fieldPath: metadata.labels
- path: "annotations"
fieldRef:
fieldPath: metadata.annotations
{{- if eq (include "cv.useInitContainer" .) "true" }}
- name: cv-storage-secretssvolume
secret:
secretName: {{ include "cv.metadataname2" (list . "cvcreds") }}
- name: configsecrets
emptyDir: {}
{{- end }}
{{- end }}

{{- define "cv.deployment.volumes" }}
{{- $root := index . 0 }}
Expand Down
15 changes: 6 additions & 9 deletions charts/commandcenter/templates/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,17 @@ spec:
volumeMounts:
# This section contains list of persistent volumes that has to be mounted onto the container.
# This can be left with default settings as mentioned in this template.
{{- if eq (include "cv.utils.isMinVersion" (list . 11 36)) "true" }}
- name: cv-storage-certsandlogs
mountPath: /opt/{{include "cv.utils.getOemPath" .}}/Apache/conf
subPath: apacheconf
{{- end }}
{{- include "cv.commonVolumeMounts" . }}
{{- include "cv.additionalVolumeMounts" . }}
{{ include "cv.commonContainerSpecs" . }}

volumes:
- name: podinfo
downwardAPI:
items:
- path: "labels"
fieldRef:
fieldPath: metadata.labels
- path: "annotations"
fieldRef:
fieldPath: metadata.annotations
{{- include "cv.commonVolumes" . }}
{{- if not $statefulset }}
{{- include "cv.deployment.volumes" (list . "certsandlogs" "10Gi") }}
{{- include "cv.deployment.additionalVolumes" . }}
Expand Down
30 changes: 9 additions & 21 deletions charts/config/templates/_cv.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ Values in defaults.yaml gets the last priority
{{- if eq (include "cv.utils.isMinVersion" (list . 11 40)) "true" }}
{{- $initContainer = true }}
{{- end }}
{{- if .Release.IsUpgrade -}}
{{- $initContainer = false }}
{{- end }}
{{- $initContainer = ternary $defaults.initContainer $initContainer (hasKey $defaults "initContainer") }}
{{- $initContainer = ternary .Values.initContainer $initContainer (hasKey .Values "initContainer") }}
{{- $initContainer | toString }}
Expand Down Expand Up @@ -281,31 +284,16 @@ cv.commondeploymentpecs creates pod specifications that are common to all deploy
{{- define "cv.initContainer" }}
{{- $objectname := include "cv.metadataname" . }}
{{- if eq (include "cv.useInitContainer" .) "true" }}
initContainers:
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
- cp /tmp/secretcontents/* /opt/{{include "cv.utils.getOemPath" .}}/Base64/Temp/k8ssecrets
volumeMounts:
- name: tmp
mountPath: /tmp/artifact
- name: configsecrets
mountPath: /opt/{{include "cv.utils.getOemPath" .}}/Base64/Temp/k8ssecrets
- name: cv-storage-secretssvolume
mountPath: /tmp/secretcontents
{{- end }}
{{- end }}
23 changes: 23 additions & 0 deletions charts/config/templates/_pvc.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,31 @@ storageClass:
- name: cv-storage-certsandlogs
mountPath: /opt/{{include "cv.utils.getOemPath" .}}/appdata
subPath: certificates
{{- if eq (include "cv.useInitContainer" .) "true" }}
- name: configsecrets
mountPath: /opt/{{include "cv.utils.getOemPath" .}}/Base64/Temp/k8ssecrets
subPath: k8ssecrets
{{- end }}
{{- end }}

{{- define "cv.commonVolumes" }}
- name: podinfo
downwardAPI:
items:
- path: "labels"
fieldRef:
fieldPath: metadata.labels
- path: "annotations"
fieldRef:
fieldPath: metadata.annotations
{{- if eq (include "cv.useInitContainer" .) "true" }}
- name: cv-storage-secretssvolume
secret:
secretName: {{ include "cv.metadataname2" (list . "cvcreds") }}
- name: configsecrets
emptyDir: {}
{{- end }}
{{- end }}

{{- define "cv.deployment.volumes" }}
{{- $root := index . 0 }}
Expand Down
6 changes: 6 additions & 0 deletions charts/config/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ data:
{{- if (.Values.secret).authcode }}
CV_CSAUTH_CODE: {{ or (.Values.secret).authcode "" | b64enc }}
{{- end }}
{{- if (.Values.secret).CCCertificate }}
CCCertificate: {{ or (.Values.secret).CCCertificate "" | b64enc }}
{{- end }}
{{- if (.Values.secret).CCCertificatePassword }}
CCCertificatePassword: {{ or (.Values.secret).CCCertificatePassword "" | b64enc}}
{{- end }}

---

Expand Down
2 changes: 2 additions & 0 deletions charts/config/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# user: # Optional. Plain text user name used for install.
# password: # Optional. Plain text password.
# authcode: # Optional. Authcode can be given in place of username/password
# CCCertificate # Optional. Certificate for Command Center.
# CCCertificatePassword # Optional. Plain text password for Command Center certificate.

# Optional. If pullsecret.create=true then an image pull secret will be created.
# pullsecret:
Expand Down
30 changes: 9 additions & 21 deletions charts/cs/templates/_cv.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ Values in defaults.yaml gets the last priority
{{- if eq (include "cv.utils.isMinVersion" (list . 11 40)) "true" }}
{{- $initContainer = true }}
{{- end }}
{{- if .Release.IsUpgrade -}}
{{- $initContainer = false }}
{{- end }}
{{- $initContainer = ternary $defaults.initContainer $initContainer (hasKey $defaults "initContainer") }}
{{- $initContainer = ternary .Values.initContainer $initContainer (hasKey .Values "initContainer") }}
{{- $initContainer | toString }}
Expand Down Expand Up @@ -281,31 +284,16 @@ cv.commondeploymentpecs creates pod specifications that are common to all deploy
{{- define "cv.initContainer" }}
{{- $objectname := include "cv.metadataname" . }}
{{- if eq (include "cv.useInitContainer" .) "true" }}
initContainers:
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
- cp /tmp/secretcontents/* /opt/{{include "cv.utils.getOemPath" .}}/Base64/Temp/k8ssecrets
volumeMounts:
- name: tmp
mountPath: /tmp/artifact
- name: configsecrets
mountPath: /opt/{{include "cv.utils.getOemPath" .}}/Base64/Temp/k8ssecrets
- name: cv-storage-secretssvolume
mountPath: /tmp/secretcontents
{{- end }}
{{- end }}
23 changes: 23 additions & 0 deletions charts/cs/templates/_pvc.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,31 @@ storageClass:
- name: cv-storage-certsandlogs
mountPath: /opt/{{include "cv.utils.getOemPath" .}}/appdata
subPath: certificates
{{- if eq (include "cv.useInitContainer" .) "true" }}
- name: configsecrets
mountPath: /opt/{{include "cv.utils.getOemPath" .}}/Base64/Temp/k8ssecrets
subPath: k8ssecrets
{{- end }}
{{- end }}

{{- define "cv.commonVolumes" }}
- name: podinfo
downwardAPI:
items:
- path: "labels"
fieldRef:
fieldPath: metadata.labels
- path: "annotations"
fieldRef:
fieldPath: metadata.annotations
{{- if eq (include "cv.useInitContainer" .) "true" }}
- name: cv-storage-secretssvolume
secret:
secretName: {{ include "cv.metadataname2" (list . "cvcreds") }}
- name: configsecrets
emptyDir: {}
{{- end }}
{{- end }}

{{- define "cv.deployment.volumes" }}
{{- $root := index . 0 }}
Expand Down
Loading

0 comments on commit 0406e21

Please sign in to comment.