Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kubernetes Docker Go React

openstack-prod

Production-Ready Kubernetes Microservices Deployment

A complete, production-ready microservices application deployed on Kubernetes with Docker containerization and Nginx ingress controller.

🏗️ Architecture

┌─────────────────────────────────────────┐
│         Kubernetes Cluster              │
│  ┌───────────────────────────────────┐  │
│  │     Nginx Ingress Controller      │  │
│  └────────────┬──────────────────────┘  │
│               │                          │
│       ┌───────┴────────┐                │
│       │                │                │
│  ┌────▼─────┐    ┌────▼─────┐          │
│  │ Frontend │    │ Backend  │          │
│  │ Service  │    │ Service  │          │
│  │ (React)  │    │   (Go)   │          │
│  │ 2 replicas│    │ 2 replicas│          │
│  └──────────┘    └──────────┘          │
└─────────────────────────────────────────┘

🚀 Tech Stack

  • Frontend: React 18 with modern hooks
  • Backend: Go 1.21 with standard HTTP library
  • Containerization: Docker with multi-stage builds
  • Orchestration: Kubernetes (Minikube for local dev)
  • Ingress: Nginx Ingress Controller
  • Version Control: Git/GitHub

📋 Prerequisites

  • Docker or Colima
  • Minikube
  • kubectl
  • Helm (for ingress)
  • Git

🛠️ Setup Instructions

1. Clone Repository

git clone https://github.com/YOUR_USERNAME/openstack-prod.git
cd openstack-prod

2. Start Minikube

minikube start --driver=docker --cpus=2 --memory=4g

3. Build Docker Images

# Point Docker to Minikube's environment
eval $(minikube docker-env)

# Build backend
cd docker/backend
docker build -t backend-api:v1 .

# Build frontend
cd ../frontend
docker build -t frontend-app:v1 .

4. Deploy to Kubernetes

cd ~/openstack-prod

# Deploy backend
kubectl apply -f kubernetes/deployments/backend-deployment.yaml
kubectl apply -f kubernetes/services/backend-service.yaml

# Deploy frontend
kubectl apply -f kubernetes/deployments/frontend-deployment.yaml
kubectl apply -f kubernetes/services/frontend-service.yaml

# Wait for pods to be ready
kubectl get pods -w

5. Setup Ingress

# Enable nginx ingress
minikube addons enable ingress

# Apply ingress configuration
kubectl apply -f kubernetes/ingress/nginx-ingress.yaml

# Setup port forwarding
kubectl port-forward -n ingress-nginx svc/ingress-nginx-controller 8080:80

6. Access Application

Open your browser to: http://localhost:8080

🧪 Testing

Run the automated test script:

./scripts/test-app.sh

Or test manually:

# Test backend API
curl http://localhost:8080/api/hello

# Test frontend
curl http://localhost:8080/

📁 Project Structure

openstack-prod/
├── apps/
│   ├── backend/        # Go API source code
│   └── frontend/       # React app source code
├── docker/
│   ├── backend/        # Backend Dockerfile
│   └── frontend/       # Frontend Dockerfile + nginx config
├── kubernetes/
│   ├── deployments/    # K8s Deployment manifests
│   ├── services/       # K8s Service manifests
│   └── ingress/        # Ingress configuration
├── scripts/
│   └── test-app.sh     # Automated testing script
└── README.md

🔑 Key Features

Docker

  • Multi-stage builds for optimized image sizes
  • Non-root users for security
  • Health checks built into images
  • Backend: ~15MB final image
  • Frontend: ~50MB final image

Kubernetes

  • High Availability: 2 replicas per service
  • Health Probes: Liveness and readiness checks
  • Resource Limits: CPU and memory constraints
  • Service Discovery: DNS-based service communication
  • Rolling Updates: Zero-downtime deployments

Ingress

  • Path-based routing: /api/* → Backend, / → Frontend
  • Nginx: Production-grade reverse proxy
  • Port forwarding: Easy local development access

📊 Monitoring

Check pod status:

kubectl get pods

View logs:

# Backend logs
kubectl logs -l app=backend

# Frontend logs
kubectl logs -l app=frontend

Describe resources:

kubectl describe deployment backend-deployment
kubectl describe service backend-service
kubectl describe ingress app-ingress

🔄 Development Workflow

  1. Make code changes in apps/
  2. Rebuild Docker image
  3. Delete old deployment: kubectl delete deployment <name>
  4. Reapply: kubectl apply -f kubernetes/deployments/<file>.yaml

🌟 Production Considerations

For production deployment on OpenStack or other cloud platforms:

  1. Use real LoadBalancer instead of port-forward
  2. Add TLS/SSL certificates for HTTPS
  3. Implement monitoring (Prometheus + Grafana)
  4. Add logging (ELK stack or Loki)
  5. Use Helm charts for easier deployment
  6. Implement CI/CD (GitHub Actions, Jenkins)
  7. Add persistent storage if needed
  8. Configure horizontal pod autoscaling

🤝 Contributing

Pull requests welcome! Please ensure:

  • Code follows existing patterns
  • Docker images build successfully
  • All pods become Ready
  • Tests pass

📝 License

MIT License

👤 Beryl Malomo

Built as a DevOps learning project demonstrating Kubernetes, Docker, and microservices architecture.


Built with ❤️ using Kubernetes, Docker, Go, and React

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages