Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions charts/commandcenter/templates/_pvc.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ storageClass:
{{- end }}

{{- define "cv.commonVolumeMounts" }}
{{- $pathMode := include "cv.commandcenter.pathMode" . }}
- name: podinfo
mountPath: /etc/podinfo
- name: cv-storage-certsandlogs
Expand All @@ -169,9 +170,15 @@ storageClass:
mountPath: /etc/CommVaultRegistry
subPath: Registry
{{- end }}
{{- if eq $pathMode "v1" }}
- name: cv-storage-certsandlogs
mountPath: /opt/{{include "cv.utils.getOemPath" .}}/appdata
subPath: certificates
{{- else if eq $pathMode "v2" }}
- name: cv-storage-certsandlogs
mountPath: /var/opt/{{include "cv.utils.getOemPath" .}}/appdata
subPath: certificates
{{- end }}
{{- if eq (include "cv.useInitContainer" .) "true" }}
- name: cv-storage-certsandlogs
mountPath: /opt/{{include "cv.utils.getOemPath" .}}/k8ssecrets
Expand Down
83 changes: 83 additions & 0 deletions charts/commandcenter/templates/_utils.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,86 @@ Returns either commvault or metallic depending on the oem id
{{- "commvault" }}
{{- end }}
{{- end }}

{{/*
Returns true if the tag is older than 11.42.105
*/}}
{{- define "cv.commandcenter.isTagBefore42105" }}
{{- $tag := index . 0 }}
{{- $numbers := regexFindAll "(\\d+)" $tag 3 }}
{{- if lt (len $numbers) 2 }}
{{- printf "true" }}
{{- else }}
{{- $major := atoi (index $numbers 0) }}
{{- $fr := atoi (index $numbers 1) }}
{{- $sp := 0 }}
{{- if ge (len $numbers) 3 }}
{{- $sp = atoi (index $numbers 2) }}
{{- end }}
{{- if lt $major 11 }}
{{- printf "true" }}
{{- else if gt $major 11 }}
{{- printf "false" }}
{{- else if lt $fr 42 }}
{{- printf "true" }}
{{- else if gt $fr 42 }}
{{- printf "false" }}
{{- else if lt $sp 105 }}
{{- printf "true" }}
{{- else }}
{{- printf "false" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Determines whether commandcenter should use v1 or v2 paths
Decision precedence:
1. Existing v1/v2 annotation on Deployment/StatefulSet
2. Fresh install: v2 for 11.44+ else v1
3. Existing workload without path annotation: v1 if old image (<11.42.105), else v2
*/}}
{{- define "cv.commandcenter.pathMode" }}
{{- $objectname := include "cv.metadataname" . }}
{{- $namespace := include "cv.namespace" . }}
{{- $statefulset := or .Values.statefulset ((.Values).global).statefulset }}
{{- $kind := "Deployment" }}
{{- if $statefulset }}
{{- $kind = "StatefulSet" }}
{{- end }}
{{- $existing := lookup "apps/v1" $kind $namespace $objectname }}
{{- $annotations := dict }}
{{- if and $existing $existing.metadata $existing.metadata.annotations }}
{{- $annotations = $existing.metadata.annotations }}
{{- end }}

{{- if hasKey $annotations "v1paths" }}
{{- printf "v1" }}
{{- else if hasKey $annotations "v2paths" }}
{{- printf "v2" }}
{{- else if not $existing }}
{{- if eq (include "cv.utils.isMinVersion" (list . 11 44)) "true" }}
{{- printf "v2" }}
{{- else }}
{{- printf "v1" }}
{{- end }}
{{- else }}
{{- $oldTag := "" }}
{{- if and $existing.spec $existing.spec.template $existing.spec.template.spec (gt (len $existing.spec.template.spec.containers) 0) }}
{{- $oldImage := index $existing.spec.template.spec.containers 0 "image" }}
{{- if $oldImage }}
{{- $parts := splitList ":" $oldImage }}
{{- if gt (len $parts) 1 }}
{{- $oldTag = last $parts }}
{{- end }}
{{- end }}
{{- end }}
{{- if and $oldTag (eq (include "cv.commandcenter.isTagBefore42105" (list $oldTag)) "true") }}
{{- printf "v1" }}
{{- else if not $oldTag }}
{{- printf "v1" }}
{{- else }}
{{- printf "v2" }}
{{- end }}
{{- end }}
{{- end }}
13 changes: 11 additions & 2 deletions charts/commandcenter/templates/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,22 @@
{{- include "cv.utils.validateVersionAndRelease" . }}
{{- $objectname := include "cv.metadataname" . }}
{{- $statefulset := or .Values.statefulset ((.Values).global).statefulset }}
{{- $pathMode := include "cv.commandcenter.pathMode" . }}

apiVersion: apps/v1
kind: {{ if $statefulset }}StatefulSet{{ else }}Deployment{{ end }}
metadata:
name: {{ $objectname }}
namespace: {{ include "cv.namespace" . }}
{{- include "cv.deploymentannotations" . }}
annotations:
{{- if eq $pathMode "v2" }}
v2paths: "true"
{{- else }}
v1paths: "true"
{{- end }}
{{- if or (.Values.global).deploymentannotations .Values.deploymentannotations }}
{{- include "cv.utils.getCombinedYaml" (list .Values.deploymentannotations (.Values.global).deploymentannotations $ 4 true) }}
{{- end }}
labels:
app.kubernetes.io/name: {{ $objectname }}
spec:
Expand Down Expand Up @@ -50,7 +59,7 @@ 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" }}
{{- if eq $pathMode "v2" }}
- name: cv-storage-certsandlogs
mountPath: /opt/{{include "cv.utils.getOemPath" .}}/Apache/conf
subPath: apacheconf
Expand Down