This is a complete Kubernetes training setup with a Go frontend and backend application.
backend/- Go backend API servicefrontend/- Go frontend web applicationk8s/- Kubernetes configuration files
# Build backend
cd backend
docker build -t your-registry/backend:latest .
docker push your-registry/backend:latest
# Build frontend
cd ../frontend
docker build -t your-registry/frontend:latest .
docker push your-registry/frontend:latest-
Update the image names in the deployment files to match your Docker registry.
-
Apply the configurations:
# Deploy backend
kubectl apply -f k8s/backend-deployment.yaml
kubectl apply -f k8s/backend-service.yaml
# Deploy frontend
kubectl apply -f k8s/frontend-deployment.yaml
kubectl apply -f k8s/frontend-service.yaml
# Deploy ingress
kubectl apply -f k8s/ingress.yaml- Add to your
/etc/hostsfile:
127.0.0.1 training.local
- Access the application at
http://training.local
-
Backend: REST API service on port 8080
/health- Health check endpoint/api/data- Returns JSON data with request counter
-
Frontend: Web UI on port 8081
- Displays a simple web interface
- Calls backend API via proxy endpoint
- Shows backend responses
-
Deployments: Manage replica sets for both services
- Backend: 3 replicas
- Frontend: 2 replicas
-
Services: Internal networking
- Backend: ClusterIP service on port 8080
- Frontend: ClusterIP service on port 80
-
Ingress: External access via NGINX ingress controller
- Routes
/to frontend - Routes
/apito backend
- Routes
# Run backend locally
cd backend
go run main.go
# Run frontend locally (in another terminal)
cd frontend
BACKEND_URL=http://localhost:8080 go run main.goVisit http://localhost:8081 to see the frontend.