From fb6c09522328551fe77a611ec048c4acc8006387 Mon Sep 17 00:00:00 2001 From: Christopher Becker Date: Fri, 14 Jun 2024 10:49:17 +0200 Subject: [PATCH] added minikube --- .github/workflows/main.yml | 18 +++++++----------- kubernetes/app.yaml | 36 ++++++++++++++++++++++++++++++++++++ qa_script_github.sh | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+), 11 deletions(-) create mode 100644 kubernetes/app.yaml create mode 100644 qa_script_github.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ba43439..2203c2b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -88,24 +88,20 @@ jobs: steps: - uses: actions/checkout@v2 - uses: medyagh/setup-minikube@master - - name: Try the cluster ! - run: kubectl get pods -A - name: Build image run: | export SHELL=/bin/bash eval $(minikube -p minikube docker-env) - docker build -f ./Dockerfile -t local/example . - echo -n "verifying images:" - docker images + docker build -t local/wings-example-app:latest . - name: Deploy to minikube run: - kubectl apply -f deploy-to-minikube.yaml - - name: Test service URLs + kubectl create namespace wings-app + kubectl apply -f kubernetes/app.yaml + kubectl wait -f kubernetes/app.yaml --for=condition=Ready + - name: Mock Review Person run: | - minikube service list - minikube service example --url - echo "------------------opening the service------------------" - curl $(minikube service example --url) + chmod +x qa_script_github.sh + ./qa_script_github.sh needs: unittest if: ${{ github.event_name }} == "push" diff --git a/kubernetes/app.yaml b/kubernetes/app.yaml new file mode 100644 index 0000000..2dbf855 --- /dev/null +++ b/kubernetes/app.yaml @@ -0,0 +1,36 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: wings-example-app + labels: + app: wings-example-app + namespace: wings-app +spec: + replicas: 3 + selector: + matchLabels: + app: wings-example-app + template: + metadata: + labels: + app: wings-example-app + spec: + containers: + - name: wings-example-app + image: local/wings-example-app:latest + ports: + - containerPort: 5000 +--- +apiVersion: v1 +kind: Service +metadata: + name: wings-example-app + namespace: wings-app +spec: + selector: + app: wings-example-app + ports: + - protocol: TCP + port: 5000 + targetPort: 5000 + type: ClusterIP \ No newline at end of file diff --git a/qa_script_github.sh b/qa_script_github.sh new file mode 100644 index 0000000..3edc417 --- /dev/null +++ b/qa_script_github.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +NAMESPACE="wings-app" +SERVICE_NAME="wings-example-app" +LOCAL_PORT=5000 +REMOTE_PORT=5000 + +# Funktion zum Beenden der Port-Forwarding-Verbindung +cleanup() { + echo "Beende Port-Forwarding..." + kill $PORT_FORWARD_PID + wait $PORT_FORWARD_PID 2>/dev/null + echo "Port-Forwarding beendet." +} + +echo "Starte Port-Forwarding von ${LOCAL_PORT} zu ${SERVICE_NAME}:${REMOTE_PORT}..." +kubectl port-forward svc/${SERVICE_NAME} ${LOCAL_PORT}:${REMOTE_PORT} --namespace ${NAMESPACE} & +PORT_FORWARD_PID=$! + +sleep 5 + +if ps -p $PORT_FORWARD_PID > /dev/null +then + echo "Port-Forwarding läuft." + + CURL_RESPONSE=$(curl -s -w "\nHTTP-Status: %{http_code}\n" http://localhost:${LOCAL_PORT}) + + echo "Antwort von curl:" + echo "$CURL_RESPONSE" + + cleanup +else + echo "Port-Forwarding fehlgeschlagen." + exit 1 +fi \ No newline at end of file