From 2c41e2e12c2734835701cfaa90b1f5049e9a119e Mon Sep 17 00:00:00 2001 From: Tung Bui Date: Thu, 3 Aug 2023 21:27:46 +0700 Subject: [PATCH 1/7] ci: introduce CI workflow to verify the CRD folder Signed-off-by: Tung Bui --- .github/workflows/verify-manifest.yml | 52 +++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/verify-manifest.yml diff --git a/.github/workflows/verify-manifest.yml b/.github/workflows/verify-manifest.yml new file mode 100644 index 00000000..579f89c8 --- /dev/null +++ b/.github/workflows/verify-manifest.yml @@ -0,0 +1,52 @@ +name: Check Velero Manifest + +on: + workflow_dispatch: + +jobs: + check-velero-manifest: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Create kind cluster + uses: helm/kind-action@v1.5.0 + + - name: Install velero + run: | + wget https://github.com/vmware-tanzu/velero/releases/download/v1.11.1/velero-v1.11.1-linux-amd64.tar.gz + tar -xvf velero-v1.11.1-linux-amd64.tar.gz + cd velero-v1.11.1-linux-amd64 + sudo cp velero /usr/local/bin + velero version + + - name: Compare manifests + run: | + cd charts/velero + mkdir diff_workspace + + echo "Generate velero manifest file" + velero install --crds-only --dry-run -o yaml | kubectl apply --dry-run=client -f - -o yaml > diff_workspace/velero_manifest.yaml + echo "Generate crds manifest file" + kubectl apply --dry-run=client -f crds/ -o yaml > diff_workspace/crds_manifest.yaml + + echo "Compare the two files using diff" + difference=$(diff diff_workspace/velero_manifest.yaml diff_workspace/crds_manifest.yaml) || true + if [ -z "$difference" ]; then + echo "Files are synced. No differences found." + else + echo "Differences between velero_manifest.yaml and crds_manifest.yaml:" + echo "$difference" + echo "$difference" > diff_workspace/diff_manifest.txt + exit 1 + fi + + - name: Archive manifests + if: always() + uses: actions/upload-artifact@v3 + with: + name: diff_output + path: | + charts/velero/diff_workspace From ac4be5a7e85fa76a01e0748c1f72f924e97730cd Mon Sep 17 00:00:00 2001 From: Tung Bui Date: Thu, 3 Aug 2023 22:05:08 +0700 Subject: [PATCH 2/7] ci: use verlero version from the charts value Signed-off-by: Tung Bui --- .github/workflows/verify-manifest.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/verify-manifest.yml b/.github/workflows/verify-manifest.yml index 579f89c8..b54e3bd5 100644 --- a/.github/workflows/verify-manifest.yml +++ b/.github/workflows/verify-manifest.yml @@ -16,9 +16,13 @@ jobs: - name: Install velero run: | - wget https://github.com/vmware-tanzu/velero/releases/download/v1.11.1/velero-v1.11.1-linux-amd64.tar.gz - tar -xvf velero-v1.11.1-linux-amd64.tar.gz - cd velero-v1.11.1-linux-amd64 + echo "Determine the velero version" + VERSION=$(yq eval ".image.tag" charts/velero/values.yaml) + + echo "Install velero $VERSION" + wget https://github.com/vmware-tanzu/velero/releases/download/${VERSION}/velero-${VERSION}-linux-amd64.tar.gz + tar -xvf velero-${VERSION}-linux-amd64.tar.gz + cd velero-${VERSION}-linux-amd64 sudo cp velero /usr/local/bin velero version From e63451d2e6d157c300e9997f028f3b6b23244c51 Mon Sep 17 00:00:00 2001 From: ishuar Date: Thu, 3 Aug 2023 17:28:04 +0200 Subject: [PATCH 3/7] add the feature to allow relabeling in servicemonitor Signed-off-by: ishuar Signed-off-by: Tung Bui --- charts/velero/Chart.yaml | 2 +- charts/velero/templates/servicemonitor.yaml | 6 ++++++ charts/velero/values.yaml | 6 ++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/charts/velero/Chart.yaml b/charts/velero/Chart.yaml index 7d721320..93b8d3ac 100644 --- a/charts/velero/Chart.yaml +++ b/charts/velero/Chart.yaml @@ -3,7 +3,7 @@ appVersion: 1.11.1 kubeVersion: ">=1.16.0-0" description: A Helm chart for velero name: velero -version: 4.2.0 +version: 4.3.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/servicemonitor.yaml b/charts/velero/templates/servicemonitor.yaml index e3ccfa40..777ff9f1 100644 --- a/charts/velero/templates/servicemonitor.yaml +++ b/charts/velero/templates/servicemonitor.yaml @@ -33,6 +33,12 @@ spec: {{- if .Values.metrics.serviceMonitor.scheme }} scheme: {{ .Values.metrics.serviceMonitor.scheme }} {{- end }} + {{- if .Values.metrics.serviceMonitor.metricRelabelings }} + metricRelabelings: {{- toYaml .Values.metrics.serviceMonitor.metricRelabelings | nindent 6 }} + {{- end }} + {{- if .Values.metrics.serviceMonitor.relabelings }} + relabelings: {{ toYaml .Values.metrics.serviceMonitor.relabelings | nindent 6 }} + {{- end }} {{- if .Values.metrics.serviceMonitor.tlsConfig }} tlsConfig: {{- toYaml .Values.metrics.serviceMonitor.tlsConfig | nindent 6 }} diff --git a/charts/velero/values.yaml b/charts/velero/values.yaml index 604ae4cf..e1490935 100644 --- a/charts/velero/values.yaml +++ b/charts/velero/values.yaml @@ -182,6 +182,12 @@ metrics: enabled: false annotations: {} additionalLabels: {} + + # metrics.serviceMonitor.metricRelabelings Specify Metric Relabelings to add to the scrape endpoint + # ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#relabelconfig + # metricRelabelings: [] + # metrics.serviceMonitor.relabelings [array] Prometheus relabeling rules + # relabelings: [] # ServiceMonitor namespace. Default to Velero namespace. # namespace: # ServiceMonitor connection scheme. Defaults to HTTP. From beb75a17a3e6dca33941afea056d706bd916026d Mon Sep 17 00:00:00 2001 From: Tung Bui Date: Thu, 3 Aug 2023 23:08:39 +0700 Subject: [PATCH 4/7] ci: enable running on PR and remove archive artifacts step Signed-off-by: Tung Bui --- .github/workflows/verify-manifest.yml | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/.github/workflows/verify-manifest.yml b/.github/workflows/verify-manifest.yml index b54e3bd5..e604641e 100644 --- a/.github/workflows/verify-manifest.yml +++ b/.github/workflows/verify-manifest.yml @@ -1,7 +1,6 @@ name: Check Velero Manifest -on: - workflow_dispatch: +on: pull_request jobs: check-velero-manifest: @@ -43,14 +42,5 @@ jobs: else echo "Differences between velero_manifest.yaml and crds_manifest.yaml:" echo "$difference" - echo "$difference" > diff_workspace/diff_manifest.txt exit 1 fi - - - name: Archive manifests - if: always() - uses: actions/upload-artifact@v3 - with: - name: diff_output - path: | - charts/velero/diff_workspace From 873c9d48b4dcc36d4e2abd719f40706c432afa63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Sun, 6 Aug 2023 16:34:14 +0200 Subject: [PATCH 5/7] Add toggle to disable annotations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan-Otto Kröpke Signed-off-by: Tung Bui --- charts/velero/templates/backupstoragelocation.yaml | 2 ++ charts/velero/templates/schedule.yaml | 2 ++ charts/velero/templates/volumesnapshotlocation.yaml | 2 ++ charts/velero/values.yaml | 4 ++++ 4 files changed, 10 insertions(+) diff --git a/charts/velero/templates/backupstoragelocation.yaml b/charts/velero/templates/backupstoragelocation.yaml index b47a41ad..0e027796 100644 --- a/charts/velero/templates/backupstoragelocation.yaml +++ b/charts/velero/templates/backupstoragelocation.yaml @@ -9,8 +9,10 @@ metadata: name: {{ .name | default "default" }} namespace: {{ $.Release.Namespace }} annotations: + {{- if $.Values.helmHookAnnotations }} "helm.sh/hook": post-install,post-upgrade,post-rollback "helm.sh/hook-delete-policy": before-hook-creation + {{- end }} labels: app.kubernetes.io/name: {{ include "velero.name" $ }} app.kubernetes.io/instance: {{ $.Release.Name }} diff --git a/charts/velero/templates/schedule.yaml b/charts/velero/templates/schedule.yaml index fa3786f4..f7e924a2 100644 --- a/charts/velero/templates/schedule.yaml +++ b/charts/velero/templates/schedule.yaml @@ -9,8 +9,10 @@ metadata: {{- if $schedule.annotations }} {{- toYaml $schedule.annotations | nindent 4 }} {{- end }} + {{- if $.Values.helmHookAnnotations }} "helm.sh/hook": post-install,post-upgrade,post-rollback "helm.sh/hook-delete-policy": before-hook-creation + {{- end }} labels: app.kubernetes.io/name: {{ include "velero.name" $ }} app.kubernetes.io/instance: {{ $.Release.Name }} diff --git a/charts/velero/templates/volumesnapshotlocation.yaml b/charts/velero/templates/volumesnapshotlocation.yaml index 4cd3f3cf..05018f33 100644 --- a/charts/velero/templates/volumesnapshotlocation.yaml +++ b/charts/velero/templates/volumesnapshotlocation.yaml @@ -9,8 +9,10 @@ metadata: name: {{ .name | default "default" }} namespace: {{ $.Release.Namespace }} annotations: + {{- if $.Values.helmHookAnnotations }} "helm.sh/hook": post-install,post-upgrade,post-rollback "helm.sh/hook-delete-policy": before-hook-creation + {{- end }} labels: app.kubernetes.io/name: {{ include "velero.name" $ }} app.kubernetes.io/instance: {{ $.Release.Name }} diff --git a/charts/velero/values.yaml b/charts/velero/values.yaml index e1490935..6de0e457 100644 --- a/charts/velero/values.yaml +++ b/charts/velero/values.yaml @@ -24,6 +24,10 @@ annotations: {} # Labels to add to the Velero deployment's. Optional. labels: {} +# helmHookAnnotations is required to deploy CustomResources after deploying CRDs. If you manage your CRDs outside of this helm chart +# or using ArgoCD, you are able to disable the helm hooks annotations. +helmHookAnnotations: true + # 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 From 3cce89f78b6a9d2e86f8bb5481cd0e6d274a36ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Mon, 7 Aug 2023 08:37:56 +0200 Subject: [PATCH 6/7] bump version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan-Otto Kröpke Signed-off-by: Tung Bui --- 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 93b8d3ac..33c78f37 100644 --- a/charts/velero/Chart.yaml +++ b/charts/velero/Chart.yaml @@ -3,7 +3,7 @@ appVersion: 1.11.1 kubeVersion: ">=1.16.0-0" description: A Helm chart for velero name: velero -version: 4.3.0 +version: 4.4.0 home: https://github.com/vmware-tanzu/velero icon: https://cdn-images-1.medium.com/max/1600/1*-9mb3AKnKdcL_QD3CMnthQ.png sources: From 9eeee06cb93f8c3ca3aa79fb75f6480d20bcf851 Mon Sep 17 00:00:00 2001 From: "Tung Bui (Leo)" <85242618+tungbq@users.noreply.github.com> Date: Tue, 8 Aug 2023 12:00:27 +0700 Subject: [PATCH 7/7] ci: filter non-required values element Signed-off-by: Tung Bui --- .github/workflows/verify-manifest.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/verify-manifest.yml b/.github/workflows/verify-manifest.yml index e604641e..78d49dd0 100644 --- a/.github/workflows/verify-manifest.yml +++ b/.github/workflows/verify-manifest.yml @@ -30,6 +30,11 @@ jobs: cd charts/velero mkdir diff_workspace + echo "Filter non-required values" + for yaml_file in crds/*.yaml; do + yq -i 'del(.status)' "$yaml_file" + done + echo "Generate velero manifest file" velero install --crds-only --dry-run -o yaml | kubectl apply --dry-run=client -f - -o yaml > diff_workspace/velero_manifest.yaml echo "Generate crds manifest file"