Skip to content

Commit

Permalink
Merge pull request #525 from jkroepke/tpl-config-reload
Browse files Browse the repository at this point in the history
[velero] Pass config trough tpl and implement reload trigger
  • Loading branch information
qiuming-best authored Dec 13, 2023
2 parents cbd56ae + 225569d commit ab0db25
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion charts/velero/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ appVersion: 1.12.2
kubeVersion: ">=1.16.0-0"
description: A Helm chart for velero
name: velero
version: 5.1.7
version: 5.2.0
home: https://github.com/vmware-tanzu/velero
icon: https://cdn-images-1.medium.com/max/1600/1*-9mb3AKnKdcL_QD3CMnthQ.png
sources:
Expand Down
8 changes: 8 additions & 0 deletions charts/velero/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,11 @@ For examples:
{{- $minorVersion := .Capabilities.KubeVersion.Minor | regexFind "[0-9]+" -}}
{{- printf "%s.%s" .Capabilities.KubeVersion.Major $minorVersion -}}
{{- end -}}


{{/*
Calculate the checksum of the credentials secret.
*/}}
{{- define "chart.config-checksum" -}}
{{- tpl (print .Values.credentials.secretContents .Values.credentials.extraEnvVars ) $ | sha256sum -}}
{{- end -}}
7 changes: 5 additions & 2 deletions charts/velero/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ spec:
{{- if .Values.podLabels }}
{{- toYaml .Values.podLabels | nindent 8 }}
{{- end }}
{{- if or .Values.podAnnotations .Values.metrics.enabled }}
{{- if or .Values.podAnnotations .Values.metrics.enabled (and .Values.credentials.useSecret (not .Values.credentials.existingSecret)) }}
annotations:
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
Expand All @@ -50,6 +50,9 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
{{- if and .Values.credentials.useSecret (not .Values.credentials.existingSecret) }}
checksum/secret: {{ template "chart.config-checksum" . }}
{{- end }}
{{- end }}
spec:
{{- if .Values.image.imagePullSecrets }}
Expand Down Expand Up @@ -218,7 +221,7 @@ spec:
{{- with .Values.configuration.extraEnvVars }}
{{- range $key, $value := . }}
- name: {{ default "none" $key }}
value: {{ default "none" $value | quote }}
value: {{ tpl (default "none" $value) $ | quote }}
{{- end }}
{{- end }}
{{- with .Values.credentials.extraEnvVars }}
Expand Down
9 changes: 6 additions & 3 deletions charts/velero/templates/node-agent-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ spec:
{{- if .Values.podLabels }}
{{- toYaml .Values.podLabels | nindent 8 }}
{{- end }}
{{- if or .Values.podAnnotations .Values.metrics.enabled }}
{{- if or .Values.podAnnotations .Values.metrics.enabled (and .Values.credentials.useSecret (not .Values.credentials.existingSecret)) }}
annotations:
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
Expand All @@ -43,6 +43,9 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
{{- if and .Values.credentials.useSecret (not .Values.credentials.existingSecret) }}
checksum/secret: {{ template "chart.config-checksum" . }}
{{- end }}
{{- end }}
spec:
{{- if .Values.image.imagePullSecrets }}
Expand Down Expand Up @@ -150,7 +153,7 @@ spec:
{{- with .Values.configuration.extraEnvVars }}
{{- range $key, $value := . }}
- name: {{ default "none" $key }}
value: {{ default "none" $value | quote }}
value: {{ tpl (default "none" $value) $ | quote }}
{{- end }}
{{- end }}
{{- with .Values.credentials.extraEnvVars }}
Expand Down Expand Up @@ -191,7 +194,7 @@ spec:
{{- with .Values.nodeAgent.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
{{- with .Values.nodeAgent.dnsConfig }}
dnsConfig:
{{- toYaml . | nindent 8 }}
Expand Down
4 changes: 2 additions & 2 deletions charts/velero/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ metadata:
type: Opaque
data:
{{- range $key, $value := .Values.credentials.secretContents }}
{{ $key }}: {{ $value | b64enc | quote }}
{{ $key }}: {{ tpl $value $ | b64enc | quote }}
{{- end }}
{{- range $key, $value := .Values.credentials.extraEnvVars }}
{{ $key }}: {{ $value | b64enc | quote }}
{{ $key }}: {{ tpl $value $ | b64enc | quote }}
{{- end }}
{{- end -}}
2 changes: 1 addition & 1 deletion charts/velero/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ serviceAccount:
credentials:
# Whether a secret should be used. Set to false if, for examples:
# - using kube2iam or kiam to provide AWS IAM credentials instead of providing the key file. (AWS only)
# - using workload identity instead of providing the key file. (GCP only)
# - using workload identity instead of providing the key file. (Azure/GCP only)
useSecret: true
# Name of the secret to create if `useSecret` is true and `existingSecret` is empty
name:
Expand Down

0 comments on commit ab0db25

Please sign in to comment.