Skip to content

Commit 83d6ce7

Browse files
committed
Implement Github CI/CD
1 parent c1d5875 commit 83d6ce7

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

.github/workflows/deploy.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Deploy to Kubernetes
2+
3+
on:
4+
workflow_dispatch: # Enable manual triggering via GitHub UI
5+
6+
jobs:
7+
build-and-push:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout code
11+
uses: actions/checkout@v3
12+
13+
- name: Log in to DockerHub
14+
uses: docker/login-action@v2
15+
with:
16+
username: ${{ secrets.DOCKER_USERNAME }}
17+
password: ${{ secrets.DOCKER_PASSWORD }}
18+
19+
- name: Build and push Docker image
20+
uses: docker/build-push-action@v5
21+
with:
22+
context: .
23+
push: true
24+
tags: scaling_kubernetes_hpa_vpa/worker:latest
25+
26+
deploy-to-k8s:
27+
runs-on: ubuntu-latest
28+
needs: [build-and-push] # Ensure this step depends on the previous step
29+
if: github.event_name == 'workflow_dispatch' # Only run when manually triggered
30+
steps:
31+
- name: Checkout code
32+
uses: actions/checkout@v3
33+
34+
- name: Set up kubectl
35+
uses: azure/setup-kubectl@v3
36+
with:
37+
version: 'latest'
38+
39+
- name: Configure KUBECONFIG
40+
run: |
41+
mkdir -p ~/.kube
42+
echo "${{ secrets.KUBECONFIG_CONTENT }}" | base64 -d > ~/.kube/config
43+
export KUBECONFIG=~/.kube/config
44+
45+
- name: Apply Kubernetes Manifests
46+
run: |
47+
kubectl apply -f k8s-manifests/redis-deployment.yaml
48+
kubectl apply -f k8s-manifests/redis-svc.yaml
49+
kubectl apply -f k8s-manifests/deployment.yaml
50+
kubectl apply -f k8s-manifests/hpa.yaml
51+
kubectl apply -f k8s-manifests/vpa.yaml

0 commit comments

Comments
 (0)