From 862142e5c45cff5df47c40a3898a6b5f67db0b18 Mon Sep 17 00:00:00 2001 From: Aditya Thebe Date: Wed, 3 Apr 2024 17:10:08 +0545 Subject: [PATCH] fix: kubernetes resource fixture to test ingress --- fixtures/k8s/kubernetes_resource.yaml | 37 ++++++++++++++++++++++++++- fixtures/k8s/kustomization.yaml | 1 + test/e2e.sh | 3 +++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/fixtures/k8s/kubernetes_resource.yaml b/fixtures/k8s/kubernetes_resource.yaml index 83986ab4a..9a896f540 100644 --- a/fixtures/k8s/kubernetes_resource.yaml +++ b/fixtures/k8s/kubernetes_resource.yaml @@ -11,9 +11,27 @@ spec: kubernetesResource: - name: ingress-accessibility-check namespace: default - description: "deploy an nginx pod" + description: "deploy an nginx pod & check that it's accessible via ingress" waitForReady: true timeout: 10m + staticResources: + - apiVersion: networking.k8s.io/v1 + kind: Ingress + metadata: + name: nginx-pod-ingress + namespace: default + spec: + rules: + - host: nginx.test.flanksource.com + http: + paths: + - pathType: Prefix + path: / + backend: + service: + name: nginx + port: + number: 80 resources: - apiVersion: v1 kind: Pod @@ -26,3 +44,20 @@ spec: image: nginx:1.24.0-alpine-slim ports: - containerPort: 80 + - apiVersion: v1 + kind: Service + metadata: + name: nginx + namespace: default + spec: + selector: + name: nginx-pod + ports: + - port: 80 + targetPort: 80 + checks: + - http: + url: "nginx.default.svc.cluster.local" + headers: + host: "{{(index (index .staticResources 0).spec.rules 0).host}}" + diff --git a/fixtures/k8s/kustomization.yaml b/fixtures/k8s/kustomization.yaml index 6669086ee..d757f301c 100644 --- a/fixtures/k8s/kustomization.yaml +++ b/fixtures/k8s/kustomization.yaml @@ -9,3 +9,4 @@ resources: - pod_fail.yaml - pod_pass.yaml - kubernetes_bundle.yaml + - kuberenetes_resource.yaml diff --git a/test/e2e.sh b/test/e2e.sh index 933428737..6f454a710 100755 --- a/test/e2e.sh +++ b/test/e2e.sh @@ -86,6 +86,9 @@ if [ "$SKIP_SETUP" != "true" ]; then echo "::endgroup::" fi +# Just testing TODO: remove this +kubectl get svc -A + image=ubuntu if [[ -e $TEST_FOLDER/_image ]]; then