Skip to content

A Kubernetes demo project showcasing how to deploy a containerized Golang web application on Minikube with Ingress routing and Horizontal Pod Autoscaling (HPA)

Notifications You must be signed in to change notification settings

phamphihungbk/scalable_minikube_app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Scalable Minikube App

A Kubernetes demo project showcasing how to deploy a containerized Golang web application on Minikube with Ingress routing and Horizontal Pod Autoscaling (HPA) based on CPU utilization. Includes a CPU-intensive endpoint for load testing and observing real-time scaling.


✨ Features

  • Deploy a lightweight Go web application in Kubernetes.
  • Configure Ingress for external access.
  • Implement Horizontal Pod Autoscaler (HPA) based on CPU metrics.
  • Enable Metrics Server for scaling metrics.
  • Perform load testing with hey or ab to trigger scaling events.
  • Observe pods automatically scale up/down in response to workload.

🛠 Tech Stack

  • Golang 1.22
  • Docker
  • Kubernetes (Minikube)
  • Ingress Controller
  • Metrics Server
  • Horizontal Pod Autoscaler
  • Load Testing Tools (hey, ab)

📂 Project Structure

scalable-minikube-app/
├─ app/                # Go application source code
├─ k8s/                # Kubernetes manifests
├─ scripts/            # Build & load test scripts
├─ Dockerfile          # Container build config
├─ .dockerignore
├─ .gitignore
└─ README.md

🚀 Quick Start

1️⃣ Prerequisites


2️⃣ Start Minikube

minikube start --memory=4096 --cpus=2

3️⃣ Enable Required Addons

minikube addons enable metrics-server
minikube addons enable ingress

4️⃣ Build & Push Docker Image

eval $(minikube docker-env)
docker build -t scalable-minikube-app:local .

5️⃣ Deploy to Kubernetes

kubectl apply -f k8s/deployment.yaml
kubectl apply -f k8s/service.yaml
kubectl apply -f k8s/ingress.yaml
kubectl apply -f k8s/hpa.yaml

6️⃣ Access the App

Get Minikube IP:

minikube ip

Edit /etc/hosts (Linux/Mac) or C:\Windows\System32\drivers\etc\hosts (Windows) and add:

<MINIKUBE_IP> scalable-minikube.local

Open in browser:

http://scalable-minikube.local/

7️⃣ Trigger Scaling with Load Test

hey -z 60s -c 50 http://scalable-minikube.local/cpu?ms=500

8️⃣ Watch Scaling in Action

kubectl get hpa -w
kubectl get pods -w

You’ll see pods scale from 1 → N and back down when the load stops.

9️⃣ Cleanup

kubectl delete -f k8s/
minikube stop

About

A Kubernetes demo project showcasing how to deploy a containerized Golang web application on Minikube with Ingress routing and Horizontal Pod Autoscaling (HPA)

Resources

Stars

Watchers

Forks