A simple microservices application demonstrating Kubernetes deployment with auto-scaling on DigitalOcean. This project was created for the CS1025 Hauptseminar "Cloud-Plattformen und Big Data" (Rupp).
This application consists of a Go backend and an HTML/JavaScript frontend that displays the current time. It demonstrates:
- Containerization with Docker
- Kubernetes orchestration
- Horizontal Pod Autoscaling (HPA)
- Infrastructure as Code with Terraform
- DigitalOcean cloud deployment
- NGINX Ingress Controller
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Ingress (NGINX) β
β time.webnils.de β
ββββββββββββββ¬ββββββββββββββββββββββ¬βββββββββββββββββββ
β β
β / β /api
βΌ βΌ
βββββββββββββββββ βββββββββββββββββ
β Frontend β β Backend β
β (nginx:80) ββββββΆβ (Go:8080) β
β β β + HPA β
βββββββββββββββββ βββββββββββββββββ
- Frontend: Static HTML page served by NGINX that fetches and displays the current time
- Backend: Go HTTP server that provides a REST API endpoint (
/api/time) returning the current time in JSON format - Auto-scaling: HPA configured to scale backend pods (1-5 replicas) based on 50% CPU utilization
- Infrastructure: DigitalOcean Kubernetes cluster (3 nodes, s-2vcpu-4gb) provisioned via Terraform
.
βββ Backend/
β βββ Dockerfile # Multi-stage build for Go backend
β βββ go.mod # Go module definition
β βββ main.go # Backend API server
βββ Frontend/
β βββ Dockerfile # NGINX container for static frontend
β βββ index.html # Time display UI
βββ K8S/
β βββ backend.yaml # Backend deployment, service, and HPA
β βββ frontend.yaml # Frontend deployment and service
β βββ ingress.yaml # Ingress routing configuration
βββ terraform/
β βββ main.tf # DigitalOcean cluster and infrastructure
β βββ input.tf # Terraform variables
β βββ output.tf # Terraform outputs
βββ presi.txt # Deployment commands and notes
- Docker with buildx support
- doctl (DigitalOcean CLI)
- kubectl
- Terraform
- DigitalOcean account with API token
cd terraform
terraform init
terraform applyThis creates:
- Kubernetes cluster (3-node, fra1 region)
- Container registry
- NGINX Ingress Controller
- Metrics Server (for HPA)
Login to DigitalOcean container registry:
doctl registry loginBuild and push backend:
cd Backend
docker buildx build --platform linux/amd64 \
-t registry.digitalocean.com/hauptseminar/backend:latest \
--push .Build and push frontend:
cd Frontend
docker buildx build --platform linux/amd64 \
-t registry.digitalocean.com/hauptseminar/frontend:latest \
--push .doctl kubernetes cluster list
doctl kubernetes cluster kubeconfig save hs-clusterkubectl apply -f K8S/backend.yaml
kubectl apply -f K8S/frontend.yaml
kubectl apply -f K8S/ingress.yamlkubectl get pods
kubectl get services
kubectl get ingress
kubectl get hpa- Port: 8080
- Endpoint:
/api/time - CPU Requests: 100m
- CPU Limits: 500m
- Auto-scaling: 1-5 replicas at 50% CPU
- Port: 80
- Update Interval: 1 second
- Host: time.webnils.de
- Routes:
/β Frontend/apiβ Backend
Check HPA status:
kubectl get hpa backend-hpa --watchView backend logs:
kubectl logs -l app=backend -fView metrics:
kubectl top pods
kubectl top nodesThe backend includes a CPU-intensive loop in each request to simulate load. Generate traffic to trigger auto-scaling:
# Simple load test
while true; do curl https://time.webnils.de/api/time; doneWatch pods scale:
kubectl get hpa backend-hpa --watch
kubectl get pods -l app=backend --watchcd Backend
go run main.go
# Server runs on http://localhost:8080Test endpoint:
curl http://localhost:8080/api/timecd Frontend
python3 -m http.server 8080
# Open http://localhost:8080Returns the current server time in RFC3339 format.
Response:
{
"time": "2025-12-16T10:30:45+01:00"
}Remove Kubernetes resources:
kubectl delete -f K8S/Destroy infrastructure:
cd terraform
terraform destroy- Backend: Go 1.25
- Frontend: HTML, JavaScript, NGINX
- Container: Docker, Multi-stage builds
- Orchestration: Kubernetes 1.34
- Cloud: DigitalOcean
- IaC: Terraform
- Ingress: NGINX Ingress Controller
- Monitoring: Kubernetes Metrics Server
This is an educational project created for the Hauptseminar "Cloud-Plattformen und Big Data" at the university.
Nils Polek
Note: This project demonstrates cloud-native development principles including containerization, orchestration, auto-scaling, and infrastructure as code for educational purposes.
This README was created with AI assistance.