From f9fcf95c053828c27ee6d0661801172c88056a1c Mon Sep 17 00:00:00 2001 From: Cesar Okuti Date: Tue, 9 Jun 2020 13:29:27 -0300 Subject: [PATCH 01/22] add schedule labels Signed-off-by: Cesar Okuti Signed-off-by: W. Kavanaugh Latiolais --- charts/velero/templates/schedule.yaml | 4 ++-- charts/velero/values.yaml | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/charts/velero/templates/schedule.yaml b/charts/velero/templates/schedule.yaml index 52c8a625..dd00ab99 100644 --- a/charts/velero/templates/schedule.yaml +++ b/charts/velero/templates/schedule.yaml @@ -8,8 +8,8 @@ metadata: app.kubernetes.io/instance: {{ $.Release.Name }} app.kubernetes.io/managed-by: {{ $.Release.Service }} helm.sh/chart: {{ include "velero.chart" $ }} - {{- if $schedule.labels }} - {{- toYaml $schedule.labels | nindent 4 }} + {{- if .Values.scheduleLabels }} + {{- toYaml .Values.scheduleLabels | nindent 4 }} {{- end }} spec: schedule: {{ $schedule.schedule | quote }} diff --git a/charts/velero/values.yaml b/charts/velero/values.yaml index 5f17bef1..5d468471 100644 --- a/charts/velero/values.yaml +++ b/charts/velero/values.yaml @@ -241,6 +241,8 @@ restic: # - foo schedules: {} +scheduleLabels: {} + # Velero ConfigMaps. # Eg: # configMaps: From d648f35c36dc1f7a3116b4baeb5f123ca56ccb4a Mon Sep 17 00:00:00 2001 From: Carlisia Date: Mon, 27 Jul 2020 17:19:49 -0700 Subject: [PATCH 02/22] Remove Prometheus operator CRDs Signed-off-by: Carlisia Signed-off-by: W. Kavanaugh Latiolais --- charts/velero/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/velero/Chart.yaml b/charts/velero/Chart.yaml index db446598..dfb6faed 100644 --- a/charts/velero/Chart.yaml +++ b/charts/velero/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v1 appVersion: 1.4.2 description: A Helm chart for velero name: velero -version: 2.12.16 +version: 2.12.10 home: https://github.com/vmware-tanzu/velero icon: https://cdn-images-1.medium.com/max/1600/1*-9mb3AKnKdcL_QD3CMnthQ.png sources: From 106c4629e751acfd8632f573ab838002f51cc213 Mon Sep 17 00:00:00 2001 From: "W. Kavanaugh Latiolais" Date: Wed, 5 Aug 2020 18:46:16 -0500 Subject: [PATCH 03/22] Fixes #90 - schedule.template BREAKING CHANGE Signed-off-by: W. Kavanaugh Latiolais --- charts/velero/templates/schedule.yaml | 8 ++++---- charts/velero/values.yaml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/charts/velero/templates/schedule.yaml b/charts/velero/templates/schedule.yaml index dd00ab99..883f5453 100644 --- a/charts/velero/templates/schedule.yaml +++ b/charts/velero/templates/schedule.yaml @@ -1,8 +1,8 @@ -{{- range $scheduleName, $schedule := .Values.schedules }} +{{- range .Values.schedules }} apiVersion: velero.io/v1 kind: Schedule metadata: - name: {{ include "velero.fullname" $ }}-{{ $scheduleName }} + name: {{ include "velero.fullname" $ }}-{{ .name }} labels: app.kubernetes.io/name: {{ include "velero.name" $ }} app.kubernetes.io/instance: {{ $.Release.Name }} @@ -12,8 +12,8 @@ metadata: {{- toYaml .Values.scheduleLabels | nindent 4 }} {{- end }} spec: - schedule: {{ $schedule.schedule | quote }} -{{- with $schedule.template }} + schedule: {{ .schedule | quote }} +{{- with .template }} template: {{- toYaml . | nindent 4 }} {{- end }} diff --git a/charts/velero/values.yaml b/charts/velero/values.yaml index 5d468471..6cb19e3b 100644 --- a/charts/velero/values.yaml +++ b/charts/velero/values.yaml @@ -239,7 +239,7 @@ restic: # ttl: "240h" # includedNamespaces: # - foo -schedules: {} +schedules: [] scheduleLabels: {} From 4af5769dd89cf31c95e8ad1f6d6d0b63c91d5216 Mon Sep 17 00:00:00 2001 From: "W. Kavanaugh Latiolais" Date: Wed, 5 Aug 2020 22:12:16 -0500 Subject: [PATCH 04/22] Fixes #89 - InitContainers/Provider BREAKING CHANGE Signed-off-by: W. Kavanaugh Latiolais --- charts/velero/templates/_helpers.tpl | 20 ++++++++++++++++++++ charts/velero/templates/deployment.yaml | 14 ++++++++++++-- charts/velero/values.yaml | 19 ++++++++++++------- 3 files changed, 44 insertions(+), 9 deletions(-) diff --git a/charts/velero/templates/_helpers.tpl b/charts/velero/templates/_helpers.tpl index 3ac184e6..19be9b3d 100644 --- a/charts/velero/templates/_helpers.tpl +++ b/charts/velero/templates/_helpers.tpl @@ -110,3 +110,23 @@ Create the volume snapshot location provider {{ default .provider .volumeSnapshotLocation.provider }} {{- end -}} {{- end -}} + + +{{/* +Create the plugin provider repository name +*/}} +{{- define "velero.plugin-for-provider" -}} + {{- $provider := .Values.configuration.provider -}} + {{- with .Values.pluginImage -}} + {{- if .repository -}} + {{- .Values.pluginImage.repository -}} + {{- else if eq $provider "azure" -}} + {{- "velero/velero-plugin-for-microsoft-azure" -}} + {{- else if eq $provider "alibabacloud" }} + {{- "registry.cn-hangzhou.aliyuncs.com/acs/velero-plugin-alibabacloud" -}} + {{- else -}} + {{- "velero/velero-plugin-for-" -}}{{ $provider }} + {{- end -}} + {{- end -}} +{{- end -}} + diff --git a/charts/velero/templates/deployment.yaml b/charts/velero/templates/deployment.yaml index 497dc977..6bae9445 100644 --- a/charts/velero/templates/deployment.yaml +++ b/charts/velero/templates/deployment.yaml @@ -137,10 +137,20 @@ spec: key: {{ default "none" $key }} {{- end }} {{- end }} -{{- if .Values.initContainers }} initContainers: + - name: velero-plugin + {{- if .Values.pluginImage.digest }} + image: "{{ include "velero.plugin-for-provider" . }}@{{ .Values.pluginImage.digest }}" + {{- else }} + image: "{{ include "velero.plugin-for-provider" . }}:{{ .Values.pluginImage.tag }}" + {{- end }} + imagePullPolicy: {{ .Values.pluginImage.pullPolicy }} + volumeMounts: + - mountPath: /target + name: plugins + {{- if .Values.initContainers }} {{- toYaml .Values.initContainers | nindent 8 }} -{{- end }} + {{- end }} volumes: {{- if .Values.credentials.useSecret }} - name: cloud-credentials diff --git a/charts/velero/values.yaml b/charts/velero/values.yaml index 6cb19e3b..5de7c017 100644 --- a/charts/velero/values.yaml +++ b/charts/velero/values.yaml @@ -12,6 +12,16 @@ image: # digest: pullPolicy: IfNotPresent +pluginImage: + # The plugin image repository will by default be selected using the provider property + # set a repository to override the image. + # repository: velero/velero-plugin-for-aws + tag: v1.1.0 + # Digest value example: sha256:d238835e151cec91c6a811fe3a89a66d3231d9f64d09e5f3c49552672d271f38. If used, it will + # take precedence over the image.tag. + # digest: + pullPolicy: IfNotPresent + # Annotations to add to the Velero deployment's pod template. Optional. # # If using kube2iam or kiam, use the following annotation with your AWS_ACCOUNT_ID @@ -26,14 +36,9 @@ podLabels: {} # Resource requests/limits to specify for the Velero deployment. Optional. resources: {} -# Init containers to add to the Velero deployment's pod spec. At least one plugin provider image is required. +# Init containers to add to the Velero deployment's pod spec. initContainers: [] - # - name: velero-plugin-for-aws - # image: velero/velero-plugin-for-aws:v1.1.0 - # imagePullPolicy: IfNotPresent - # volumeMounts: - # - mountPath: /target - # name: plugins + # SecurityContext to use for the Velero deployment. Optional. # Set fsGroup for `AWS IAM Roles for Service Accounts` From a2a9791e7e5865ec14d58bfbdcc7124d9c8e5774 Mon Sep 17 00:00:00 2001 From: "W. Kavanaugh Latiolais" Date: Wed, 5 Aug 2020 22:26:56 -0500 Subject: [PATCH 05/22] Fixes #88 - ExistingSecret Signed-off-by: W. Kavanaugh Latiolais --- charts/velero/templates/deployment.yaml | 8 ++++---- charts/velero/values.yaml | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/charts/velero/templates/deployment.yaml b/charts/velero/templates/deployment.yaml index 6bae9445..23e5dd92 100644 --- a/charts/velero/templates/deployment.yaml +++ b/charts/velero/templates/deployment.yaml @@ -110,16 +110,16 @@ spec: {{- if .Values.credentials.useSecret }} {{- if eq $provider "aws" }} - name: AWS_SHARED_CREDENTIALS_FILE - value: /credentials/cloud + value: /credentials/{{ .Values.credentials.existingSecretKey }} {{- else if eq $provider "gcp"}} - name: GOOGLE_APPLICATION_CREDENTIALS - value: /credentials/cloud + value: /credentials/{{ .Values.credentials.existingSecretKey }} {{- else if eq $provider "azure" }} - name: AZURE_CREDENTIALS_FILE - value: /credentials/cloud + value: /credentials/{{ .Values.credentials.existingSecretKey }} {{- else if eq $provider "alibabacloud" }} - name: ALIBABA_CLOUD_CREDENTIALS_FILE - value: /credentials/cloud + value: /credentials/{{ .Values.credentials.existingSecretKey }} {{- end }} {{- end }} {{- with .Values.configuration.extraEnvVars }} diff --git a/charts/velero/values.yaml b/charts/velero/values.yaml index 5de7c017..366e36f3 100644 --- a/charts/velero/values.yaml +++ b/charts/velero/values.yaml @@ -196,6 +196,7 @@ credentials: # Name of a pre-existing secret (if any) in the Velero namespace # that should be used to get IAM account credentials. Optional. existingSecret: + existingSecretKey: cloud # Data to be stored in the Velero secret, if `useSecret` is # true and `existingSecret` is empty. This should be the contents # of your IAM credentials file. From b8d769eb09d212acfa58f8843b59d6ab74d4a345 Mon Sep 17 00:00:00 2001 From: "W. Kavanaugh Latiolais" Date: Wed, 5 Aug 2020 22:58:44 -0500 Subject: [PATCH 06/22] Reving version and adding docs Signed-off-by: W. Kavanaugh Latiolais --- charts/velero/Chart.yaml | 2 +- charts/velero/README.md | 36 ++++++++++++++++++++++++++---------- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/charts/velero/Chart.yaml b/charts/velero/Chart.yaml index dfb6faed..e9f8f868 100644 --- a/charts/velero/Chart.yaml +++ b/charts/velero/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v1 appVersion: 1.4.2 description: A Helm chart for velero name: velero -version: 2.12.10 +version: 3.12.13 home: https://github.com/vmware-tanzu/velero icon: https://cdn-images-1.medium.com/max/1600/1*-9mb3AKnKdcL_QD3CMnthQ.png sources: diff --git a/charts/velero/README.md b/charts/velero/README.md index ccdfb2d2..7c3f4dd0 100644 --- a/charts/velero/README.md +++ b/charts/velero/README.md @@ -24,6 +24,30 @@ The default configuration values for this chart are listed in values.yaml. See Velero's full [official documentation](https://velero.io/docs/v1.4/basic-install/). More specifically, find your provider in the Velero list of [supported providers](https://velero.io/docs/v1.4/supported-providers/) for specific configuration information and examples. +#### Configuration + +Parameter | Description | Default +:--------------------------------------------------- | :--------------------------------------------------------------------------------------------------------- | :--------------------------------------------------- +`image.repository` | Velero image repository | `velero/velero` +`image.digest` | Velero image digest | +`image.tag` | Velero image tag | `v1.4.0` +`image.pullPolicy` | Velero image pull policy | `IfNotPresent` +`pluginImage.repository`* | Velero plugin image repository | Generated from `configuration.provider` +`pluginImage.digest` | Velero plugin image digest | +`pluginImage.tag` | Velero plugin image tag | `v1.1.0` +`pluginImage.pullPolicy` | Velero plugin image pull policy | `IfNotPresent` +`podAnnotations` | Annotations to add to the Velero deployment's pod template. | +`podLabels` | Additional pod labels for Velero deployment's template. | +`resources` | Resource requests/limits to specify for the Velero deployment. | +`initContainers` | Init containers to add to the Velero deployment's pod spec. | +`securityContext` | SecurityContext to use for the Velero deployment. | +`tolerations` | Tolerations to use for the Velero deployment. | +`affinity` | Affinity to use for the Velero deployment. | +`nodeSelector` | Node selector to use for the Velero deployment. | +`extraVolumes` | Extra volumes for the Velero deployment. | +`extraVolumeMounts` | Extra volumeMounts for the Velero deployment. | +`metrics.enabled` | Settings for Velero's prometheus metrics. Enabled by default. | `true` +`installCRDs` | Install CRDs as a templates. | `true` #### Using Helm 3 @@ -47,10 +71,6 @@ helm install vmware-tanzu/velero --namespace \ --set image.repository=velero/velero \ --set image.tag=v1.4.2 \ --set image.pullPolicy=IfNotPresent \ ---set initContainers[0].name=velero-plugin-for-aws \ ---set initContainers[0].image=velero/velero-plugin-for-aws:v1.1.0 \ ---set initContainers[0].volumeMounts[0].mountPath=/target \ ---set initContainers[0].volumeMounts[0].name=plugins \ --generate-name ``` @@ -98,11 +118,7 @@ helm install vmware-tanzu/velero --namespace \ --set configuration.volumeSnapshotLocation.config.region= \ --set image.repository=velero/velero \ --set image.tag=v1.4.2 \ ---set image.pullPolicy=IfNotPresent \ ---set initContainers[0].name=velero-plugin-for-aws \ ---set initContainers[0].image=velero/velero-plugin-for-aws:v1.1.0 \ ---set initContainers[0].volumeMounts[0].mountPath=/target \ ---set initContainers[0].volumeMounts[0].name=plugins +--set image.pullPolicy=IfNotPresent ``` ##### Option 2) YAML file @@ -118,7 +134,7 @@ helm install vmware-tanzu/velero --namespace -f values.yaml If a value needs to be added or changed, you may do so with the `upgrade` command. An example: ```bash -helm upgrade vmware-tanzu/velero --reuse-values --set configuration.provider= +helm upgrade vmware-tanzu/velero --reuse-values --set configuration.provider= ``` ## Upgrading From ddd47dc9ebb929a88973daf6c5ddb68b2dab358b Mon Sep 17 00:00:00 2001 From: "W. Kavanaugh Latiolais" Date: Sun, 16 Aug 2020 18:29:49 -0500 Subject: [PATCH 07/22] Removing config table Signed-off-by: W. Kavanaugh Latiolais --- charts/velero/README.md | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/charts/velero/README.md b/charts/velero/README.md index 7c3f4dd0..a0b4ce76 100644 --- a/charts/velero/README.md +++ b/charts/velero/README.md @@ -24,31 +24,6 @@ The default configuration values for this chart are listed in values.yaml. See Velero's full [official documentation](https://velero.io/docs/v1.4/basic-install/). More specifically, find your provider in the Velero list of [supported providers](https://velero.io/docs/v1.4/supported-providers/) for specific configuration information and examples. -#### Configuration - -Parameter | Description | Default -:--------------------------------------------------- | :--------------------------------------------------------------------------------------------------------- | :--------------------------------------------------- -`image.repository` | Velero image repository | `velero/velero` -`image.digest` | Velero image digest | -`image.tag` | Velero image tag | `v1.4.0` -`image.pullPolicy` | Velero image pull policy | `IfNotPresent` -`pluginImage.repository`* | Velero plugin image repository | Generated from `configuration.provider` -`pluginImage.digest` | Velero plugin image digest | -`pluginImage.tag` | Velero plugin image tag | `v1.1.0` -`pluginImage.pullPolicy` | Velero plugin image pull policy | `IfNotPresent` -`podAnnotations` | Annotations to add to the Velero deployment's pod template. | -`podLabels` | Additional pod labels for Velero deployment's template. | -`resources` | Resource requests/limits to specify for the Velero deployment. | -`initContainers` | Init containers to add to the Velero deployment's pod spec. | -`securityContext` | SecurityContext to use for the Velero deployment. | -`tolerations` | Tolerations to use for the Velero deployment. | -`affinity` | Affinity to use for the Velero deployment. | -`nodeSelector` | Node selector to use for the Velero deployment. | -`extraVolumes` | Extra volumes for the Velero deployment. | -`extraVolumeMounts` | Extra volumeMounts for the Velero deployment. | -`metrics.enabled` | Settings for Velero's prometheus metrics. Enabled by default. | `true` -`installCRDs` | Install CRDs as a templates. | `true` - #### Using Helm 3 First, create the namespace: `kubectl create namespace ` From ac3d3b2c56064dec9ac522cd5afe7642eaa2db45 Mon Sep 17 00:00:00 2001 From: "W. Kavanaugh Latiolais" Date: Mon, 17 Aug 2020 22:32:49 -0500 Subject: [PATCH 08/22] Fixing version Signed-off-by: W. Kavanaugh Latiolais --- charts/velero/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/velero/Chart.yaml b/charts/velero/Chart.yaml index e9f8f868..25e2518f 100644 --- a/charts/velero/Chart.yaml +++ b/charts/velero/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v1 appVersion: 1.4.2 description: A Helm chart for velero name: velero -version: 3.12.13 +version: 3.0.0 home: https://github.com/vmware-tanzu/velero icon: https://cdn-images-1.medium.com/max/1600/1*-9mb3AKnKdcL_QD3CMnthQ.png sources: From 3e431d87067ce128715eba81cff4774554aa3bac Mon Sep 17 00:00:00 2001 From: "W. Kavanaugh Latiolais" Date: Tue, 18 Aug 2020 10:47:42 -0500 Subject: [PATCH 09/22] Adding plugins for all providers Signed-off-by: W. Kavanaugh Latiolais --- charts/velero/templates/_helpers.tpl | 22 ++++------------- charts/velero/templates/deployment.yaml | 22 +++++++---------- charts/velero/values.yaml | 32 ++++++++++++++++++------- 3 files changed, 37 insertions(+), 39 deletions(-) diff --git a/charts/velero/templates/_helpers.tpl b/charts/velero/templates/_helpers.tpl index 19be9b3d..77f0d1bf 100644 --- a/charts/velero/templates/_helpers.tpl +++ b/charts/velero/templates/_helpers.tpl @@ -111,22 +111,10 @@ Create the volume snapshot location provider {{- end -}} {{- end -}} - -{{/* -Create the plugin provider repository name -*/}} -{{- define "velero.plugin-for-provider" -}} - {{- $provider := .Values.configuration.provider -}} - {{- with .Values.pluginImage -}} - {{- if .repository -}} - {{- .Values.pluginImage.repository -}} - {{- else if eq $provider "azure" -}} - {{- "velero/velero-plugin-for-microsoft-azure" -}} - {{- else if eq $provider "alibabacloud" }} - {{- "registry.cn-hangzhou.aliyuncs.com/acs/velero-plugin-alibabacloud" -}} - {{- else -}} - {{- "velero/velero-plugin-for-" -}}{{ $provider }} - {{- end -}} +{{- define "velero.image-from-values" -}} + {{- if .digest }} + {{- .repository }}@{{ .digest }} + {{- else }} + {{- .repository }}:{{ .tag }} {{- end -}} {{- end -}} - diff --git a/charts/velero/templates/deployment.yaml b/charts/velero/templates/deployment.yaml index 23e5dd92..e0b2ae7d 100644 --- a/charts/velero/templates/deployment.yaml +++ b/charts/velero/templates/deployment.yaml @@ -1,5 +1,6 @@ {{- if .Values.configuration.provider -}} -{{- $provider := .Values.configuration.provider -}} +{{- $providers := list .Values.configuration.provider .Values.configuration.backupStorageLocation.provider .Values.configuration.volumeSnapshotLocation.provider | compact | uniq -}} +{{- $provider := first $providers -}} apiVersion: apps/v1 kind: Deployment metadata: @@ -43,11 +44,7 @@ spec: {{- end }} containers: - name: velero - {{- if .Values.image.digest }} - image: "{{ .Values.image.repository }}@{{ .Values.image.digest }}" - {{- else }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" - {{- end }} + image: {{include "velero.image-from-values" .Values.image }} imagePullPolicy: {{ .Values.image.pullPolicy }} {{- if .Values.metrics.enabled }} ports: @@ -138,16 +135,15 @@ spec: {{- end }} {{- end }} initContainers: - - name: velero-plugin - {{- if .Values.pluginImage.digest }} - image: "{{ include "velero.plugin-for-provider" . }}@{{ .Values.pluginImage.digest }}" - {{- else }} - image: "{{ include "velero.plugin-for-provider" . }}:{{ .Values.pluginImage.tag }}" - {{- end }} - imagePullPolicy: {{ .Values.pluginImage.pullPolicy }} + {{- range $providers }} + {{- $pluginImage := get $.Values.pluginImages . }} + - name: velero-plugin-for-{{.}} + image: {{include "velero.image-from-values" $pluginImage }} + imagePullPolicy: {{ $pluginImage.pullPolicy }} volumeMounts: - mountPath: /target name: plugins + {{- end }} {{- if .Values.initContainers }} {{- toYaml .Values.initContainers | nindent 8 }} {{- end }} diff --git a/charts/velero/values.yaml b/charts/velero/values.yaml index 366e36f3..df52705b 100644 --- a/charts/velero/values.yaml +++ b/charts/velero/values.yaml @@ -12,15 +12,29 @@ image: # digest: pullPolicy: IfNotPresent -pluginImage: - # The plugin image repository will by default be selected using the provider property - # set a repository to override the image. - # repository: velero/velero-plugin-for-aws - tag: v1.1.0 - # Digest value example: sha256:d238835e151cec91c6a811fe3a89a66d3231d9f64d09e5f3c49552672d271f38. If used, it will - # take precedence over the image.tag. - # digest: - pullPolicy: IfNotPresent +pluginImages: + alibabacloud: + repository: registry.cn-hangzhou.aliyuncs.com/acs/velero-plugin-alibabacloud + tag: v1.1.0 + pullPolicy: IfNotPresent + aws: + repository: velero/velero-plugin-for-aws + tag: v1.1.0 + pullPolicy: IfNotPresent + azure: + repository: velero/velero-plugin-for-microsoft-azure + tag: v1.1.0 + pullPolicy: IfNotPresent + csi: + repository: velero/velero-plugin-for-csi + tag: v0.1.1 + pullPolicy: IfNotPresent + gcp: + repository: velero/velero-plugin-for-gcp + tag: v1.1.0 + pullPolicy: IfNotPresent + + # Annotations to add to the Velero deployment's pod template. Optional. # From cb958885a9d993bc772a19cd415d4963e52098df Mon Sep 17 00:00:00 2001 From: "W. Kavanaugh Latiolais" Date: Tue, 18 Aug 2020 10:47:42 -0500 Subject: [PATCH 10/22] renaming secret file to align with velero install Signed-off-by: W. Kavanaugh Latiolais --- charts/velero/templates/deployment.yaml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/charts/velero/templates/deployment.yaml b/charts/velero/templates/deployment.yaml index e0b2ae7d..ae43e0ae 100644 --- a/charts/velero/templates/deployment.yaml +++ b/charts/velero/templates/deployment.yaml @@ -107,16 +107,16 @@ spec: {{- if .Values.credentials.useSecret }} {{- if eq $provider "aws" }} - name: AWS_SHARED_CREDENTIALS_FILE - value: /credentials/{{ .Values.credentials.existingSecretKey }} + value: /credentials/cloud {{- else if eq $provider "gcp"}} - name: GOOGLE_APPLICATION_CREDENTIALS - value: /credentials/{{ .Values.credentials.existingSecretKey }} + value: /credentials/cloud {{- else if eq $provider "azure" }} - name: AZURE_CREDENTIALS_FILE - value: /credentials/{{ .Values.credentials.existingSecretKey }} + value: /credentials/cloud {{- else if eq $provider "alibabacloud" }} - name: ALIBABA_CLOUD_CREDENTIALS_FILE - value: /credentials/{{ .Values.credentials.existingSecretKey }} + value: /credentials/cloud {{- end }} {{- end }} {{- with .Values.configuration.extraEnvVars }} @@ -152,6 +152,9 @@ spec: - name: cloud-credentials secret: secretName: {{ include "velero.secretName" . }} + items: + - key: {{ .Values.credentials.existingSecretKey }} + path: cloud {{- end }} - name: plugins emptyDir: {} From 64d4fc4a5c3281be0409b021a8ff42d0997b4520 Mon Sep 17 00:00:00 2001 From: "W. Kavanaugh Latiolais" Date: Sat, 29 Aug 2020 14:39:03 -0500 Subject: [PATCH 11/22] Adding plugins and tests for initContainers Tagged version as alpha since there are other breaking change under discussion Signed-off-by: W. Kavanaugh Latiolais --- README.md | 9 ++ charts/velero/Chart.yaml | 2 +- charts/velero/templates/_helpers.tpl | 27 +++- charts/velero/templates/deployment.yaml | 22 +++- charts/velero/tests/base-values.yaml | 9 ++ .../tests/deployment_initContainers_test.yaml | 116 ++++++++++++++++++ charts/velero/values.yaml | 12 ++ 7 files changed, 186 insertions(+), 11 deletions(-) create mode 100644 charts/velero/tests/base-values.yaml create mode 100644 charts/velero/tests/deployment_initContainers_test.yaml diff --git a/README.md b/README.md index 928e0cbc..dcdb4c84 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,15 @@ You can then run `helm search repo vmware-tanzu` to see the charts. TBD +### Running Tests + +To run unit tests in this repository please install helm-unittest + +```sh +helm plugin install https://github.com/quintush/helm-unittest +helm unittest -3 charts/velero +``` + ## License [Apache 2.0 License](./LICENSE). diff --git a/charts/velero/Chart.yaml b/charts/velero/Chart.yaml index 25e2518f..4d35b6cc 100644 --- a/charts/velero/Chart.yaml +++ b/charts/velero/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v1 appVersion: 1.4.2 description: A Helm chart for velero name: velero -version: 3.0.0 +version: 3.0.0-alpha.1 home: https://github.com/vmware-tanzu/velero icon: https://cdn-images-1.medium.com/max/1600/1*-9mb3AKnKdcL_QD3CMnthQ.png sources: diff --git a/charts/velero/templates/_helpers.tpl b/charts/velero/templates/_helpers.tpl index 77f0d1bf..6b88d012 100644 --- a/charts/velero/templates/_helpers.tpl +++ b/charts/velero/templates/_helpers.tpl @@ -112,9 +112,28 @@ Create the volume snapshot location provider {{- end -}} {{- define "velero.image-from-values" -}} - {{- if .digest }} - {{- .repository }}@{{ .digest }} - {{- else }} - {{- .repository }}:{{ .tag }} + {{- if kindIs "string" . -}} + {{- . }} + {{- else -}} + {{- if .digest -}} + {{- .repository }}@{{ .digest }} + {{- else -}} + {{- .repository }}:{{ .tag }} + {{- end -}} + {{- end -}} +{{- end -}} +{{- define "velero.pull-policy-from-values" -}} + {{- if kindIs "string" . -}} + {{ "IfNotPresent" -}} + {{- else -}} + {{ .pullPolicy -}} + {{- end -}} +{{- end -}} + +{{- define "velero.name-from-values" -}} + {{- if kindIs "string" . -}} + {{ splitList "@" . | first | splitList ":" | first | splitList "/" | last -}} + {{- else -}} + {{ splitList "/" .repository | last -}} {{- end -}} {{- end -}} diff --git a/charts/velero/templates/deployment.yaml b/charts/velero/templates/deployment.yaml index ae43e0ae..6b8a760b 100644 --- a/charts/velero/templates/deployment.yaml +++ b/charts/velero/templates/deployment.yaml @@ -45,7 +45,7 @@ spec: containers: - name: velero image: {{include "velero.image-from-values" .Values.image }} - imagePullPolicy: {{ .Values.image.pullPolicy }} + imagePullPolicy: {{ include "velero.pull-policy-from-values" .Values.image }} {{- if .Values.metrics.enabled }} ports: - name: monitoring @@ -135,11 +135,19 @@ spec: {{- end }} {{- end }} initContainers: - {{- range $providers }} - {{- $pluginImage := get $.Values.pluginImages . }} - - name: velero-plugin-for-{{.}} - image: {{include "velero.image-from-values" $pluginImage }} - imagePullPolicy: {{ $pluginImage.pullPolicy }} + {{- $plugins := list -}} + {{- if kindIs "string" .Values.plugins -}} + {{- $plugins = splitList "," .Values.plugins -}} + {{- else -}} + {{- $plugins = .Values.plugins -}} + {{- end -}} + {{- range $providers -}} + {{- $plugins = append $plugins (get $.Values.pluginImages .) }} + {{- end }} + {{- range $pluginImage := $plugins }} + - name: {{ include "velero.name-from-values" $pluginImage }} + image: {{ include "velero.image-from-values" $pluginImage }} + imagePullPolicy: {{ include "velero.pull-policy-from-values" $pluginImage }} volumeMounts: - mountPath: /target name: plugins @@ -147,6 +155,8 @@ spec: {{- if .Values.initContainers }} {{- toYaml .Values.initContainers | nindent 8 }} {{- end }} + + volumes: {{- if .Values.credentials.useSecret }} - name: cloud-credentials diff --git a/charts/velero/tests/base-values.yaml b/charts/velero/tests/base-values.yaml new file mode 100644 index 00000000..c5a2f8fc --- /dev/null +++ b/charts/velero/tests/base-values.yaml @@ -0,0 +1,9 @@ +configuration: + provider: gcp +schedules: + - name: mybackup + schedule: "0 0 * * *" + template: + ttl: "240h" + includedNamespaces: + - foo diff --git a/charts/velero/tests/deployment_initContainers_test.yaml b/charts/velero/tests/deployment_initContainers_test.yaml new file mode 100644 index 00000000..945748ec --- /dev/null +++ b/charts/velero/tests/deployment_initContainers_test.yaml @@ -0,0 +1,116 @@ +tests: + - it: installs initContainers for initContainers array + set: + initContainers: + - image: test/an-init-container + imagePullPolicy: Always + name: the-init-container + volumeMounts: + - mountPath: /test + name: test + values: + - base-values.yaml + template: deployment.yaml + asserts: + - contains: + path: spec.template.spec.initContainers + content: + image: test/an-init-container + imagePullPolicy: Always + name: the-init-container + volumeMounts: + - mountPath: /test + name: test + - it: installs plugins initContainers for the various provider values + set: + configuration: + provider: aws + backupStorageLocation: + provider: azure + volumeSnapshotLocation: + provider: alibabacloud + values: + - base-values.yaml + template: deployment.yaml + asserts: + - contains: + path: spec.template.spec.initContainers + content: + image: velero/velero-plugin-for-aws:v1.1.0 + imagePullPolicy: IfNotPresent + name: velero-plugin-for-aws + volumeMounts: + - mountPath: /target + name: plugins + - contains: + path: spec.template.spec.initContainers + content: + image: velero/velero-plugin-for-microsoft-azure:v1.1.0 + imagePullPolicy: IfNotPresent + name: velero-plugin-for-microsoft-azure + volumeMounts: + - mountPath: /target + name: plugins + - contains: + path: spec.template.spec.initContainers + content: + image: registry.cn-hangzhou.aliyuncs.com/acs/velero-plugin-alibabacloud:v1.1.0 + imagePullPolicy: IfNotPresent + name: velero-plugin-alibabacloud + volumeMounts: + - mountPath: /target + name: plugins + - it: installs plugins initContainers for plugins as a array of image tags/objects + set: + plugins: + - velero/velero-plugin-for-test1:first + - repository: velero/velero-plugin-for-test2 + digest: sha256:second + pullPolicy: Always + values: + - base-values.yaml + template: deployment.yaml + asserts: + - contains: + path: spec.template.spec.initContainers + content: + image: velero/velero-plugin-for-test1:first + imagePullPolicy: IfNotPresent + name: velero-plugin-for-test1 + volumeMounts: + - mountPath: /target + name: plugins + - contains: + path: spec.template.spec.initContainers + content: + name: velero-plugin-for-test2 + image: velero/velero-plugin-for-test2@sha256:second + imagePullPolicy: Always + volumeMounts: + - mountPath: /target + name: plugins + - it: allows plugins as a string of plugin images + set: + plugins: velero/velero-plugin-for-test1:first,velero/velero-plugin-for-test2@sha256:second + values: + - base-values.yaml + template: deployment.yaml + asserts: + - contains: + path: spec.template.spec.initContainers + content: + name: velero-plugin-for-test1 + image: velero/velero-plugin-for-test1:first + imagePullPolicy: IfNotPresent + volumeMounts: + - mountPath: /target + name: plugins + - contains: + path: spec.template.spec.initContainers + content: + name: velero-plugin-for-test2 + image: velero/velero-plugin-for-test2@sha256:second + imagePullPolicy: IfNotPresent + volumeMounts: + - mountPath: /target + name: plugins diff --git a/charts/velero/values.yaml b/charts/velero/values.yaml index df52705b..f0fc2728 100644 --- a/charts/velero/values.yaml +++ b/charts/velero/values.yaml @@ -12,6 +12,7 @@ image: # digest: pullPolicy: IfNotPresent +# default plugin images to enabled when used by providers pluginImages: alibabacloud: repository: registry.cn-hangzhou.aliyuncs.com/acs/velero-plugin-alibabacloud @@ -34,6 +35,17 @@ pluginImages: tag: v1.1.0 pullPolicy: IfNotPresent +# Additional plugin images to install +# Supports a comma seperated string +# plugins: 'velero/velero-plugin-for-aws:v1.1.0,velero/velero-plugin-for-csi:v0.1.1' +# +# Or an array of images as strings and/or objects +# plugins: +# - velero/velero-plugin-for-aws:v1.1.0 +# - repository: velero/velero-plugin-for-csi +# digest: sha256:60d47fd25216f13073525823a067eab223d12e695d4b41e480aa3ff13a58c916 +# pullPolicy: Always +plugins: [] # Annotations to add to the Velero deployment's pod template. Optional. From 39fb672724c67375e13507a161801dc8983a122a Mon Sep 17 00:00:00 2001 From: "W. Kavanaugh Latiolais" Date: Sat, 29 Aug 2020 16:11:43 -0500 Subject: [PATCH 12/22] Unifying with scheduleLabels and fixing helm2 Signed-off-by: W. Kavanaugh Latiolais --- charts/velero/templates/deployment.yaml | 2 +- charts/velero/templates/schedule.yaml | 4 ++-- charts/velero/values.yaml | 4 +--- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/charts/velero/templates/deployment.yaml b/charts/velero/templates/deployment.yaml index 6b8a760b..fd8b7590 100644 --- a/charts/velero/templates/deployment.yaml +++ b/charts/velero/templates/deployment.yaml @@ -142,7 +142,7 @@ spec: {{- $plugins = .Values.plugins -}} {{- end -}} {{- range $providers -}} - {{- $plugins = append $plugins (get $.Values.pluginImages .) }} + {{- $plugins = append $plugins (pluck . $.Values.pluginImages | first) }} {{- end }} {{- range $pluginImage := $plugins }} - name: {{ include "velero.name-from-values" $pluginImage }} diff --git a/charts/velero/templates/schedule.yaml b/charts/velero/templates/schedule.yaml index 883f5453..f4cc7456 100644 --- a/charts/velero/templates/schedule.yaml +++ b/charts/velero/templates/schedule.yaml @@ -8,8 +8,8 @@ metadata: app.kubernetes.io/instance: {{ $.Release.Name }} app.kubernetes.io/managed-by: {{ $.Release.Service }} helm.sh/chart: {{ include "velero.chart" $ }} - {{- if .Values.scheduleLabels }} - {{- toYaml .Values.scheduleLabels | nindent 4 }} + {{- if $.Values.scheduleLabels }} + {{- toYaml $.Values.scheduleLabels | nindent 4 }} {{- end }} spec: schedule: {{ .schedule | quote }} diff --git a/charts/velero/values.yaml b/charts/velero/values.yaml index f0fc2728..0aac58d8 100644 --- a/charts/velero/values.yaml +++ b/charts/velero/values.yaml @@ -263,9 +263,7 @@ restic: # Backup schedules to create. # Eg: # schedules: -# mybackup: -# labels: -# myenv: foo +# name: mybackup # schedule: "0 0 * * *" # template: # ttl: "240h" From e6d94f97eb59d37b8f927a4c3a019d34e0cf628d Mon Sep 17 00:00:00 2001 From: "W. Kavanaugh Latiolais" Date: Sat, 29 Aug 2020 16:50:14 -0500 Subject: [PATCH 13/22] Inferring useSecret We create a secret if we have contents or envVars to put in it. We use a secret if we created one or if we have an existing one. Signed-off-by: W. Kavanaugh Latiolais --- charts/velero/templates/deployment.yaml | 7 ++++--- charts/velero/templates/restic-daemonset.yaml | 7 ++++--- charts/velero/templates/secret.yaml | 2 +- charts/velero/values.yaml | 11 ++++++----- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/charts/velero/templates/deployment.yaml b/charts/velero/templates/deployment.yaml index fd8b7590..aa6dac67 100644 --- a/charts/velero/templates/deployment.yaml +++ b/charts/velero/templates/deployment.yaml @@ -1,6 +1,7 @@ {{- if .Values.configuration.provider -}} {{- $providers := list .Values.configuration.provider .Values.configuration.backupStorageLocation.provider .Values.configuration.volumeSnapshotLocation.provider | compact | uniq -}} {{- $provider := first $providers -}} +{{- $useSecret := or .Values.credentials.existingSecret (or .Values.credentials.secretContents .Values.credentials.extraEnvVars) -}} apiVersion: apps/v1 kind: Deployment metadata: @@ -85,7 +86,7 @@ spec: volumeMounts: - name: plugins mountPath: /plugins - {{- if .Values.credentials.useSecret }} + {{- if or .Values.credentials.secretContents .Values.credentials.extraEnvVars }} - name: cloud-credentials mountPath: /credentials - name: scratch @@ -104,7 +105,7 @@ spec: fieldPath: metadata.namespace - name: LD_LIBRARY_PATH value: /plugins - {{- if .Values.credentials.useSecret }} + {{- if $useSecret }} {{- if eq $provider "aws" }} - name: AWS_SHARED_CREDENTIALS_FILE value: /credentials/cloud @@ -158,7 +159,7 @@ spec: volumes: - {{- if .Values.credentials.useSecret }} + {{- if $useSecret }} - name: cloud-credentials secret: secretName: {{ include "velero.secretName" . }} diff --git a/charts/velero/templates/restic-daemonset.yaml b/charts/velero/templates/restic-daemonset.yaml index 25dca825..9b261954 100644 --- a/charts/velero/templates/restic-daemonset.yaml +++ b/charts/velero/templates/restic-daemonset.yaml @@ -1,5 +1,6 @@ {{- if .Values.deployRestic }} {{- $provider := .Values.configuration.provider -}} +{{- $useSecret := or .Values.credentials.existingSecret (or .Values.credentials.secretContents .Values.credentials.extraEnvVars) -}} apiVersion: apps/v1 kind: DaemonSet metadata: @@ -36,7 +37,7 @@ spec: priorityClassName: {{ include "velero.restic.priorityClassName" . }} {{- end }} volumes: - {{- if .Values.credentials.useSecret }} + {{- if $useSecret }} - name: cloud-credentials secret: secretName: {{ include "velero.secretName" . }} @@ -74,7 +75,7 @@ spec: {{- end }} {{- end }} volumeMounts: - {{- if .Values.credentials.useSecret }} + {{- if $useSecret }} - name: cloud-credentials mountPath: /credentials {{- end }} @@ -103,7 +104,7 @@ spec: fieldPath: spec.nodeName - name: VELERO_SCRATCH_DIR value: /scratch - {{- if .Values.credentials.useSecret }} + {{- if $useSecret }} {{- if eq $provider "aws" }} - name: AWS_SHARED_CREDENTIALS_FILE value: /credentials/cloud diff --git a/charts/velero/templates/secret.yaml b/charts/velero/templates/secret.yaml index 650228a0..6358ddce 100644 --- a/charts/velero/templates/secret.yaml +++ b/charts/velero/templates/secret.yaml @@ -1,4 +1,4 @@ -{{- if and .Values.credentials.useSecret (not .Values.credentials.existingSecret) -}} +{{- if and (not .Values.credentials.existingSecret) (or .Values.credentials.secretContents .Values.credentials.extraEnvVars ) -}} apiVersion: v1 kind: Secret metadata: diff --git a/charts/velero/values.yaml b/charts/velero/values.yaml index 0aac58d8..5ad6c918 100644 --- a/charts/velero/values.yaml +++ b/charts/velero/values.yaml @@ -215,18 +215,19 @@ serviceAccount: # should contain credentials for the cloud provider IAM account you've # set up for Velero. credentials: - # Whether a secret should be used as the source of IAM account - # credentials. Set to false if, for example, using kube2iam or - # kiam to provide IAM credentials for the Velero pod. - useSecret: true # Name of a pre-existing secret (if any) in the Velero namespace # that should be used to get IAM account credentials. Optional. - existingSecret: + # existingSecret: + + # Key within a pre-existing secret (if any) in the Velero namespace + # that should be used to get IAM account credentials. Optional. existingSecretKey: cloud + # Data to be stored in the Velero secret, if `useSecret` is # true and `existingSecret` is empty. This should be the contents # of your IAM credentials file. secretContents: {} + # additional key/value pairs to be used as environment variables such as "DIGITALOCEAN_TOKEN: ". Values will be stored in the secret. extraEnvVars: {} From cb2f06594236e612bd0ef61a9bb1786384d89085 Mon Sep 17 00:00:00 2001 From: "W. Kavanaugh Latiolais" Date: Sat, 29 Aug 2020 20:31:42 -0500 Subject: [PATCH 14/22] Adding credentials tests Signed-off-by: W. Kavanaugh Latiolais --- charts/velero/tests/credentials_test.yaml | 55 +++++++++++++++++++ .../tests/deployment_initContainers_test.yaml | 6 +- 2 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 charts/velero/tests/credentials_test.yaml diff --git a/charts/velero/tests/credentials_test.yaml b/charts/velero/tests/credentials_test.yaml new file mode 100644 index 00000000..83fb53b1 --- /dev/null +++ b/charts/velero/tests/credentials_test.yaml @@ -0,0 +1,55 @@ +suite: Credentials +templates: + - deployment.yaml + - secret.yaml +tests: + - it: doesn't create secrets or use them if there is no data or existing secret + values: + - base-values.yaml + asserts: + - template: secret.yaml + hasDocuments: + count: 0 + - template: deployment.yaml + notContains: + any: true + path: spec.template.spec.volumes + content: + name: cloud-credentials + - it: doesn't create secrets if an existingSecret is provided but does use them + values: + - base-values.yaml + set: + credentials: + existingSecret: foo-secret + asserts: + - template: secret.yaml + hasDocuments: + count: 0 + - template: deployment.yaml + contains: + any: true + path: spec.template.spec.volumes + content: + name: cloud-credentials + - it: creates secrets and uses them if secretContent is provided + values: + - base-values.yaml + set: + credentials: + existingSecretKey: credentials + secretContents: + credentials: | + [default] + aws_access_key_id=AKIAIOSFODNN7EXAMPLE + aws_secret_access_key=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY + asserts: + - template: secret.yaml + hasDocuments: + count: 1 + - template: deployment.yaml + contains: + any: true + path: spec.template.spec.volumes + content: + name: cloud-credentials diff --git a/charts/velero/tests/deployment_initContainers_test.yaml b/charts/velero/tests/deployment_initContainers_test.yaml index 945748ec..24cdda06 100644 --- a/charts/velero/tests/deployment_initContainers_test.yaml +++ b/charts/velero/tests/deployment_initContainers_test.yaml @@ -1,3 +1,5 @@ +templates: + - deployment.yaml tests: - it: installs initContainers for initContainers array set: @@ -10,7 +12,6 @@ tests: name: test values: - base-values.yaml - template: deployment.yaml asserts: - contains: path: spec.template.spec.initContainers @@ -31,7 +32,6 @@ tests: provider: alibabacloud values: - base-values.yaml - template: deployment.yaml asserts: - contains: path: spec.template.spec.initContainers @@ -69,7 +69,6 @@ tests: pullPolicy: Always values: - base-values.yaml - template: deployment.yaml asserts: - contains: path: spec.template.spec.initContainers @@ -94,7 +93,6 @@ tests: plugins: velero/velero-plugin-for-test1:first,velero/velero-plugin-for-test2@sha256:second values: - base-values.yaml - template: deployment.yaml asserts: - contains: path: spec.template.spec.initContainers From 54692e112341eb32e0fd4bdaacdd94ce98812011 Mon Sep 17 00:00:00 2001 From: "W. Kavanaugh Latiolais" Date: Sat, 29 Aug 2020 20:38:39 -0500 Subject: [PATCH 15/22] Switching deployRestic to restic.enabled Signed-off-by: W. Kavanaugh Latiolais --- charts/velero/templates/restic-daemonset.yaml | 2 +- charts/velero/tests/restic-daemonset_test.yaml | 18 ++++++++++++++++++ charts/velero/values.yaml | 5 ++--- 3 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 charts/velero/tests/restic-daemonset_test.yaml diff --git a/charts/velero/templates/restic-daemonset.yaml b/charts/velero/templates/restic-daemonset.yaml index 9b261954..9e4c8c2a 100644 --- a/charts/velero/templates/restic-daemonset.yaml +++ b/charts/velero/templates/restic-daemonset.yaml @@ -1,4 +1,4 @@ -{{- if .Values.deployRestic }} +{{- if .Values.restic.enabled }} {{- $provider := .Values.configuration.provider -}} {{- $useSecret := or .Values.credentials.existingSecret (or .Values.credentials.secretContents .Values.credentials.extraEnvVars) -}} apiVersion: apps/v1 diff --git a/charts/velero/tests/restic-daemonset_test.yaml b/charts/velero/tests/restic-daemonset_test.yaml new file mode 100644 index 00000000..19894618 --- /dev/null +++ b/charts/velero/tests/restic-daemonset_test.yaml @@ -0,0 +1,18 @@ +suite: Restic DaemonSet +templates: + - restic-daemonset.yaml +tests: + - it: is not created by default + values: + - base-values.yaml + asserts: + - hasDocuments: + count: 0 + - it: is created when enabled + set: + restic.enabled: true + values: + - base-values.yaml + asserts: + - isKind: + of: DaemonSet diff --git a/charts/velero/values.yaml b/charts/velero/values.yaml index 5ad6c918..1eaac795 100644 --- a/charts/velero/values.yaml +++ b/charts/velero/values.yaml @@ -236,10 +236,9 @@ backupsEnabled: true # Whether to create volumesnapshotlocation crd, if false => disable snapshot feature snapshotsEnabled: true -# Whether to deploy the restic daemonset. -deployRestic: false - restic: + # Whether to deploy the restic daemonset. + enabled: false podVolumePath: /var/lib/kubelet/pods privileged: false # Pod priority class name to use for the Restic daemonset. Optional. From e4921e11ce7dbc1c45b182b68b46c7f1b016b1e7 Mon Sep 17 00:00:00 2001 From: "W. Kavanaugh Latiolais" Date: Sun, 30 Aug 2020 11:11:04 -0500 Subject: [PATCH 16/22] Adding snapshots before refactoring configuration out Signed-off-by: W. Kavanaugh Latiolais --- .../__snapshot__/snapshot__test.yaml.snap | 166 ++++++++++++++++++ charts/velero/tests/snapshot__test.yaml | 13 ++ 2 files changed, 179 insertions(+) create mode 100644 charts/velero/tests/__snapshot__/snapshot__test.yaml.snap create mode 100644 charts/velero/tests/snapshot__test.yaml diff --git a/charts/velero/tests/__snapshot__/snapshot__test.yaml.snap b/charts/velero/tests/__snapshot__/snapshot__test.yaml.snap new file mode 100644 index 00000000..71ec75d1 --- /dev/null +++ b/charts/velero/tests/__snapshot__/snapshot__test.yaml.snap @@ -0,0 +1,166 @@ +manifest should match snapshot: + 1: | + apiVersion: apps/v1 + kind: Deployment + metadata: + labels: + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Tiller + app.kubernetes.io/name: velero + helm.sh/chart: velero-3.0.0-alpha.1 + name: RELEASE-NAME-velero + spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/name: velero + template: + metadata: + annotations: + prometheus.io/path: /metrics + prometheus.io/port: "8085" + prometheus.io/scrape: "true" + labels: + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Tiller + app.kubernetes.io/name: velero + helm.sh/chart: velero-3.0.0-alpha.1 + name: velero + spec: + containers: + - args: + - server + command: + - /velero + env: + - name: VELERO_SCRATCH_DIR + value: /scratch + - name: VELERO_NAMESPACE + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.namespace + - name: LD_LIBRARY_PATH + value: /plugins + image: velero/velero:v1.4.2 + imagePullPolicy: IfNotPresent + name: velero + ports: + - containerPort: 8085 + name: monitoring + volumeMounts: + - mountPath: /plugins + name: plugins + initContainers: + - image: velero/velero-plugin-for-aws:v1.1.0 + imagePullPolicy: IfNotPresent + name: velero-plugin-for-aws + volumeMounts: + - mountPath: /target + name: plugins + restartPolicy: Always + serviceAccountName: velero + volumes: + - emptyDir: {} + name: plugins + - emptyDir: {} + name: scratch + 2: | + apiVersion: velero.io/v1 + kind: BackupStorageLocation + metadata: + annotations: + helm.sh/hook: post-install,post-upgrade + helm.sh/hook-delete-policy: before-hook-creation + labels: + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Tiller + app.kubernetes.io/name: velero + helm.sh/chart: velero-3.0.0-alpha.1 + name: default + spec: + config: + profile: test + region: us-west-1 + objectStorage: + bucket: velero + provider: aws + 3: | + apiVersion: apps/v1 + kind: DaemonSet + metadata: + labels: + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Tiller + app.kubernetes.io/name: velero + helm.sh/chart: velero-3.0.0-alpha.1 + name: restic + spec: + selector: + matchLabels: + name: restic + template: + metadata: + labels: + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Tiller + app.kubernetes.io/name: velero + helm.sh/chart: velero-3.0.0-alpha.1 + name: restic + spec: + containers: + - args: + - restic + - server + command: + - /velero + env: + - name: VELERO_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + - name: VELERO_SCRATCH_DIR + value: /scratch + image: velero/velero:v1.4.2 + imagePullPolicy: IfNotPresent + name: restic + securityContext: + privileged: false + volumeMounts: + - mountPath: /host_pods + mountPropagation: HostToContainer + name: host-pods + - mountPath: /scratch + name: scratch + securityContext: + runAsUser: 0 + serviceAccountName: velero + volumes: + - hostPath: + path: /var/lib/kubelet/pods + name: host-pods + - emptyDir: {} + name: scratch + 4: | + apiVersion: velero.io/v1 + kind: VolumeSnapshotLocation + metadata: + annotations: + helm.sh/hook: post-install,post-upgrade + helm.sh/hook-delete-policy: before-hook-creation + labels: + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Tiller + app.kubernetes.io/name: velero + helm.sh/chart: velero-3.0.0-alpha.1 + name: default + spec: + config: + bucket: velero + region: us-west-1 + provider: aws diff --git a/charts/velero/tests/snapshot__test.yaml b/charts/velero/tests/snapshot__test.yaml new file mode 100644 index 00000000..80f5b00d --- /dev/null +++ b/charts/velero/tests/snapshot__test.yaml @@ -0,0 +1,13 @@ +templates: + - deployment.yaml + - backupstoragelocation.yaml + - restic-daemonset.yaml + - volumesnapshotlocation.yaml +tests: + - it: manifest should match snapshot + values: + - ../ci/test-values.yaml + set: + restic.enabled: true + asserts: + - matchSnapshot: {} From 379b4a1b98bb3563309250c68ce8d31f84abf257 Mon Sep 17 00:00:00 2001 From: "W. Kavanaugh Latiolais" Date: Sun, 30 Aug 2020 11:38:52 -0500 Subject: [PATCH 17/22] Removing configuration key Signed-off-by: W. Kavanaugh Latiolais --- charts/velero/README.md | 28 ++-- charts/velero/ci/test-values.yaml | 19 +-- charts/velero/templates/_helpers.tpl | 8 +- .../templates/backupstoragelocation.yaml | 2 +- charts/velero/templates/deployment.yaml | 8 +- charts/velero/templates/restic-daemonset.yaml | 8 +- .../templates/volumesnapshotlocation.yaml | 2 +- charts/velero/tests/base-values.yaml | 3 +- .../tests/deployment_initContainers_test.yaml | 11 +- charts/velero/values.yaml | 155 +++++++++--------- 10 files changed, 120 insertions(+), 124 deletions(-) diff --git a/charts/velero/README.md b/charts/velero/README.md index a0b4ce76..9d6a0afe 100644 --- a/charts/velero/README.md +++ b/charts/velero/README.md @@ -37,12 +37,12 @@ Specify the necessary values using the --set key=value[,key=value] argument to h ```bash helm install vmware-tanzu/velero --namespace \ --set-file credentials.secretContents.cloud= \ ---set configuration.provider= \ ---set configuration.backupStorageLocation.name= \ ---set configuration.backupStorageLocation.bucket= \ ---set configuration.backupStorageLocation.config.region= \ ---set configuration.volumeSnapshotLocation.name= \ ---set configuration.volumeSnapshotLocation.config.region= \ +--set provider= \ +--set backupStorageLocation.name= \ +--set backupStorageLocation.bucket= \ +--set backupStorageLocation.config.region= \ +--set volumeSnapshotLocation.name= \ +--set volumeSnapshotLocation.config.region= \ --set image.repository=velero/velero \ --set image.tag=v1.4.2 \ --set image.pullPolicy=IfNotPresent \ @@ -61,7 +61,7 @@ helm install vmware-tanzu/velero --namespace -f values.yaml --g If a value needs to be added or changed, you may do so with the `upgrade` command. An example: ```bash -helm upgrade vmware-tanzu/velero --namespace --reuse-values --set configuration.provider= +helm upgrade vmware-tanzu/velero --namespace --reuse-values --set provider= ``` #### Using Helm 2 @@ -85,12 +85,12 @@ Specify the necessary values using the --set key=value[,key=value] argument to h ```bash helm install vmware-tanzu/velero --namespace \ --set-file credentials.secretContents.cloud= \ ---set configuration.provider=aws \ ---set configuration.backupStorageLocation.name= \ ---set configuration.backupStorageLocation.bucket= \ ---set configuration.backupStorageLocation.config.region= \ ---set configuration.volumeSnapshotLocation.name= \ ---set configuration.volumeSnapshotLocation.config.region= \ +--set provider=aws \ +--set backupStorageLocation.name= \ +--set backupStorageLocation.bucket= \ +--set backupStorageLocation.config.region= \ +--set volumeSnapshotLocation.name= \ +--set volumeSnapshotLocation.config.region= \ --set image.repository=velero/velero \ --set image.tag=v1.4.2 \ --set image.pullPolicy=IfNotPresent @@ -109,7 +109,7 @@ helm install vmware-tanzu/velero --namespace -f values.yaml If a value needs to be added or changed, you may do so with the `upgrade` command. An example: ```bash -helm upgrade vmware-tanzu/velero --reuse-values --set configuration.provider= +helm upgrade vmware-tanzu/velero --reuse-values --set provider= ``` ## Upgrading diff --git a/charts/velero/ci/test-values.yaml b/charts/velero/ci/test-values.yaml index 0ae3469f..217439e3 100644 --- a/charts/velero/ci/test-values.yaml +++ b/charts/velero/ci/test-values.yaml @@ -1,18 +1,17 @@ installCRDs: true # Set provider name and backup storage location bucket name -configuration: +provider: aws +backupStorageLocation: + bucket: velero + config: + region: us-west-1 + profile: test +volumeSnapshotLocation: provider: aws - backupStorageLocation: + config: bucket: velero - config: - region: us-west-1 - profile: test - volumeSnapshotLocation: - provider: aws - config: - bucket: velero - region: us-west-1 + region: us-west-1 # Set a service account so that the CRD clean up job has proper permissions to delete CRDs serviceAccount: diff --git a/charts/velero/templates/_helpers.tpl b/charts/velero/templates/_helpers.tpl index 6b88d012..d251f49e 100644 --- a/charts/velero/templates/_helpers.tpl +++ b/charts/velero/templates/_helpers.tpl @@ -79,7 +79,7 @@ Create the Restic priority class name. Create the backup storage location name */}} {{- define "velero.backupStorageLocation.name" -}} -{{- with .Values.configuration.backupStorageLocation -}} +{{- with .Values.backupStorageLocation -}} {{ default "default" .name }} {{- end -}} {{- end -}} @@ -88,7 +88,7 @@ Create the backup storage location name Create the backup storage location provider */}} {{- define "velero.backupStorageLocation.provider" -}} -{{- with .Values.configuration -}} +{{- with .Values -}} {{ default .provider .backupStorageLocation.provider }} {{- end -}} {{- end -}} @@ -97,7 +97,7 @@ Create the backup storage location provider Create the volume snapshot location name */}} {{- define "velero.volumeSnapshotLocation.name" -}} -{{- with .Values.configuration.volumeSnapshotLocation -}} +{{- with .Values.volumeSnapshotLocation -}} {{ default "default" .name }} {{- end -}} {{- end -}} @@ -106,7 +106,7 @@ Create the volume snapshot location name Create the volume snapshot location provider */}} {{- define "velero.volumeSnapshotLocation.provider" -}} -{{- with .Values.configuration -}} +{{- with .Values -}} {{ default .provider .volumeSnapshotLocation.provider }} {{- end -}} {{- end -}} diff --git a/charts/velero/templates/backupstoragelocation.yaml b/charts/velero/templates/backupstoragelocation.yaml index 789168b9..b4a4ab24 100644 --- a/charts/velero/templates/backupstoragelocation.yaml +++ b/charts/velero/templates/backupstoragelocation.yaml @@ -13,7 +13,7 @@ metadata: helm.sh/chart: {{ include "velero.chart" . }} spec: provider: {{ include "velero.backupStorageLocation.provider" . }} -{{- with .Values.configuration.backupStorageLocation }} +{{- with .Values.backupStorageLocation }} objectStorage: bucket: {{ .bucket }} {{- with .prefix }} diff --git a/charts/velero/templates/deployment.yaml b/charts/velero/templates/deployment.yaml index aa6dac67..8cb1dfb0 100644 --- a/charts/velero/templates/deployment.yaml +++ b/charts/velero/templates/deployment.yaml @@ -1,5 +1,5 @@ -{{- if .Values.configuration.provider -}} -{{- $providers := list .Values.configuration.provider .Values.configuration.backupStorageLocation.provider .Values.configuration.volumeSnapshotLocation.provider | compact | uniq -}} +{{- if .Values.provider -}} +{{- $providers := list .Values.provider .Values.backupStorageLocation.provider .Values.volumeSnapshotLocation.provider | compact | uniq -}} {{- $provider := first $providers -}} {{- $useSecret := or .Values.credentials.existingSecret (or .Values.credentials.secretContents .Values.credentials.extraEnvVars) -}} apiVersion: apps/v1 @@ -56,7 +56,7 @@ spec: - /velero args: - server - {{- with .Values.configuration }} + {{- with .Values }} {{- with .backupSyncPeriod }} - --backup-sync-period={{ . }} {{- end }} @@ -120,7 +120,7 @@ spec: value: /credentials/cloud {{- end }} {{- end }} - {{- with .Values.configuration.extraEnvVars }} + {{- with .Values.extraEnvVars }} {{- range $key, $value := . }} - name: {{ default "none" $key | quote }} value: {{ default "none" $value | quote }} diff --git a/charts/velero/templates/restic-daemonset.yaml b/charts/velero/templates/restic-daemonset.yaml index 9e4c8c2a..980e5396 100644 --- a/charts/velero/templates/restic-daemonset.yaml +++ b/charts/velero/templates/restic-daemonset.yaml @@ -1,5 +1,5 @@ {{- if .Values.restic.enabled }} -{{- $provider := .Values.configuration.provider -}} +{{- $provider := .Values.provider -}} {{- $useSecret := or .Values.credentials.existingSecret (or .Values.credentials.secretContents .Values.credentials.extraEnvVars) -}} apiVersion: apps/v1 kind: DaemonSet @@ -63,7 +63,7 @@ spec: args: - restic - server - {{- with .Values.configuration }} + {{- with .Values }} {{- with .features }} - --features={{ . }} {{- end }} @@ -88,7 +88,7 @@ spec: {{- toYaml .Values.restic.extraVolumeMounts | nindent 12 }} {{- end }} env: - {{- with .Values.configuration.extraEnvVars }} + {{- with .Values.extraEnvVars }} {{- range $key, $value := . }} - name: {{ default "none" $key | quote }} value: {{ default "none" $value | quote }} @@ -119,7 +119,7 @@ spec: value: /credentials/cloud {{- end }} {{- end }} - {{- with .Values.configuration.extraEnvVars }} + {{- with .Values.extraEnvVars }} {{- range $key, $value := . }} - name: {{ default "none" $key | quote }} value: {{ default "none" $value | quote }} diff --git a/charts/velero/templates/volumesnapshotlocation.yaml b/charts/velero/templates/volumesnapshotlocation.yaml index 96fdd7fc..6e5a0d16 100644 --- a/charts/velero/templates/volumesnapshotlocation.yaml +++ b/charts/velero/templates/volumesnapshotlocation.yaml @@ -13,7 +13,7 @@ metadata: helm.sh/chart: {{ include "velero.chart" . }} spec: provider: {{ include "velero.volumeSnapshotLocation.provider" . }} -{{- with .Values.configuration.volumeSnapshotLocation.config }} +{{- with .Values.volumeSnapshotLocation.config }} config: {{ toYaml . | indent 4 }} {{- end -}} diff --git a/charts/velero/tests/base-values.yaml b/charts/velero/tests/base-values.yaml index c5a2f8fc..ab820498 100644 --- a/charts/velero/tests/base-values.yaml +++ b/charts/velero/tests/base-values.yaml @@ -1,5 +1,4 @@ -configuration: - provider: gcp +provider: gcp schedules: - name: mybackup schedule: "0 0 * * *" diff --git a/charts/velero/tests/deployment_initContainers_test.yaml b/charts/velero/tests/deployment_initContainers_test.yaml index 24cdda06..78948602 100644 --- a/charts/velero/tests/deployment_initContainers_test.yaml +++ b/charts/velero/tests/deployment_initContainers_test.yaml @@ -24,12 +24,11 @@ tests: name: test - it: installs plugins initContainers for the various provider values set: - configuration: - provider: aws - backupStorageLocation: - provider: azure - volumeSnapshotLocation: - provider: alibabacloud + provider: aws + backupStorageLocation: + provider: azure + volumeSnapshotLocation: + provider: alibabacloud values: - base-values.yaml asserts: diff --git a/charts/velero/values.yaml b/charts/velero/values.yaml index 1eaac795..e243ceb4 100644 --- a/charts/velero/values.yaml +++ b/charts/velero/values.yaml @@ -109,85 +109,84 @@ installCRDs: true ## Parameters for the `default` BackupStorageLocation and VolumeSnapshotLocation, ## and additional server settings. ## -configuration: - # Cloud provider being used (e.g. aws, azure, gcp). +# Cloud provider being used (e.g. aws, azure, gcp). +provider: + +# Parameters for the `default` BackupStorageLocation. See +# https://velero.io/docs/v1.4/api-types/backupstoragelocation/ +backupStorageLocation: + # name is the name of the backup storage location where backups should be stored. If a name is not provided, + # a backup storage location will be created with the name "default". Optional. + name: + # provider is the name for the backup storage location provider. If omitted + # `provider` will be used instead. provider: - - # Parameters for the `default` BackupStorageLocation. See - # https://velero.io/docs/v1.4/api-types/backupstoragelocation/ - backupStorageLocation: - # name is the name of the backup storage location where backups should be stored. If a name is not provided, - # a backup storage location will be created with the name "default". Optional. - name: - # provider is the name for the backup storage location provider. If omitted - # `configuration.provider` will be used instead. - provider: - # bucket is the name of the bucket to store backups in. Required. - bucket: - # caCert defines a base64 encoded CA bundle to use when verifying TLS connections to the provider. - caCert: - # prefix is the directory under which all Velero data should be stored within the bucket. Optional. - prefix: - # Additional provider-specific configuration. See link above - # for details of required/optional fields for your provider. - config: {} - # region: - # s3ForcePathStyle: - # s3Url: - # kmsKeyId: - # resourceGroup: - # The ID of the subscription containing the storage account, if different from the cluster’s subscription. (Azure only) - # subscriptionId: - # storageAccount: - # publicUrl: - # Name of the GCP service account to use for this backup storage location. Specify the - # service account here if you want to use workload identity instead of providing the key file.(GCP only) - # serviceAccount: - - # Parameters for the `default` VolumeSnapshotLocation. See - # https://velero.io/docs/v1.4/api-types/volumesnapshotlocation/ - volumeSnapshotLocation: - # name is the name of the volume snapshot location where snapshots are being taken. Required. - name: - # provider is the name for the volume snapshot provider. If omitted - # `configuration.provider` will be used instead. - provider: - # Additional provider-specific configuration. See link above - # for details of required/optional fields for your provider. - config: {} - # region: - # apitimeout: - # resourceGroup: - # The ID of the subscription where volume snapshots should be stored, if different from the cluster’s subscription. If specified, also requires `configuration.volumeSnapshotLocation.config.resourceGroup`to be set. (Azure only) - # subscriptionId: - # snapshotLocation: - # project: - - # These are server-level settings passed as CLI flags to the `velero server` command. Velero - # uses default values if they're not passed in, so they only need to be explicitly specified - # here if using a non-default value. The `velero server` default values are shown in the - # comments below. - # -------------------- - # `velero server` default: 1m - backupSyncPeriod: - # `velero server` default: 1h - resticTimeout: - # `velero server` default: namespaces,persistentvolumes,persistentvolumeclaims,secrets,configmaps,serviceaccounts,limitranges,pods - restoreResourcePriorities: - # `velero server` default: false - restoreOnlyMode: - - # additional key/value pairs to be used as environment variables such as "AWS_CLUSTER_NAME: 'yourcluster.domain.tld'" - extraEnvVars: {} - - # Comma separated list of velero feature flags. default: empty - features: - - # Set log-level for Velero pod. Default: info. Other options: debug, warning, error, fatal, panic. - logLevel: - - # Set log-format for Velero pod. Default: text. Other option: json. - logFormat: + # bucket is the name of the bucket to store backups in. Required. + bucket: + # caCert defines a base64 encoded CA bundle to use when verifying TLS connections to the provider. + caCert: + # prefix is the directory under which all Velero data should be stored within the bucket. Optional. + prefix: + # Additional provider-specific configuration. See link above + # for details of required/optional fields for your provider. + config: {} + # region: + # s3ForcePathStyle: + # s3Url: + # kmsKeyId: + # resourceGroup: + # The ID of the subscription containing the storage account, if different from the cluster’s subscription. (Azure only) + # subscriptionId: + # storageAccount: + # publicUrl: + # Name of the GCP service account to use for this backup storage location. Specify the + # service account here if you want to use workload identity instead of providing the key file.(GCP only) + # serviceAccount: + +# Parameters for the `default` VolumeSnapshotLocation. See +# https://velero.io/docs/v1.4/api-types/volumesnapshotlocation/ +volumeSnapshotLocation: + # name is the name of the volume snapshot location where snapshots are being taken. Required. + name: + # provider is the name for the volume snapshot provider. If omitted + # `configuration.provider` will be used instead. + provider: + # Additional provider-specific configuration. See link above + # for details of required/optional fields for your provider. + config: {} +# region: +# apitimeout: +# resourceGroup: +# The ID of the subscription where volume snapshots should be stored, if different from the cluster’s subscription. If specified, also requires `volumeSnapshotLocation.config.resourceGroup`to be set. (Azure only) +# subscriptionId: +# snapshotLocation: +# project: + +# These are server-level settings passed as CLI flags to the `velero server` command. Velero +# uses default values if they're not passed in, so they only need to be explicitly specified +# here if using a non-default value. The `velero server` default values are shown in the +# comments below. +# -------------------- +# `velero server` default: 1m +backupSyncPeriod: +# `velero server` default: 1h +resticTimeout: +# `velero server` default: namespaces,persistentvolumes,persistentvolumeclaims,secrets,configmaps,serviceaccounts,limitranges,pods +restoreResourcePriorities: +# `velero server` default: false +restoreOnlyMode: + +# additional key/value pairs to be used as environment variables such as "AWS_CLUSTER_NAME: 'yourcluster.domain.tld'" +extraEnvVars: {} + +# Comma separated list of velero feature flags. default: empty +features: + +# Set log-level for Velero pod. Default: info. Other options: debug, warning, error, fatal, panic. +logLevel: + +# Set log-format for Velero pod. Default: text. Other option: json. +logFormat: ## ## End of backup/snapshot location settings. From 6b5e7d1abf061cfea319fa21caaa84c2565a5b53 Mon Sep 17 00:00:00 2001 From: "W. Kavanaugh Latiolais" Date: Fri, 23 Oct 2020 19:39:59 -0500 Subject: [PATCH 18/22] Adding backcompat Signed-off-by: W. Kavanaugh Latiolais --- charts/velero/Chart.yaml | 2 +- charts/velero/templates/_helpers.tpl | 16 ++++------------ .../templates/backupstoragelocation.yaml | 2 +- charts/velero/templates/deployment.yaml | 18 +++++++++--------- charts/velero/templates/restic-daemonset.yaml | 12 ++++++------ .../templates/volumesnapshotlocation.yaml | 2 +- .../__snapshot__/snapshot__test.yaml.snap | 12 ++++++------ charts/velero/tests/restic-daemonset_test.yaml | 8 ++++++++ charts/velero/values.yaml | 5 +++++ 9 files changed, 41 insertions(+), 36 deletions(-) diff --git a/charts/velero/Chart.yaml b/charts/velero/Chart.yaml index 4d35b6cc..8504e350 100644 --- a/charts/velero/Chart.yaml +++ b/charts/velero/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v1 appVersion: 1.4.2 description: A Helm chart for velero name: velero -version: 3.0.0-alpha.1 +version: 2.14.0 home: https://github.com/vmware-tanzu/velero icon: https://cdn-images-1.medium.com/max/1600/1*-9mb3AKnKdcL_QD3CMnthQ.png sources: diff --git a/charts/velero/templates/_helpers.tpl b/charts/velero/templates/_helpers.tpl index d251f49e..1a22057b 100644 --- a/charts/velero/templates/_helpers.tpl +++ b/charts/velero/templates/_helpers.tpl @@ -79,36 +79,28 @@ Create the Restic priority class name. Create the backup storage location name */}} {{- define "velero.backupStorageLocation.name" -}} -{{- with .Values.backupStorageLocation -}} -{{ default "default" .name }} -{{- end -}} +{{ coalesce .Values.backupStorageLocation.name .Values.configuration.backupStorageLocation.name "default" }} {{- end -}} {{/* Create the backup storage location provider */}} {{- define "velero.backupStorageLocation.provider" -}} -{{- with .Values -}} -{{ default .provider .backupStorageLocation.provider }} -{{- end -}} +{{ coalesce .Values.backupStorageLocation.provider .Values.configuration.backupStorageLocation.provider .Values.provider }} {{- end -}} {{/* Create the volume snapshot location name */}} {{- define "velero.volumeSnapshotLocation.name" -}} -{{- with .Values.volumeSnapshotLocation -}} -{{ default "default" .name }} -{{- end -}} +{{ coalesce .Values.volumeSnapshotLocation.name .Values.configuration.volumeSnapshotLocation.name "default" }} {{- end -}} {{/* Create the volume snapshot location provider */}} {{- define "velero.volumeSnapshotLocation.provider" -}} -{{- with .Values -}} -{{ default .provider .volumeSnapshotLocation.provider }} -{{- end -}} +{{ coalesce .Values.volumeSnapshotLocation.provider .Values.configuration.volumeSnapshotLocation.provider .Values.provider}} {{- end -}} {{- define "velero.image-from-values" -}} diff --git a/charts/velero/templates/backupstoragelocation.yaml b/charts/velero/templates/backupstoragelocation.yaml index b4a4ab24..6fd14d91 100644 --- a/charts/velero/templates/backupstoragelocation.yaml +++ b/charts/velero/templates/backupstoragelocation.yaml @@ -13,7 +13,7 @@ metadata: helm.sh/chart: {{ include "velero.chart" . }} spec: provider: {{ include "velero.backupStorageLocation.provider" . }} -{{- with .Values.backupStorageLocation }} +{{- with coalesce .Values.backupStorageLocation .Values.configuration.backupStorageLocation }} objectStorage: bucket: {{ .bucket }} {{- with .prefix }} diff --git a/charts/velero/templates/deployment.yaml b/charts/velero/templates/deployment.yaml index 8cb1dfb0..9d8747a2 100644 --- a/charts/velero/templates/deployment.yaml +++ b/charts/velero/templates/deployment.yaml @@ -1,5 +1,5 @@ {{- if .Values.provider -}} -{{- $providers := list .Values.provider .Values.backupStorageLocation.provider .Values.volumeSnapshotLocation.provider | compact | uniq -}} +{{- $providers := list .Values.provider .Values.backupStorageLocation.provider .Values.volumeSnapshotLocation.provider .Values.configuration.backupStorageLocation.provider .Values.configuration.volumeSnapshotLocation.provider | compact | uniq -}} {{- $provider := first $providers -}} {{- $useSecret := or .Values.credentials.existingSecret (or .Values.credentials.secretContents .Values.credentials.extraEnvVars) -}} apiVersion: apps/v1 @@ -57,25 +57,25 @@ spec: args: - server {{- with .Values }} - {{- with .backupSyncPeriod }} + {{- with coalesce .backupSyncPeriod .configuration.backupSyncPeriod }} - --backup-sync-period={{ . }} {{- end }} - {{- with .resticTimeout }} + {{- with coalesce .resticTimeout .configuration.resticTimeout }} - --restic-timeout={{ . }} {{- end }} - {{- if .restoreOnlyMode }} + {{- if coalesce .restoreOnlyMode .configuration.restoreOnlyMode }} - --restore-only {{- end }} - {{- with .restoreResourcePriorities }} + {{- with coalesce .restoreResourcePriorities .configuration.restoreResourcePriorities }} - --restore-resource-priorities={{ . }} {{- end }} - {{- with .features }} + {{- with coalesce .features .configuration.features }} - --features={{ . }} {{- end }} - {{- with .logLevel }} + {{- with coalesce .configuration.logLevel }} - --log-level={{ . }} {{- end }} - {{- with .logFormat }} + {{- with coalesce .configuration.logFormat }} - --log-format={{ . }} {{- end }} {{- end }} @@ -120,7 +120,7 @@ spec: value: /credentials/cloud {{- end }} {{- end }} - {{- with .Values.extraEnvVars }} + {{- with coalesce .Values.extraEnvVars .Values.configuration.extraEnvVars }} {{- range $key, $value := . }} - name: {{ default "none" $key | quote }} value: {{ default "none" $value | quote }} diff --git a/charts/velero/templates/restic-daemonset.yaml b/charts/velero/templates/restic-daemonset.yaml index 980e5396..5ed94a4e 100644 --- a/charts/velero/templates/restic-daemonset.yaml +++ b/charts/velero/templates/restic-daemonset.yaml @@ -1,4 +1,4 @@ -{{- if .Values.restic.enabled }} +{{- if or .Values.deployRestic .Values.restic.enabled }} {{- $provider := .Values.provider -}} {{- $useSecret := or .Values.credentials.existingSecret (or .Values.credentials.secretContents .Values.credentials.extraEnvVars) -}} apiVersion: apps/v1 @@ -64,13 +64,13 @@ spec: - restic - server {{- with .Values }} - {{- with .features }} + {{- with coalesce .features .configuration.features }} - --features={{ . }} {{- end }} - {{- with .logLevel }} + {{- with coalesce .logLevel .configuration.logLevel }} - --log-level={{ . }} {{- end }} - {{- with .logFormat }} + {{- with coalesce .logFormat .configuration.logFormat }} - --log-format={{ . }} {{- end }} {{- end }} @@ -88,7 +88,7 @@ spec: {{- toYaml .Values.restic.extraVolumeMounts | nindent 12 }} {{- end }} env: - {{- with .Values.extraEnvVars }} + {{- with coalesce .Values.extraEnvVars .Values.configuration.extraEnvVars }} {{- range $key, $value := . }} - name: {{ default "none" $key | quote }} value: {{ default "none" $value | quote }} @@ -119,7 +119,7 @@ spec: value: /credentials/cloud {{- end }} {{- end }} - {{- with .Values.extraEnvVars }} + {{- with coalesce .Values.extraEnvVars .Values.configuration.extraEnvVars }} {{- range $key, $value := . }} - name: {{ default "none" $key | quote }} value: {{ default "none" $value | quote }} diff --git a/charts/velero/templates/volumesnapshotlocation.yaml b/charts/velero/templates/volumesnapshotlocation.yaml index 6e5a0d16..2b9455eb 100644 --- a/charts/velero/templates/volumesnapshotlocation.yaml +++ b/charts/velero/templates/volumesnapshotlocation.yaml @@ -13,7 +13,7 @@ metadata: helm.sh/chart: {{ include "velero.chart" . }} spec: provider: {{ include "velero.volumeSnapshotLocation.provider" . }} -{{- with .Values.volumeSnapshotLocation.config }} +{{- with coalesce .Values.volumeSnapshotLocation.config .Values.configuration.volumeSnapshotLocation.config }} config: {{ toYaml . | indent 4 }} {{- end -}} diff --git a/charts/velero/tests/__snapshot__/snapshot__test.yaml.snap b/charts/velero/tests/__snapshot__/snapshot__test.yaml.snap index 71ec75d1..78c6524d 100644 --- a/charts/velero/tests/__snapshot__/snapshot__test.yaml.snap +++ b/charts/velero/tests/__snapshot__/snapshot__test.yaml.snap @@ -7,7 +7,7 @@ manifest should match snapshot: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Tiller app.kubernetes.io/name: velero - helm.sh/chart: velero-3.0.0-alpha.1 + helm.sh/chart: velero-2.14.0 name: RELEASE-NAME-velero spec: replicas: 1 @@ -25,7 +25,7 @@ manifest should match snapshot: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Tiller app.kubernetes.io/name: velero - helm.sh/chart: velero-3.0.0-alpha.1 + helm.sh/chart: velero-2.14.0 name: velero spec: containers: @@ -77,7 +77,7 @@ manifest should match snapshot: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Tiller app.kubernetes.io/name: velero - helm.sh/chart: velero-3.0.0-alpha.1 + helm.sh/chart: velero-2.14.0 name: default spec: config: @@ -94,7 +94,7 @@ manifest should match snapshot: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Tiller app.kubernetes.io/name: velero - helm.sh/chart: velero-3.0.0-alpha.1 + helm.sh/chart: velero-2.14.0 name: restic spec: selector: @@ -106,7 +106,7 @@ manifest should match snapshot: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Tiller app.kubernetes.io/name: velero - helm.sh/chart: velero-3.0.0-alpha.1 + helm.sh/chart: velero-2.14.0 name: restic spec: containers: @@ -157,7 +157,7 @@ manifest should match snapshot: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Tiller app.kubernetes.io/name: velero - helm.sh/chart: velero-3.0.0-alpha.1 + helm.sh/chart: velero-2.14.0 name: default spec: config: diff --git a/charts/velero/tests/restic-daemonset_test.yaml b/charts/velero/tests/restic-daemonset_test.yaml index 19894618..01ab8ece 100644 --- a/charts/velero/tests/restic-daemonset_test.yaml +++ b/charts/velero/tests/restic-daemonset_test.yaml @@ -16,3 +16,11 @@ tests: asserts: - isKind: of: DaemonSet + - it: is created when enabled (legacy) + set: + deployRestic: true + values: + - base-values.yaml + asserts: + - isKind: + of: DaemonSet diff --git a/charts/velero/values.yaml b/charts/velero/values.yaml index e243ceb4..896a429c 100644 --- a/charts/velero/values.yaml +++ b/charts/velero/values.yaml @@ -286,3 +286,8 @@ configMaps: {} ## ## End of additional Velero resource settings. ## + +# Depricated configuration key +configuration: + backupStorageLocation: {} + volumeSnapshotLocation: {} From 4d2343dc109c955ef419acddbdbfce49fb204476 Mon Sep 17 00:00:00 2001 From: "W. Kavanaugh Latiolais" Date: Sat, 24 Oct 2020 12:38:41 -0500 Subject: [PATCH 19/22] WIP: Adding backcompat testing Signed-off-by: W. Kavanaugh Latiolais --- README.md | 2 +- charts/velero/ci/test-values-back-compat.yaml | 26 +++ charts/velero/templates/_helpers.tpl | 8 +- .../templates/backupstoragelocation.yaml | 2 +- charts/velero/templates/deployment.yaml | 18 +- charts/velero/templates/restic-daemonset.yaml | 10 +- .../templates/volumesnapshotlocation.yaml | 2 +- .../back-compat-snapshot_test.yaml.snap | 166 ++++++++++++++++++ .../tests/back-compat-snapshot_test.yaml | 13 ++ 9 files changed, 226 insertions(+), 21 deletions(-) create mode 100644 charts/velero/ci/test-values-back-compat.yaml create mode 100644 charts/velero/tests/__snapshot__/back-compat-snapshot_test.yaml.snap create mode 100644 charts/velero/tests/back-compat-snapshot_test.yaml diff --git a/README.md b/README.md index dcdb4c84..3fd8b763 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ To run unit tests in this repository please install helm-unittest ```sh helm plugin install https://github.com/quintush/helm-unittest -helm unittest -3 charts/velero +helm unittest charts/velero ``` ## License diff --git a/charts/velero/ci/test-values-back-compat.yaml b/charts/velero/ci/test-values-back-compat.yaml new file mode 100644 index 00000000..0ae3469f --- /dev/null +++ b/charts/velero/ci/test-values-back-compat.yaml @@ -0,0 +1,26 @@ +installCRDs: true + +# Set provider name and backup storage location bucket name +configuration: + provider: aws + backupStorageLocation: + bucket: velero + config: + region: us-west-1 + profile: test + volumeSnapshotLocation: + provider: aws + config: + bucket: velero + region: us-west-1 + +# Set a service account so that the CRD clean up job has proper permissions to delete CRDs +serviceAccount: + server: + name: velero + +# Whether or not to clean up CustomResourceDefintions when deleting a release. +# Cleaning up CRDs will delete the BackupStorageLocation and VolumeSnapshotLocation instances, which would have to be reconfigured. +# Backup data in object storage will _not_ be deleted, however Backup instances in the Kubernetes API will. +# Always clean up CRDs in CI. +cleanUpCRDs: true diff --git a/charts/velero/templates/_helpers.tpl b/charts/velero/templates/_helpers.tpl index 1a22057b..fd43cbcc 100644 --- a/charts/velero/templates/_helpers.tpl +++ b/charts/velero/templates/_helpers.tpl @@ -79,28 +79,28 @@ Create the Restic priority class name. Create the backup storage location name */}} {{- define "velero.backupStorageLocation.name" -}} -{{ coalesce .Values.backupStorageLocation.name .Values.configuration.backupStorageLocation.name "default" }} +{{ coalesce .Values.configuration.backupStorageLocation.name .Values.backupStorageLocation.name "default" }} {{- end -}} {{/* Create the backup storage location provider */}} {{- define "velero.backupStorageLocation.provider" -}} -{{ coalesce .Values.backupStorageLocation.provider .Values.configuration.backupStorageLocation.provider .Values.provider }} +{{ coalesce .Values.configuration.backupStorageLocation.provider .Values.backupStorageLocation.provider .Values.configuration.provider .Values.provider }} {{- end -}} {{/* Create the volume snapshot location name */}} {{- define "velero.volumeSnapshotLocation.name" -}} -{{ coalesce .Values.volumeSnapshotLocation.name .Values.configuration.volumeSnapshotLocation.name "default" }} +{{ coalesce .Values.configuration.volumeSnapshotLocation.name .Values.volumeSnapshotLocation.name "default" }} {{- end -}} {{/* Create the volume snapshot location provider */}} {{- define "velero.volumeSnapshotLocation.provider" -}} -{{ coalesce .Values.volumeSnapshotLocation.provider .Values.configuration.volumeSnapshotLocation.provider .Values.provider}} +{{ coalesce .Values.configuration.volumeSnapshotLocation.provider .Values.volumeSnapshotLocation.provider .Values.configuration.provider .Values.provider}} {{- end -}} {{- define "velero.image-from-values" -}} diff --git a/charts/velero/templates/backupstoragelocation.yaml b/charts/velero/templates/backupstoragelocation.yaml index 6fd14d91..9d968486 100644 --- a/charts/velero/templates/backupstoragelocation.yaml +++ b/charts/velero/templates/backupstoragelocation.yaml @@ -13,7 +13,7 @@ metadata: helm.sh/chart: {{ include "velero.chart" . }} spec: provider: {{ include "velero.backupStorageLocation.provider" . }} -{{- with coalesce .Values.backupStorageLocation .Values.configuration.backupStorageLocation }} +{{- with coalesce .Values.configuration.backupStorageLocation .Values.backupStorageLocation }} objectStorage: bucket: {{ .bucket }} {{- with .prefix }} diff --git a/charts/velero/templates/deployment.yaml b/charts/velero/templates/deployment.yaml index 9d8747a2..60da605e 100644 --- a/charts/velero/templates/deployment.yaml +++ b/charts/velero/templates/deployment.yaml @@ -1,4 +1,4 @@ -{{- if .Values.provider -}} +{{- if or .Values.provider .Values.configuration.provider -}} {{- $providers := list .Values.provider .Values.backupStorageLocation.provider .Values.volumeSnapshotLocation.provider .Values.configuration.backupStorageLocation.provider .Values.configuration.volumeSnapshotLocation.provider | compact | uniq -}} {{- $provider := first $providers -}} {{- $useSecret := or .Values.credentials.existingSecret (or .Values.credentials.secretContents .Values.credentials.extraEnvVars) -}} @@ -57,25 +57,25 @@ spec: args: - server {{- with .Values }} - {{- with coalesce .backupSyncPeriod .configuration.backupSyncPeriod }} + {{- with coalesce .configuration.backupSyncPeriod .backupSyncPeriod }} - --backup-sync-period={{ . }} {{- end }} - {{- with coalesce .resticTimeout .configuration.resticTimeout }} + {{- with coalesce .configuration.resticTimeout .resticTimeout}} - --restic-timeout={{ . }} {{- end }} - {{- if coalesce .restoreOnlyMode .configuration.restoreOnlyMode }} + {{- if coalesce .configuration.restoreOnlyMode .restoreOnlyMode}} - --restore-only {{- end }} - {{- with coalesce .restoreResourcePriorities .configuration.restoreResourcePriorities }} + {{- with coalesce .configuration.restoreResourcePriorities .restoreResourcePriorities }} - --restore-resource-priorities={{ . }} {{- end }} - {{- with coalesce .features .configuration.features }} + {{- with coalesce .configuration.features .features }} - --features={{ . }} {{- end }} - {{- with coalesce .configuration.logLevel }} + {{- with coalesce .configuration.logLevel .logLevel }} - --log-level={{ . }} {{- end }} - {{- with coalesce .configuration.logFormat }} + {{- with coalesce .configuration.logFormat .logFormat }} - --log-format={{ . }} {{- end }} {{- end }} @@ -120,7 +120,7 @@ spec: value: /credentials/cloud {{- end }} {{- end }} - {{- with coalesce .Values.extraEnvVars .Values.configuration.extraEnvVars }} + {{- with coalesce .Values.configuration.extraEnvVars .Values.extraEnvVars }} {{- range $key, $value := . }} - name: {{ default "none" $key | quote }} value: {{ default "none" $value | quote }} diff --git a/charts/velero/templates/restic-daemonset.yaml b/charts/velero/templates/restic-daemonset.yaml index 5ed94a4e..8de90a32 100644 --- a/charts/velero/templates/restic-daemonset.yaml +++ b/charts/velero/templates/restic-daemonset.yaml @@ -64,13 +64,13 @@ spec: - restic - server {{- with .Values }} - {{- with coalesce .features .configuration.features }} + {{- with coalesce .configuration.features .features }} - --features={{ . }} {{- end }} - {{- with coalesce .logLevel .configuration.logLevel }} + {{- with coalesce .configuration.logLevel .logLevel }} - --log-level={{ . }} {{- end }} - {{- with coalesce .logFormat .configuration.logFormat }} + {{- with coalesce .configuration.logFormat .logFormat }} - --log-format={{ . }} {{- end }} {{- end }} @@ -88,7 +88,7 @@ spec: {{- toYaml .Values.restic.extraVolumeMounts | nindent 12 }} {{- end }} env: - {{- with coalesce .Values.extraEnvVars .Values.configuration.extraEnvVars }} + {{- with coalesce .Values.configuration.extraEnvVars .Values.extraEnvVars }} {{- range $key, $value := . }} - name: {{ default "none" $key | quote }} value: {{ default "none" $value | quote }} @@ -119,7 +119,7 @@ spec: value: /credentials/cloud {{- end }} {{- end }} - {{- with coalesce .Values.extraEnvVars .Values.configuration.extraEnvVars }} + {{- with coalesce .Values.configuration.extraEnvVars .Values.extraEnvVars }} {{- range $key, $value := . }} - name: {{ default "none" $key | quote }} value: {{ default "none" $value | quote }} diff --git a/charts/velero/templates/volumesnapshotlocation.yaml b/charts/velero/templates/volumesnapshotlocation.yaml index 2b9455eb..489603bb 100644 --- a/charts/velero/templates/volumesnapshotlocation.yaml +++ b/charts/velero/templates/volumesnapshotlocation.yaml @@ -13,7 +13,7 @@ metadata: helm.sh/chart: {{ include "velero.chart" . }} spec: provider: {{ include "velero.volumeSnapshotLocation.provider" . }} -{{- with coalesce .Values.volumeSnapshotLocation.config .Values.configuration.volumeSnapshotLocation.config }} +{{- with coalesce .Values.configuration.volumeSnapshotLocation.config .Values.volumeSnapshotLocation.config }} config: {{ toYaml . | indent 4 }} {{- end -}} diff --git a/charts/velero/tests/__snapshot__/back-compat-snapshot_test.yaml.snap b/charts/velero/tests/__snapshot__/back-compat-snapshot_test.yaml.snap new file mode 100644 index 00000000..78c6524d --- /dev/null +++ b/charts/velero/tests/__snapshot__/back-compat-snapshot_test.yaml.snap @@ -0,0 +1,166 @@ +manifest should match snapshot: + 1: | + apiVersion: apps/v1 + kind: Deployment + metadata: + labels: + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Tiller + app.kubernetes.io/name: velero + helm.sh/chart: velero-2.14.0 + name: RELEASE-NAME-velero + spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/name: velero + template: + metadata: + annotations: + prometheus.io/path: /metrics + prometheus.io/port: "8085" + prometheus.io/scrape: "true" + labels: + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Tiller + app.kubernetes.io/name: velero + helm.sh/chart: velero-2.14.0 + name: velero + spec: + containers: + - args: + - server + command: + - /velero + env: + - name: VELERO_SCRATCH_DIR + value: /scratch + - name: VELERO_NAMESPACE + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.namespace + - name: LD_LIBRARY_PATH + value: /plugins + image: velero/velero:v1.4.2 + imagePullPolicy: IfNotPresent + name: velero + ports: + - containerPort: 8085 + name: monitoring + volumeMounts: + - mountPath: /plugins + name: plugins + initContainers: + - image: velero/velero-plugin-for-aws:v1.1.0 + imagePullPolicy: IfNotPresent + name: velero-plugin-for-aws + volumeMounts: + - mountPath: /target + name: plugins + restartPolicy: Always + serviceAccountName: velero + volumes: + - emptyDir: {} + name: plugins + - emptyDir: {} + name: scratch + 2: | + apiVersion: velero.io/v1 + kind: BackupStorageLocation + metadata: + annotations: + helm.sh/hook: post-install,post-upgrade + helm.sh/hook-delete-policy: before-hook-creation + labels: + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Tiller + app.kubernetes.io/name: velero + helm.sh/chart: velero-2.14.0 + name: default + spec: + config: + profile: test + region: us-west-1 + objectStorage: + bucket: velero + provider: aws + 3: | + apiVersion: apps/v1 + kind: DaemonSet + metadata: + labels: + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Tiller + app.kubernetes.io/name: velero + helm.sh/chart: velero-2.14.0 + name: restic + spec: + selector: + matchLabels: + name: restic + template: + metadata: + labels: + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Tiller + app.kubernetes.io/name: velero + helm.sh/chart: velero-2.14.0 + name: restic + spec: + containers: + - args: + - restic + - server + command: + - /velero + env: + - name: VELERO_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + - name: VELERO_SCRATCH_DIR + value: /scratch + image: velero/velero:v1.4.2 + imagePullPolicy: IfNotPresent + name: restic + securityContext: + privileged: false + volumeMounts: + - mountPath: /host_pods + mountPropagation: HostToContainer + name: host-pods + - mountPath: /scratch + name: scratch + securityContext: + runAsUser: 0 + serviceAccountName: velero + volumes: + - hostPath: + path: /var/lib/kubelet/pods + name: host-pods + - emptyDir: {} + name: scratch + 4: | + apiVersion: velero.io/v1 + kind: VolumeSnapshotLocation + metadata: + annotations: + helm.sh/hook: post-install,post-upgrade + helm.sh/hook-delete-policy: before-hook-creation + labels: + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Tiller + app.kubernetes.io/name: velero + helm.sh/chart: velero-2.14.0 + name: default + spec: + config: + bucket: velero + region: us-west-1 + provider: aws diff --git a/charts/velero/tests/back-compat-snapshot_test.yaml b/charts/velero/tests/back-compat-snapshot_test.yaml new file mode 100644 index 00000000..3d052433 --- /dev/null +++ b/charts/velero/tests/back-compat-snapshot_test.yaml @@ -0,0 +1,13 @@ +templates: + - deployment.yaml + - backupstoragelocation.yaml + - restic-daemonset.yaml + - volumesnapshotlocation.yaml +tests: + - it: manifest should match snapshot + values: + - ../ci/test-values-back-compat.yaml + set: + restic.enabled: true + asserts: + - matchSnapshot: {} From 26d1a8a81101bec36904b2e5fa62cf8395d27eb6 Mon Sep 17 00:00:00 2001 From: "W. Kavanaugh Latiolais" Date: Mon, 26 Oct 2020 12:49:10 -0600 Subject: [PATCH 20/22] Back compat for schedules. A touch less graceful than I'd like but it does work. Signed-off-by: W. Kavanaugh Latiolais --- charts/velero/ci/test-values-back-compat.yaml | 7 ++++ charts/velero/ci/test-values.yaml | 7 ++++ charts/velero/templates/schedule.yaml | 34 +++++++++++++++++-- .../back-compat-snapshot_test.yaml.snap | 19 +++++++++++ .../__snapshot__/snapshot__test.yaml.snap | 19 +++++++++++ .../tests/back-compat-snapshot_test.yaml | 1 + charts/velero/tests/snapshot__test.yaml | 1 + charts/velero/values.yaml | 6 ++-- 8 files changed, 89 insertions(+), 5 deletions(-) diff --git a/charts/velero/ci/test-values-back-compat.yaml b/charts/velero/ci/test-values-back-compat.yaml index 0ae3469f..0e990ac8 100644 --- a/charts/velero/ci/test-values-back-compat.yaml +++ b/charts/velero/ci/test-values-back-compat.yaml @@ -19,6 +19,13 @@ serviceAccount: server: name: velero +schedules: + mybackup: + schedule: "0 0 * * *" + template: + ttl: "240h" + includedNamespaces: + - foo # Whether or not to clean up CustomResourceDefintions when deleting a release. # Cleaning up CRDs will delete the BackupStorageLocation and VolumeSnapshotLocation instances, which would have to be reconfigured. # Backup data in object storage will _not_ be deleted, however Backup instances in the Kubernetes API will. diff --git a/charts/velero/ci/test-values.yaml b/charts/velero/ci/test-values.yaml index 217439e3..7aee081d 100644 --- a/charts/velero/ci/test-values.yaml +++ b/charts/velero/ci/test-values.yaml @@ -18,6 +18,13 @@ serviceAccount: server: name: velero +schedules: + - name: mybackup + schedule: "0 0 * * *" + template: + ttl: "240h" + includedNamespaces: + - foo # Whether or not to clean up CustomResourceDefintions when deleting a release. # Cleaning up CRDs will delete the BackupStorageLocation and VolumeSnapshotLocation instances, which would have to be reconfigured. # Backup data in object storage will _not_ be deleted, however Backup instances in the Kubernetes API will. diff --git a/charts/velero/templates/schedule.yaml b/charts/velero/templates/schedule.yaml index f4cc7456..039adf1b 100644 --- a/charts/velero/templates/schedule.yaml +++ b/charts/velero/templates/schedule.yaml @@ -1,15 +1,19 @@ +{{- if kindIs "slice" .Values.schedules -}} {{- range .Values.schedules }} apiVersion: velero.io/v1 kind: Schedule metadata: name: {{ include "velero.fullname" $ }}-{{ .name }} + annotations: + "helm.sh/hook": post-install,post-upgrade + "helm.sh/hook-delete-policy": "before-hook-creation" labels: app.kubernetes.io/name: {{ include "velero.name" $ }} app.kubernetes.io/instance: {{ $.Release.Name }} app.kubernetes.io/managed-by: {{ $.Release.Service }} helm.sh/chart: {{ include "velero.chart" $ }} - {{- if $.Values.scheduleLabels }} - {{- toYaml $.Values.scheduleLabels | nindent 4 }} + {{- if .labels }} + {{- toYaml .labels | nindent 4 }} {{- end }} spec: schedule: {{ .schedule | quote }} @@ -18,4 +22,30 @@ spec: {{- toYaml . | nindent 4 }} {{- end }} --- +{{- end -}} +{{- else -}} +{{- range $scheduleName, $schedule := .Values.schedules }} +apiVersion: velero.io/v1 +kind: Schedule +metadata: + name: {{ include "velero.fullname" $ }}-{{ $scheduleName }} + annotations: + "helm.sh/hook": post-install,post-upgrade + "helm.sh/hook-delete-policy": "before-hook-creation" + labels: + app.kubernetes.io/name: {{ include "velero.name" $ }} + app.kubernetes.io/instance: {{ $.Release.Name }} + app.kubernetes.io/managed-by: {{ $.Release.Service }} + helm.sh/chart: {{ include "velero.chart" $ }} + {{- if $schedule.labels }} + {{- toYaml $schedule.labels | nindent 4 }} + {{- end }} +spec: + schedule: {{ $schedule.schedule | quote }} +{{- with $schedule.template }} + template: + {{- toYaml . | nindent 4 }} +{{- end }} +--- {{- end }} +{{- end -}} diff --git a/charts/velero/tests/__snapshot__/back-compat-snapshot_test.yaml.snap b/charts/velero/tests/__snapshot__/back-compat-snapshot_test.yaml.snap index 78c6524d..ae67f8c5 100644 --- a/charts/velero/tests/__snapshot__/back-compat-snapshot_test.yaml.snap +++ b/charts/velero/tests/__snapshot__/back-compat-snapshot_test.yaml.snap @@ -164,3 +164,22 @@ manifest should match snapshot: bucket: velero region: us-west-1 provider: aws + 5: | + apiVersion: velero.io/v1 + kind: Schedule + metadata: + annotations: + helm.sh/hook: post-install,post-upgrade + helm.sh/hook-delete-policy: before-hook-creation + labels: + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Tiller + app.kubernetes.io/name: velero + helm.sh/chart: velero-2.14.0 + name: RELEASE-NAME-velero-mybackup + spec: + schedule: 0 0 * * * + template: + includedNamespaces: + - foo + ttl: 240h diff --git a/charts/velero/tests/__snapshot__/snapshot__test.yaml.snap b/charts/velero/tests/__snapshot__/snapshot__test.yaml.snap index 78c6524d..ae67f8c5 100644 --- a/charts/velero/tests/__snapshot__/snapshot__test.yaml.snap +++ b/charts/velero/tests/__snapshot__/snapshot__test.yaml.snap @@ -164,3 +164,22 @@ manifest should match snapshot: bucket: velero region: us-west-1 provider: aws + 5: | + apiVersion: velero.io/v1 + kind: Schedule + metadata: + annotations: + helm.sh/hook: post-install,post-upgrade + helm.sh/hook-delete-policy: before-hook-creation + labels: + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Tiller + app.kubernetes.io/name: velero + helm.sh/chart: velero-2.14.0 + name: RELEASE-NAME-velero-mybackup + spec: + schedule: 0 0 * * * + template: + includedNamespaces: + - foo + ttl: 240h diff --git a/charts/velero/tests/back-compat-snapshot_test.yaml b/charts/velero/tests/back-compat-snapshot_test.yaml index 3d052433..a8ed8f6f 100644 --- a/charts/velero/tests/back-compat-snapshot_test.yaml +++ b/charts/velero/tests/back-compat-snapshot_test.yaml @@ -3,6 +3,7 @@ templates: - backupstoragelocation.yaml - restic-daemonset.yaml - volumesnapshotlocation.yaml + - schedule.yaml tests: - it: manifest should match snapshot values: diff --git a/charts/velero/tests/snapshot__test.yaml b/charts/velero/tests/snapshot__test.yaml index 80f5b00d..b62f4683 100644 --- a/charts/velero/tests/snapshot__test.yaml +++ b/charts/velero/tests/snapshot__test.yaml @@ -3,6 +3,7 @@ templates: - backupstoragelocation.yaml - restic-daemonset.yaml - volumesnapshotlocation.yaml + - schedule.yaml tests: - it: manifest should match snapshot values: diff --git a/charts/velero/values.yaml b/charts/velero/values.yaml index 896a429c..4918a88a 100644 --- a/charts/velero/values.yaml +++ b/charts/velero/values.yaml @@ -262,13 +262,13 @@ restic: # Backup schedules to create. # Eg: # schedules: -# name: mybackup +# - name: mybackup # schedule: "0 0 * * *" # template: # ttl: "240h" # includedNamespaces: # - foo -schedules: [] +# schedules: [] scheduleLabels: {} @@ -287,7 +287,7 @@ configMaps: {} ## End of additional Velero resource settings. ## -# Depricated configuration key +# Deprecated configuration: backupStorageLocation: {} volumeSnapshotLocation: {} From d8d1ee109d8f209655638c5bf6c0ab5e0dfd4b08 Mon Sep 17 00:00:00 2001 From: "W. Kavanaugh Latiolais" Date: Tue, 27 Oct 2020 20:30:24 -0600 Subject: [PATCH 21/22] linting Signed-off-by: W. Kavanaugh Latiolais --- charts/velero/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/velero/Chart.yaml b/charts/velero/Chart.yaml index 97767edb..a2a8f3ec 100644 --- a/charts/velero/Chart.yaml +++ b/charts/velero/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v1 appVersion: 1.5.2 description: A Helm chart for velero name: velero -version: 2.14.0 +version: 2.14.0 home: https://github.com/vmware-tanzu/velero icon: https://cdn-images-1.medium.com/max/1600/1*-9mb3AKnKdcL_QD3CMnthQ.png sources: From 9dc8a2232650cf7278cf739cc8e22eb509bbefc8 Mon Sep 17 00:00:00 2001 From: "W. Kavanaugh Latiolais" Date: Tue, 27 Oct 2020 20:33:41 -0600 Subject: [PATCH 22/22] Updating tests and snapshots post main merge Signed-off-by: W. Kavanaugh Latiolais --- charts/velero/ci/test-values-back-compat.yaml | 5 ++++- charts/velero/ci/test-values.yaml | 13 +++---------- .../back-compat-snapshot_test.yaml.snap | 5 +++-- .../tests/__snapshot__/snapshot__test.yaml.snap | 5 +++-- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/charts/velero/ci/test-values-back-compat.yaml b/charts/velero/ci/test-values-back-compat.yaml index 0e990ac8..6abe09f5 100644 --- a/charts/velero/ci/test-values-back-compat.yaml +++ b/charts/velero/ci/test-values-back-compat.yaml @@ -21,11 +21,14 @@ serviceAccount: schedules: mybackup: + labels: + myenv: foo schedule: "0 0 * * *" template: ttl: "240h" includedNamespaces: - - foo + - foo + # Whether or not to clean up CustomResourceDefintions when deleting a release. # Cleaning up CRDs will delete the BackupStorageLocation and VolumeSnapshotLocation instances, which would have to be reconfigured. # Backup data in object storage will _not_ be deleted, however Backup instances in the Kubernetes API will. diff --git a/charts/velero/ci/test-values.yaml b/charts/velero/ci/test-values.yaml index b6c6a326..fec39364 100644 --- a/charts/velero/ci/test-values.yaml +++ b/charts/velero/ci/test-values.yaml @@ -13,16 +13,6 @@ volumeSnapshotLocation: bucket: velero region: us-west-1 -schedules: - mybackup: - labels: - myenv: foo - schedule: "0 0 * * *" - template: - ttl: "240h" - includedNamespaces: - - foo - # Set a service account so that the CRD clean up job has proper permissions to delete CRDs serviceAccount: server: @@ -30,11 +20,14 @@ serviceAccount: schedules: - name: mybackup + labels: + myenv: foo schedule: "0 0 * * *" template: ttl: "240h" includedNamespaces: - foo + # Whether or not to clean up CustomResourceDefintions when deleting a release. # Cleaning up CRDs will delete the BackupStorageLocation and VolumeSnapshotLocation instances, which would have to be reconfigured. # Backup data in object storage will _not_ be deleted, however Backup instances in the Kubernetes API will. diff --git a/charts/velero/tests/__snapshot__/back-compat-snapshot_test.yaml.snap b/charts/velero/tests/__snapshot__/back-compat-snapshot_test.yaml.snap index ae67f8c5..fc379823 100644 --- a/charts/velero/tests/__snapshot__/back-compat-snapshot_test.yaml.snap +++ b/charts/velero/tests/__snapshot__/back-compat-snapshot_test.yaml.snap @@ -43,7 +43,7 @@ manifest should match snapshot: fieldPath: metadata.namespace - name: LD_LIBRARY_PATH value: /plugins - image: velero/velero:v1.4.2 + image: velero/velero:v1.5.2 imagePullPolicy: IfNotPresent name: velero ports: @@ -126,7 +126,7 @@ manifest should match snapshot: fieldPath: spec.nodeName - name: VELERO_SCRATCH_DIR value: /scratch - image: velero/velero:v1.4.2 + image: velero/velero:v1.5.2 imagePullPolicy: IfNotPresent name: restic securityContext: @@ -176,6 +176,7 @@ manifest should match snapshot: app.kubernetes.io/managed-by: Tiller app.kubernetes.io/name: velero helm.sh/chart: velero-2.14.0 + myenv: foo name: RELEASE-NAME-velero-mybackup spec: schedule: 0 0 * * * diff --git a/charts/velero/tests/__snapshot__/snapshot__test.yaml.snap b/charts/velero/tests/__snapshot__/snapshot__test.yaml.snap index ae67f8c5..fc379823 100644 --- a/charts/velero/tests/__snapshot__/snapshot__test.yaml.snap +++ b/charts/velero/tests/__snapshot__/snapshot__test.yaml.snap @@ -43,7 +43,7 @@ manifest should match snapshot: fieldPath: metadata.namespace - name: LD_LIBRARY_PATH value: /plugins - image: velero/velero:v1.4.2 + image: velero/velero:v1.5.2 imagePullPolicy: IfNotPresent name: velero ports: @@ -126,7 +126,7 @@ manifest should match snapshot: fieldPath: spec.nodeName - name: VELERO_SCRATCH_DIR value: /scratch - image: velero/velero:v1.4.2 + image: velero/velero:v1.5.2 imagePullPolicy: IfNotPresent name: restic securityContext: @@ -176,6 +176,7 @@ manifest should match snapshot: app.kubernetes.io/managed-by: Tiller app.kubernetes.io/name: velero helm.sh/chart: velero-2.14.0 + myenv: foo name: RELEASE-NAME-velero-mybackup spec: schedule: 0 0 * * *