πŸš€ Building a Free CI/CD Pipeline for Node.js with Kubernetes (Minikube + GitHub Actions)

πŸ’‘ Why This Project?

When learning DevOps, most tutorials directly jump to AWS EKS, GKE, or AKS. While these are powerful, they’re also paid services. For someone practicing at home, that’s not ideal.

That’s why I built this pipeline with Minikube (local Kubernetes) and a self-hosted GitHub Actions runner. This way:

  • CI/CD feels real-world (GitHub Actions + Docker Hub + Kubernetes).

  • I didn’t have to spend on cloud bills (EKS costs money for clusters + nodes).

  • The entire setup runs inside a single VM on my laptop.

In short: it’s a budget-friendly, yet production-like DevOps workflow.


πŸ“˜ What This Project Does

This project demonstrates a complete DevOps CI/CD pipeline for a Node.js application:

  1. Develop a simple Node.js app.

  2. Containerize it with Docker.

  3. Push the image to Docker Hub via GitHub Actions (CI).

  4. Deploy it to Kubernetes (Minikube) via GitHub Actions (CD).

  5. Access the app via a Kubernetes Service.

Because Minikube runs locally, I used a self-hosted runner inside the VM so GitHub Actions can talk to the cluster.


🧱 Prerequisites

  • A Linux VM (Ubuntu is perfect) β€” I used VirtualBox.

  • Docker, kubectl, Minikube installed.

  • Node.js 16+ (for testing locally).

  • A Docker Hub account.

  • A GitHub repository.


πŸ“‚ Project Structure

.
β”œβ”€β”€ .github/workflows/ci-cd.yml
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ k8s/
β”‚   β”œβ”€β”€ deployment.yaml
β”‚   └── service.yaml
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ index.js
β”‚   β”œβ”€β”€ server.js
β”‚   └── package.json
└── README.md

βš™οΈ Step 1 β€” Set Up Project Locally

mkdir -p ~/projects && cd ~/projects
git clone https://github.com/<your-gh-username>/nodejs-k8s-cicd.git
cd nodejs-k8s-cicd
ls -la

βš™οΈ Step 2 β€” Configure Minikube

Start Minikube:

minikube start --driver=docker

Check cluster:

kubectl config current-context   # should be "minikube"
kubectl cluster-info
kubectl get nodes

βš™οΈ Step 3 β€” Setup Docker Hub & Secrets

In GitHub β†’ Settings β†’ Secrets and variables β†’ Actions:

  • DOCKERHUB_USERNAME β†’ your username

  • DOCKERHUB_TOKEN β†’ Docker Hub access token


βš™οΈ Step 4 β€” GitHub Actions Workflow

CI/CD workflow lives at .github/workflows/ci-cd.yml:

  • Build job: Runs on GitHub’s free ubuntu-latest runner.

  • Deploy job: Runs on your self-hosted runner in the VM (so it can talk to Minikube).


βš™οΈ Step 5 β€” Self-Hosted Runner

Since Minikube is local, deployment must also happen local.
Steps:

cd ~
mkdir actions-runner && cd actions-runner

# download runner
curl -o actions-runner-linux-x64.tar.gz -L https://github.com/actions/runner/releases/download/vX.Y.Z/actions-runner-linux-x64-X.Y.Z.tar.gz
tar xzf actions-runner-linux-x64.tar.gz

# configure with repo + token
./config.sh --url https://github.com/<your-gh-username>/nodejs-k8s-cicd --token <YOUR_TOKEN>

# run (foreground)
./run.sh

(Optional: install as service so it persists after reboot).


βš™οΈ Step 6 β€” Trigger Pipeline

echo "// test change" >> app.js
git add app.js
git commit -m "Trigger pipeline"
git push
  • Build job β†’ builds & pushes Docker image to Docker Hub.

  • Deploy job β†’ applies Kubernetes manifests.

Check app status:

kubectl get pods
kubectl get svc
minikube service nodejs-service --url

Open the printed URL in browser πŸŽ‰


πŸ”‘ Why Minikube + Self-Hosted Runner, Not AWS EKS?

I deliberately avoided EKS because:

  1. Cost β†’ EKS control plane + nodes = $$$ even for small clusters.

  2. Simplicity β†’ Minikube runs everything in a single VM.

  3. Learning Focus β†’ My goal was to practice Kubernetes CI/CD, not manage AWS networking & billing.

  4. Self-Hosted Runner β†’ Keeps everything free, but still shows how CD pipelines work with Kubernetes.

Once this works on Minikube, migrating to EKS later is straightforward β€” manifests and workflow logic stay the same, only cluster context changes.

0
Subscribe to my newsletter

Read articles from HARSHAL VERNEKAR directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

HARSHAL VERNEKAR
HARSHAL VERNEKAR

πŸš€ Aspiring DevOps & Cloud Engineer with a strong foundation in cloud platforms (AWS), infrastructure automation, and container orchestration tools like Docker and Kubernetes. I’m passionate about building reliable, scalable, and secure cloud-native applications. πŸ”§ Currently building real-world projects using Terraform, Ansible, Jenkins, GitHub Actions, and EKS to understand how modern infrastructure is deployed, managed, and monitored. I enjoy breaking things (safely), debugging, and learning from hands-on experience. πŸ“¦ Comfortable working with: AWS (EC2, S3, IAM, VPC, EKS) Docker, Kubernetes (Minikube & EKS) CI/CD tools like Jenkins & GitHub Actions IaC tools like Terraform & Ansible Monitoring with Prometheus & Grafana Linux, Bash, Git, and Networking fundamentals πŸ’‘ Always learning β€” currently exploring deeper concepts in Kubernetes workloads, Helm, and scaling best practices. πŸ” Open to DevOps, Cloud, or SRE roles where I can grow, contribute, and solve real-world problems.