From 256de94546f18140171b999c91edd25d81f910da Mon Sep 17 00:00:00 2001 From: Renato Monteiro <45536168+monteiro-renato@users.noreply.github.com> Date: Sun, 24 Nov 2024 10:31:39 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20(helm/v1alpha1):=20instal?= =?UTF-8?q?l=20the=20prometheus-operator=20CRDs=20before=20installing=20a?= =?UTF-8?q?=20chart=20which=20configures=20a=20ServiceMonitor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/test-helm-samples.yml | 22 ++++++++++++++----- .../internal/templates/github/test_chart.go | 13 ++++++++++- .../.github/workflows/test-chart.yml | 13 ++++++++++- 3 files changed, 40 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test-helm-samples.yml b/.github/workflows/test-helm-samples.yml index 1fc31a21393..3c468c46c79 100644 --- a/.github/workflows/test-helm-samples.yml +++ b/.github/workflows/test-helm-samples.yml @@ -3,12 +3,12 @@ name: Helm Testdata Sample on: push: paths: - - 'testdata/project-v4-with-plugins/**' - - '.github/workflows/test-helm-samples.yml' + - "testdata/project-v4-with-plugins/**" + - ".github/workflows/test-helm-samples.yml" pull_request: paths: - - 'testdata/project-v4-with-plugins/**' - - '.github/workflows/test-helm-samples.yml' + - "testdata/project-v4-with-plugins/**" + - ".github/workflows/test-helm-samples.yml" jobs: helm-test-project-v4-with-plugins: @@ -23,7 +23,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '~1.22' + go-version: "~1.22" - name: Install the latest version of kind run: | @@ -55,6 +55,12 @@ jobs: run: | helm lint testdata/project-v4-with-plugins/dist/chart + - name: Install Prometheus Operator CRDs + run: | + helm repo add prometheus-community https://prometheus-community.github.io/helm-charts + helm repo update + helm install prometheus-crds prometheus-community/prometheus-operator-crds + - name: Install cert-manager via Helm run: | helm repo add jetstack https://charts.jetstack.io @@ -69,8 +75,12 @@ jobs: - name: Install Helm chart for project-v4-with-plugins run: | - helm install my-release testdata/project-v4-with-plugins/dist/chart --create-namespace --namespace project-v4-with-plugins-system + helm install my-release testdata/project-v4-with-plugins/dist/chart --create-namespace --namespace project-v4-with-plugins-system --set prometheus.enable=true - name: Check Helm release status run: | helm status my-release --namespace project-v4-with-plugins-system + + - name: Check Presence of ServiceMonitor + run: | + kubectl wait --namespace project-v4-with-plugins-system --for=jsonpath='{.kind}'=ServiceMonitor servicemonitor/project-v4-with-plugins-controller-manager-metrics-monitor diff --git a/pkg/plugins/optional/helm/v1alpha/scaffolds/internal/templates/github/test_chart.go b/pkg/plugins/optional/helm/v1alpha/scaffolds/internal/templates/github/test_chart.go index 6a5ac396edb..27e67118f55 100644 --- a/pkg/plugins/optional/helm/v1alpha/scaffolds/internal/templates/github/test_chart.go +++ b/pkg/plugins/optional/helm/v1alpha/scaffolds/internal/templates/github/test_chart.go @@ -83,7 +83,7 @@ jobs: - name: Install Helm run: | - curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash + curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash - name: Verify Helm installation run: helm version @@ -106,6 +106,12 @@ jobs: # kubectl wait --namespace cert-manager --for=condition=available --timeout=300s deployment/cert-manager-webhook # TODO: Uncomment if Prometheus is enabled +# - name: Install Prometheus Operator CRDs +# run: | +# helm repo add prometheus-community https://prometheus-community.github.io/helm-charts +# helm repo update +# helm install prometheus-crds prometheus-community/prometheus-operator-crds +# # - name: Install Prometheus via Helm # run: | # helm repo add prometheus-community https://prometheus-community.github.io/helm-charts @@ -123,4 +129,9 @@ jobs: - name: Check Helm release status run: | helm status my-release --namespace {{ .ProjectName }}-system + +# TODO: Uncomment if prometheus.enabled is set to true to confirm that the ServiceMonitor gets created +# - name: Check Presence of ServiceMonitor +# run: | +# kubectl wait --namespace {{ .ProjectName }}-system --for=jsonpath='{.kind}'=ServiceMonitor servicemonitor/{{ .ProjectName }}-controller-manager-metrics-monitor ` diff --git a/testdata/project-v4-with-plugins/.github/workflows/test-chart.yml b/testdata/project-v4-with-plugins/.github/workflows/test-chart.yml index f36c83b93a4..bae16f7a169 100644 --- a/testdata/project-v4-with-plugins/.github/workflows/test-chart.yml +++ b/testdata/project-v4-with-plugins/.github/workflows/test-chart.yml @@ -37,7 +37,7 @@ jobs: - name: Install Helm run: | - curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash + curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash - name: Verify Helm installation run: helm version @@ -60,6 +60,12 @@ jobs: # kubectl wait --namespace cert-manager --for=condition=available --timeout=300s deployment/cert-manager-webhook # TODO: Uncomment if Prometheus is enabled +# - name: Install Prometheus Operator CRDs +# run: | +# helm repo add prometheus-community https://prometheus-community.github.io/helm-charts +# helm repo update +# helm install prometheus-crds prometheus-community/prometheus-operator-crds +# # - name: Install Prometheus via Helm # run: | # helm repo add prometheus-community https://prometheus-community.github.io/helm-charts @@ -77,3 +83,8 @@ jobs: - name: Check Helm release status run: | helm status my-release --namespace project-v4-with-plugins-system + +# TODO: Uncomment if prometheus.enabled is set to true to confirm that the ServiceMonitor gets created +# - name: Check Presence of ServiceMonitor +# run: | +# kubectl wait --namespace project-v4-with-plugins-system --for=jsonpath='{.kind}'=ServiceMonitor servicemonitor/project-v4-with-plugins-controller-manager-metrics-monitor