Skip to content

Deploy to Kubernetes #4

Deploy to Kubernetes

Deploy to Kubernetes #4

Workflow file for this run

name: Deploy to Kubernetes
on:
workflow_dispatch: # Enable manual triggering via GitHub UI
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Log in to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: narsic/scaling_kubernetes_hpa_vpa:latest
deploy-to-k8s:
runs-on: ubuntu-latest
needs: [build-and-push] # Ensure this step depends on the previous step
if: github.event_name == 'workflow_dispatch' # Only run when manually triggered
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up kubectl
uses: azure/setup-kubectl@v3
with:
version: 'latest'
- name: Configure KUBECONFIG
run: |
mkdir -p ~/.kube
echo "${{ secrets.KUBECONFIG_CONTENT }}" | base64 -d > ~/.kube/config
export KUBECONFIG=~/.kube/config
- name: Apply Kubernetes Manifests
run: |
kubectl apply -f k8s-manifests/redis-deployment.yaml
kubectl apply -f k8s-manifests/redis-svc.yaml
kubectl apply -f k8s-manifests/deployment.yaml
kubectl apply -f k8s-manifests/hpa.yaml
kubectl apply -f k8s-manifests/vpa.yaml