From ab135a4f318c56133cb50356b8f42d1cda35c67f Mon Sep 17 00:00:00 2001 From: Thomas Vitale Date: Mon, 17 Jun 2024 22:15:58 +0200 Subject: [PATCH] test: Test integration with cert-manager --- test/integration/cert-manager/00-assert.yaml | 21 +++++++++++++++++++ test/integration/cert-manager/00-install.yaml | 8 +++++++ .../cert-manager/01-application.yaml | 6 ++++++ test/integration/cert-manager/01-assert.yaml | 6 ++++++ .../cert-manager/02-uninstall.yaml | 9 ++++++++ .../cert-manager/config/overlay.yml | 9 ++++++++ .../cert-manager/config/values.yml | 13 ++++++++++++ test/integration/kuttl-test.yml | 12 +++++++++++ test/integration/nodeport/02-uninstall.yaml | 1 + test/setup/dependencies/cert-manager.yml | 15 +++++++++++++ 10 files changed, 100 insertions(+) create mode 100644 test/integration/cert-manager/00-assert.yaml create mode 100644 test/integration/cert-manager/00-install.yaml create mode 100644 test/integration/cert-manager/01-application.yaml create mode 100644 test/integration/cert-manager/01-assert.yaml create mode 100644 test/integration/cert-manager/02-uninstall.yaml create mode 100644 test/integration/cert-manager/config/overlay.yml create mode 100644 test/integration/cert-manager/config/values.yml create mode 100644 test/setup/dependencies/cert-manager.yml diff --git a/test/integration/cert-manager/00-assert.yaml b/test/integration/cert-manager/00-assert.yaml new file mode 100644 index 0000000..c373cc9 --- /dev/null +++ b/test/integration/cert-manager/00-assert.yaml @@ -0,0 +1,21 @@ +--- +apiVersion: cert-manager.io/v1 +kind: Certificate +metadata: + name: contour-cert + namespace: projectcontour +status: + conditions: + - status: "True" + type: Ready + +--- +apiVersion: cert-manager.io/v1 +kind: Certificate +metadata: + name: envoy-cert + namespace: projectcontour +status: + conditions: + - status: "True" + type: Ready diff --git a/test/integration/cert-manager/00-install.yaml b/test/integration/cert-manager/00-install.yaml new file mode 100644 index 0000000..5d3a3f9 --- /dev/null +++ b/test/integration/cert-manager/00-install.yaml @@ -0,0 +1,8 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: + - script: | + cd ../../../package && \ + kubectl config set-context --current --namespace=tests && \ + ytt -f ../test/integration/cert-manager/config -f package-resources.yml | kctrl dev -f- --local -y diff --git a/test/integration/cert-manager/01-application.yaml b/test/integration/cert-manager/01-application.yaml new file mode 100644 index 0000000..8256df2 --- /dev/null +++ b/test/integration/cert-manager/01-application.yaml @@ -0,0 +1,6 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: + - script: | + kapp deploy -a kuard -f https://projectcontour.io/examples/kuard.yaml -y diff --git a/test/integration/cert-manager/01-assert.yaml b/test/integration/cert-manager/01-assert.yaml new file mode 100644 index 0000000..128ee9f --- /dev/null +++ b/test/integration/cert-manager/01-assert.yaml @@ -0,0 +1,6 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +commands: + - script: | + curl --fail-with-body localhost:80 diff --git a/test/integration/cert-manager/02-uninstall.yaml b/test/integration/cert-manager/02-uninstall.yaml new file mode 100644 index 0000000..44c7265 --- /dev/null +++ b/test/integration/cert-manager/02-uninstall.yaml @@ -0,0 +1,9 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: + - script: | + kapp delete -a kuard -y + cd ../../../package && \ + kubectl config set-context --current --namespace=tests && \ + ytt -f ../test/integration/cert-manager/config -f package-resources.yml | kctrl dev -f- --local --delete -y diff --git a/test/integration/cert-manager/config/overlay.yml b/test/integration/cert-manager/config/overlay.yml new file mode 100644 index 0000000..1e3b94a --- /dev/null +++ b/test/integration/cert-manager/config/overlay.yml @@ -0,0 +1,9 @@ +#@ load("@ytt:overlay", "overlay") + +#@overlay/match by=overlay.subset({"metadata":{"name":"contour"}, "kind":"PackageInstall"}) +--- +spec: + #@overlay/match missing_ok=True + values: + - secretRef: + name: contour-values diff --git a/test/integration/cert-manager/config/values.yml b/test/integration/cert-manager/config/values.yml new file mode 100644 index 0000000..d167335 --- /dev/null +++ b/test/integration/cert-manager/config/values.yml @@ -0,0 +1,13 @@ +--- +apiVersion: v1 +kind: Secret +metadata: + name: contour-values + namespace: tests +stringData: + values.yaml: | + envoy: + service: + type: NodePort + certificates: + useCertManager: true diff --git a/test/integration/kuttl-test.yml b/test/integration/kuttl-test.yml index 3bd3aa5..898369c 100644 --- a/test/integration/kuttl-test.yml +++ b/test/integration/kuttl-test.yml @@ -10,3 +10,15 @@ kindContext: integration kindNodeCache: true timeout: 120 artifactsDir: /tmp/kuttl-artifacts +commands: + - script: | + kapp deploy -a kapp-controller -y \ + -f https://github.com/carvel-dev/kapp-controller/releases/latest/download/release.yml + - script: | + kubectl config set-context --current --namespace=tests && \ + kapp deploy -a cert-manager-package -y \ + -f https://github.com/kadras-io/package-for-cert-manager/releases/download/v1.15.0%2Bkadras.1/package.yml \ + -f https://github.com/kadras-io/package-for-cert-manager/releases/download/v1.15.0%2Bkadras.1/metadata.yml + - script: | + kubectl config set-context --current --namespace=tests && \ + kapp deploy -a dependencies -y -f ./test/setup/dependencies diff --git a/test/integration/nodeport/02-uninstall.yaml b/test/integration/nodeport/02-uninstall.yaml index e31de73..6473be0 100644 --- a/test/integration/nodeport/02-uninstall.yaml +++ b/test/integration/nodeport/02-uninstall.yaml @@ -3,6 +3,7 @@ apiVersion: kuttl.dev/v1beta1 kind: TestStep commands: - script: | + kapp delete -a kuard -y cd ../../../package && \ kubectl config set-context --current --namespace=tests && \ ytt -f ../test/integration/nodeport/config -f package-resources.yml | kctrl dev -f- --local --delete -y diff --git a/test/setup/dependencies/cert-manager.yml b/test/setup/dependencies/cert-manager.yml new file mode 100644 index 0000000..6abed4d --- /dev/null +++ b/test/setup/dependencies/cert-manager.yml @@ -0,0 +1,15 @@ +--- +apiVersion: packaging.carvel.dev/v1alpha1 +kind: PackageInstall +metadata: + name: cert-manager + namespace: tests + annotations: + kapp.k14s.io/change-group: cert-manager + kapp.k14s.io/change-rule.serviceaccount: delete before deleting serviceaccount +spec: + serviceAccountName: kadras-install-sa + packageRef: + refName: cert-manager.packages.kadras.io + versionSelection: + constraints: 1.15.0+kadras.1