From d144e012087b50fb9170996e9571e5c0d9ab9692 Mon Sep 17 00:00:00 2001 From: Eric Date: Mon, 31 Jan 2022 09:32:44 -0600 Subject: [PATCH] Adding k8s tests --- .../log4shell-goof-server-docker-image.yaml | 23 +++++++++++++++ .../workflows/todolist-goof-docker-image.yaml | 29 ++++++++++++++++--- .../log4shell-server/k8s/deploy.yaml | 1 + 3 files changed, 49 insertions(+), 4 deletions(-) diff --git a/.github/workflows/log4shell-goof-server-docker-image.yaml b/.github/workflows/log4shell-goof-server-docker-image.yaml index d40f327d36..915f50c1eb 100644 --- a/.github/workflows/log4shell-goof-server-docker-image.yaml +++ b/.github/workflows/log4shell-goof-server-docker-image.yaml @@ -45,3 +45,26 @@ jobs: - name: Cleanup container run: docker kill log4shell-server + + - name: Start minikube + uses: medyagh/setup-minikube@master + with: + cni: calico + + - name: Deploy to minikube + run: | + sed -i 's/${DOCKER_ACCOUNT}\///' k8s/deploy.yaml + sed -i 's/imagePullPolicy: Always/imagePullPolicy: Never/' k8s/deploy.yaml + minikube image load log4shell-server:latest + kubectl apply -f k8s/deploy.yaml + + - name: Test pods came up cleanly + run: | + kubectl get all --namespace=darkweb && \ + kubectl wait --namespace=darkweb --for=condition=ready pod --selector=app=log4shell --timeout=90s + + - name: Dump pod description + if: ${{ failure() }} + run: | + kubectl describe pod --namespace=darkweb --selector=app=log4shell + kubectl describe deploy --namespace=darkweb --selector=app=log4shell diff --git a/.github/workflows/todolist-goof-docker-image.yaml b/.github/workflows/todolist-goof-docker-image.yaml index bc4742cee2..88cb79f5f5 100644 --- a/.github/workflows/todolist-goof-docker-image.yaml +++ b/.github/workflows/todolist-goof-docker-image.yaml @@ -1,4 +1,4 @@ -name: todolost-goof Docker image build and test +name: todolist-goof Docker image build and test on: push: @@ -33,12 +33,33 @@ jobs: context: todolist-goof push: false tags: java-goof:latest - + - name: Run container run: docker run -d --rm --name java-goof -p 8080:8080 java-goof:latest - name: Smoke test container run: sleep 5 && curl -s --retry 5 --retry-delay 1 --retry-max-time 30 http://localhost:8080/todolist/ - - - name: Cleanup container + + - name: Teardown container run: docker kill java-goof + + - name: Start minikube + uses: medyagh/setup-minikube@master + with: + cni: calico + + - name: Deploy to minikube + run: | + sed -i 's/${DOCKER_ACCOUNT}\///' k8s/java-goof.yaml + sed -i 's/imagePullPolicy: Always/imagePullPolicy: Never/' k8s/java-goof.yaml + minikube image load java-goof:latest + kubectl apply -f k8s/java-goof.yaml + + - name: Test pod came up cleanly + run: | + kubectl get all + kubectl wait --for=condition=ready pod --selector=app=goof --timeout=90s + + - name: Dump pod description + if: ${{ failure() }} + run: kubectl describe pod --selector=app=goof diff --git a/log4shell-goof/log4shell-server/k8s/deploy.yaml b/log4shell-goof/log4shell-server/k8s/deploy.yaml index 9fd6036731..0598d81cf0 100644 --- a/log4shell-goof/log4shell-server/k8s/deploy.yaml +++ b/log4shell-goof/log4shell-server/k8s/deploy.yaml @@ -24,6 +24,7 @@ spec: containers: - name: ldap image: ${DOCKER_ACCOUNT}/log4shell-server:latest + imagePullPolicy: Always --- apiVersion: v1 kind: Service