GitOps-driven Kubernetes Native Deployment

May 12, 2025
ArgoCD project Docker kubernetes github

This Project Include:

Video Demonstration: https://youtu.be/1PRMywtWoJA?feature=shared

Instructions to Deploy

Install Prerequistics

Clone the Repository

git clone https://github.com/srngx/devopsifying-app

Create Docker Image

docker build -t /mywebsite .

Start Minikube Cluster

minikube start

Manually Running with kubernetes

Goto the K8S/manifests/ directory and run:
- deployment kubctl apply -f deployment.yaml
- service kubctl apply -f service.yaml

Check status if all service working properly
- kubectl get all

And try to access the service using minikube IP and nodeport Check Minikube IP
- minikube ip

Deploying with helm charts

Optional:
- You can create helm chart and manually edit template but I already did that part
So here is what I did
- helm create mywebsite-chart
- deleted Charts and everything inside templates folder
- and copied both manifests files into templates
- Deleted all comments from Chart.yaml
- Edited values.yaml file and deleted everything except: yaml replicaCount: 1 image: tag: "v1"
- And Edited deployment.yaml file to parameterized the Image Tab with {{ .Values.image.tag }}

Deploy with helm charts

Github Actions

Creating Repository

name: helm-CI
permissions:
  contents: write

on:
  push:
    branches:
      - master
    paths-ignore:
      - 'helm/**'
      - Readme.md
      - .gitignore

jobs:
  push:
    runs-on: ubuntu-latest
    steps:
      - name: checkout repository
        uses: actions/checkout@v4

      - name: Setup docker build
        uses: docker/setup-buildx-action@v1

      - name: Login do DockerHub
        uses: docker/login-action@v3
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}

      - name: Build and push
        uses: docker/build-push-action@v6
        with:
          context: .
          file: ./Dockerfile
          push: true
          tags: ${{ secrets.DOCKERHUB_USERNAME }}/mywebsite:${{ github.run_id }}
          platforms: linux/amd64,linux/arm64

  update-helm-chart:
    runs-on: ubuntu-latest
    needs: push
    steps:
      - name: checkout repository
        uses: actions/checkout@v4

      - name: Update tag
        run: |
          sed -i 's/tag: .*/tag: "${{github.run_id}}"/' helm/mywebsite-chart/values.yaml

      - name: Commit and push changes
        run: |
          git config --global user.email "[email protected]"
          git config --global user.name "srngx"
          git add helm/mywebsite-chart/values.yaml
          git commit -m "Updated tag in Helm chart"
          git push

Generate Dockerhub token

Create Repository Secrets in Github

Push everything to github and see if action is running perfectly

  • Given that you have perfectly setuped Dockerhub Repository and all
  • After Github Actions Completed Successfully You should see new tag in Dockerhub.
  • and under helm chart values tag part also must have changed.
  • ArgoCD

    To Autodeploy the new version of site we use Argo CD

    Install ArgoCD cluster

    kubectl create namespace argocd
    kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml

    Check argo running status

    kubectl get all -n argocd
    kubectl get service -n argocd

    Our arogocd server service showing ClusterIP right now but we need to make it NodePort to access it

    Kubectl edit service argocd-server -n argocd
    Goto Very bottom of page and Change

    type: ClusterIP     to    type: NodePort

    and save and exit

    Now we should see Nodeport

    Accessing the ArgoCD-server

    check minikube and open in browser with appending nodePort Port: http://192.168.49.2:31542

    Getting Login Details

    To get password

    Create app inside Argocd

    It will take a second to show everything in sync and healthy.

    Now try editing your website code and push it to github and See it will resync after a minute and new tag will be appear on values.yaml file and same tag no. image must be uploaded to dockerhub.

    Thanks for Reading!