From a43b41b86492a571832d59eb964db1b9fc0eb2d0 Mon Sep 17 00:00:00 2001 From: Pankaj Date: Fri, 9 Aug 2024 19:29:36 +0530 Subject: [PATCH] More experiment --- .github/workflows/postgres-deployment.yaml | 22 ++++++++ .github/workflows/postgres-service.yaml | 11 ++++ .github/workflows/test_kubernetes.yml | 60 +++++++++++++++++----- 3 files changed, 79 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/postgres-deployment.yaml create mode 100644 .github/workflows/postgres-service.yaml diff --git a/.github/workflows/postgres-deployment.yaml b/.github/workflows/postgres-deployment.yaml new file mode 100644 index 000000000..85def64af --- /dev/null +++ b/.github/workflows/postgres-deployment.yaml @@ -0,0 +1,22 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: postgres +spec: + replicas: 1 + selector: + matchLabels: + app: postgres + template: + metadata: + labels: + app: postgres + spec: + containers: + - name: postgres + image: postgres:latest + env: + - name: POSTGRES_PASSWORD + value: postgres + ports: + - containerPort: 5432 diff --git a/.github/workflows/postgres-service.yaml b/.github/workflows/postgres-service.yaml new file mode 100644 index 000000000..c12c0fed1 --- /dev/null +++ b/.github/workflows/postgres-service.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: postgres +spec: + selector: + app: postgres + ports: + - protocol: TCP + port: 5432 + targetPort: 5432   diff --git a/.github/workflows/test_kubernetes.yml b/.github/workflows/test_kubernetes.yml index d8cb96c05..799274020 100644 --- a/.github/workflows/test_kubernetes.yml +++ b/.github/workflows/test_kubernetes.yml @@ -3,17 +3,49 @@ name: Kubernetes Integration Tests on: push jobs: - run-kubernets-tests: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Kubernetes KinD Cluster - uses: container-tools/kind-action@v1 - - name: Run tests - run: | - sh ./scripts/test/kubernetes-setup.sh - pip install hatch - hatch -e tests.py3.9-2.9 run pip freeze - hatch run tests.py3.9-2.9:test-kubernetes - kubectl get pods -o wide - kubectl logs postgres-postgresql-0 + name: Spin Kind Cluster, Run Postgres, and Expose + + on: + push: + branches: [ main ] + + jobs: + spin-and-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Kind + uses: actions/setup-docker@v3 + - name: Create Kind Cluster + run: | + kind create cluster + - name: Create PostgreSQL Deployment + run: | + kubectl apply -f postgres-deployment.yaml + - name: Expose PostgreSQL Service + run: | + kubectl apply -f postgres-service.yaml + - name: Port Forward (or Load Balancer Setup) + run: | + kubectl port-forward service/postgres 5432:5432 + - name: Test PostgreSQL Connection + run: | + kubectl get pods -o wide + - name: Tear Down Cluster + run: | + kind delete cluster --name my-cluster +# run-kubernets-tests: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v3 +# - name: Kubernetes KinD Cluster +# uses: container-tools/kind-action@v1 +# - name: Run tests +# run: | +# sh ./scripts/test/kubernetes-setup.sh +# pip install hatch +# hatch -e tests.py3.9-2.9 run pip freeze +# hatch run tests.py3.9-2.9:test-kubernetes +# kubectl get pods -o wide +# kubectl logs postgres-postgresql-0 +