A 3-tier web application running on a local K3d (K3s in Docker) cluster: Nginx (frontend/reverse proxy) → Flask API (backend) → Redis (cache)
- Kubernetes Namespaces
- Deployments & Pod lifecycle
- ClusterIP / NodePort Services
- ConfigMap environment injection
- Horizontal Pod Autoscaler (HPA)
- Readiness Probes
- Troubleshooting with K9s terminal UI
- 3-tier architecture: Nginx → Flask API → Redis
- Ubuntu / WSL2 Ubuntu
- Docker Engine running
- Git installed
chmod +x install-tools.sh
./install-tools.shchmod +x cluster/create-cluster.sh
./cluster/create-cluster.shchmod +x deploy.sh
./deploy.shThe app will be available at http://localhost:8080
k9sManual scaling:
kubectl scale deployment flask-api -n web-stack --replicas=3HPA (auto-scaling based on CPU):
kubectl get hpa -n web-stack
kubectl describe hpa flask-api-hpa -n web-stackcurl http://localhost:8080
# Refresh multiple times to see the visit counter incrementchmod +x destroy.sh
./destroy.sh ┌─────────────┐
localhost:8080 ──►│ NodePort │
│ 30080 │
└──────┬──────┘
│
┌──────▼──────┐
│ Nginx │ (reverse proxy, port 80)
└──────┬──────┘
│ proxy_pass :5000
┌──────▼──────┐
│ Flask API │ (ClusterIP, port 5000)
└──────┬──────┘
│
┌──────▼──────┐
│ Redis │ (ClusterIP, port 6379)
└─────────────┘
# Check pod status
kubectl get pods -n web-stack
# View pod logs
kubectl logs -n web-stack deployment/flask-api
kubectl logs -n web-stack deployment/nginx
# Describe a failing pod
kubectl describe pod -n web-stack -l app=flask-api
# Exec into a pod
kubectl exec -it -n web-stack deployment/redis -- redis-cli