From eb9baf2de889f39cb4d103483bfa597563bff240 Mon Sep 17 00:00:00 2001 From: Pieter Date: Thu, 5 Jun 2025 19:41:26 +0200 Subject: [PATCH] Add workflow to validate deployment methods --- .github/workflows/e2e-test.yml | 4 +- .github/workflows/validate-deployments.yaml | 44 +++++++++++++++++++ Makefile | 3 +- README.md | 14 +----- config/default/kustomization.yaml | 1 + config/{ => default}/secret.yaml | 4 +- ...kuttl-test-self-hosted-postgres-helm.yaml} | 1 - ...l-test-self-hosted-postgres-kustomize.yaml | 20 +++++++++ 8 files changed, 74 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/validate-deployments.yaml rename config/{ => default}/secret.yaml (68%) rename tests/{kuttl-test-self-hosted-postgres.yaml => kuttl-test-self-hosted-postgres-helm.yaml} (97%) create mode 100644 tests/kuttl-test-self-hosted-postgres-kustomize.yaml diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index 492f657e..fc45c2ab 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -33,7 +33,9 @@ jobs: - name: Install KUTTL run: kubectl krew install kuttl - name: Run tests - run: kubectl kuttl test --config ./tests/kuttl-test-self-hosted-postgres.yaml + run: | + kubectl kuttl test --config ./tests/kuttl-test-self-hosted-postgres-helm.yaml + kubectl kuttl test --config ./tests/kuttl-test-self-hosted-postgres-kustomize.yaml - name: Upload test artifacts if: always() # Run even if tests fail uses: actions/upload-artifact@v4 diff --git a/.github/workflows/validate-deployments.yaml b/.github/workflows/validate-deployments.yaml new file mode 100644 index 00000000..6555a838 --- /dev/null +++ b/.github/workflows/validate-deployments.yaml @@ -0,0 +1,44 @@ +name: Validate Deployment methods + +on: + push: + branches: + - master + paths: + - "charts/ext-postgres-operator/**" + - "config/**" + pull_request: + branches: + - master + paths: + - "charts/ext-postgres-operator/**" + - "config/**" + +jobs: + validate-helm: + name: Validate Helm Chart + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Helm + uses: azure/setup-helm@v3 + with: + version: "latest" + + - name: Lint Helm chart + run: helm lint ./charts/ext-postgres-operator + + - name: Template Helm chart + run: helm template ext-postgres-operator ./charts/ext-postgres-operator > /dev/null + + validate-kustomize: + name: Validate Kustomize Configuration + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Validate Kustomize configuration + run: kustomize build ./config/default > /dev/null diff --git a/Makefile b/Makefile index 3561c95c..d609c5c7 100644 --- a/Makefile +++ b/Makefile @@ -305,4 +305,5 @@ catalog-push: ## Push a catalog image. .PHONY: e2e e2e: - kubectl kuttl test --config ./tests/kuttl-test-self-hosted-postgres.yaml + kubectl kuttl test --config ./tests/kuttl-test-self-hosted-postgres-helm.yaml + kubectl kuttl test --config ./tests/kuttl-test-self-hosted-postgres-kustomize.yaml diff --git a/README.md b/README.md index e580268a..a2413834 100644 --- a/README.md +++ b/README.md @@ -118,19 +118,9 @@ data: To install the operator using Kustomize, follow these steps: -1. Configure Postgres credentials for the operator in `config/secret.yaml`. +1. Configure Postgres credentials for the operator in `config/default/secret.yaml`. -2. Create the namespace if needed: - ```bash - kubectl apply -f config/namespace.yaml - ``` - -3. Apply the secret: - ```bash - kubectl apply -f deploy/secret.yaml - ``` - -4. Deploy the operator: +2. Deploy the operator: ```bash kubectl kustomize config/default/ | kubectl apply -f - ``` diff --git a/config/default/kustomization.yaml b/config/default/kustomization.yaml index cd836034..776f2c8c 100644 --- a/config/default/kustomization.yaml +++ b/config/default/kustomization.yaml @@ -2,6 +2,7 @@ namespace: operators resources: - namespace.yaml + - secret.yaml - ../crd - ../rbac - ../manager diff --git a/config/secret.yaml b/config/default/secret.yaml similarity index 68% rename from config/secret.yaml rename to config/default/secret.yaml index 090c3e78..6d1d33b5 100644 --- a/config/secret.yaml +++ b/config/default/secret.yaml @@ -4,7 +4,7 @@ metadata: name: ext-postgres-operator type: Opaque data: - POSTGRES_HOST: cG9zdGdyZXMuZGF0YWJhc2Vz + POSTGRES_HOST: cG9zdGdyZXNxbA== POSTGRES_USER: cG9zdGdyZXM= - POSTGRES_PASS: YWRtaW4xMjM= + POSTGRES_PASS: cG9zdGdyZXM= POSTGRES_URI_ARGS: c3NsbW9kZT1kaXNhYmxl diff --git a/tests/kuttl-test-self-hosted-postgres.yaml b/tests/kuttl-test-self-hosted-postgres-helm.yaml similarity index 97% rename from tests/kuttl-test-self-hosted-postgres.yaml rename to tests/kuttl-test-self-hosted-postgres-helm.yaml index a6d088af..997f4e3b 100644 --- a/tests/kuttl-test-self-hosted-postgres.yaml +++ b/tests/kuttl-test-self-hosted-postgres-helm.yaml @@ -2,7 +2,6 @@ apiVersion: kuttl.dev/v1beta1 kind: TestSuite testDirs: - ./tests/e2e/ -# crdDir: ./deploy/crds/ startKIND: true kindContext: self-hosted-postgres kindContainers: diff --git a/tests/kuttl-test-self-hosted-postgres-kustomize.yaml b/tests/kuttl-test-self-hosted-postgres-kustomize.yaml new file mode 100644 index 00000000..d525ddac --- /dev/null +++ b/tests/kuttl-test-self-hosted-postgres-kustomize.yaml @@ -0,0 +1,20 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestSuite +testDirs: + - ./tests/e2e/ +startKIND: true +kindContext: self-hosted-postgres +kindContainers: + - postgres-operator:build +artifactsDir: ./tests/ +commands: + - command: >- + helm install -n operators postgresql oci://registry-1.docker.io/bitnamicharts/postgresql + --version 16.6.0 + --set global.postgresql.auth.password=postgres + --set global.postgresql.auth.username=postgres + --create-namespace + --wait + timeout: 120 + - command: >- + kubectl apply -n operators -k config/default/