This repository contains a complete CI/CD pipeline for the Be Your Moments microservices application, supporting both production deployment (K3s) and development deployment (Docker Compose).
The application consists of 5 microservices:
- photo-svc (Port 8001) - Photo management service
- user-svc (Port 8003) - User management service
- transaction-svc (Port 8005) - Transaction processing service
- upload-svc (Port 8002) - File upload service
- notification-svc (Port 8004) - Notification service
- Trigger: Tags like
v1.0.0,v2.1.0 - Deployment: K3s cluster
- Features: Full microservices architecture with Kubernetes
- Trigger: Tags like
x.dev.1.0.0,x.dev.2.1.0 - Deployment: Docker Compose on VPS
- Features: Simplified development environment
├── .github/workflows/
│ ├── ci-cd.yml # Production pipeline (K3s)
│ └── ci-cd-dev.yml # Development pipeline (Docker Compose)
├── scripts/
│ ├── deploy.sh # Production deployment
│ ├── setup.sh # Production setup
│ ├── rollback.sh # Production rollback
│ ├── monitor.sh # Production monitoring
│ ├── deploy-dev.sh # Development deployment
│ ├── setup-dev.sh # Development setup
│ ├── monitor-dev.sh # Development monitoring
│ └── k8s/ # Kubernetes manifests
├── photo-svc/ # Photo service
├── user-svc/ # User service
├── transaction-svc/ # Transaction service
├── upload-svc/ # Upload service
├── notification-svc/ # Notification service
└── pb/ # Protocol buffers
- VPS with Docker installed
- GitHub repository with secrets configured
- kubectl configured (for production)
# Setup K3s on VPS
./scripts/k3s-setup.sh
# Setup infrastructure
./scripts/setup.sh
# Create secrets
./scripts/create-secrets.sh
# Deploy services
./scripts/deploy.sh latest# Setup development environment
./scripts/setup-dev.sh
# Start services
cd /tmp/be-yourmoments-dev
./start.sh-
Create and push a production tag:
git tag v1.0.0 git push origin v1.0.0
-
GitHub Actions will automatically:
- Run tests
- Build Docker images
- Deploy to K3s cluster
-
Create and push a development tag:
git tag x.dev.1.0.0 git push origin x.dev.1.0.0
-
GitHub Actions will automatically:
- Run tests
- Build Docker images
- Deploy to VPS using Docker Compose
# Check status
./scripts/monitor.sh status
# Check health
./scripts/monitor.sh health
# View logs
./scripts/monitor.sh logs photo-svc# Check status
./scripts/monitor-dev.sh status
# Check health
./scripts/monitor-dev.sh health
# View logs
./scripts/monitor-dev.sh logs photo-svc# Rollback all services
./scripts/rollback.sh
# Rollback specific service
./scripts/rollback.sh photo-svc# Restart services
cd /tmp/be-yourmoments-dev
./restart.sh
# Or use monitoring script
./scripts/monitor-dev.sh restart photo-svcAll services include health check endpoints:
- photo-svc:
http://localhost:8001/health - user-svc:
http://localhost:8003/health - transaction-svc:
http://localhost:8005/health - upload-svc:
http://localhost:8002/health - notification-svc:
http://localhost:8004/health
# Check pod status
kubectl get pods -n be-yourmoments
# Check logs
kubectl logs deployment/photo-svc -n be-yourmoments
# Check events
kubectl get events -n be-yourmoments# Check container status
docker ps
# Check logs
./logs.sh
# Check specific service
./scripts/monitor-dev.sh logs photo-svc- Minimum: 4 cores, 8GB RAM
- Recommended: 8 cores, 16GB RAM
- Services: 5 microservices + infrastructure
- Minimum: 2 cores, 4GB RAM
- Recommended: 4 cores, 8GB RAM
- Services: 5 microservices + infrastructure
- Production: Kubernetes secrets
- Development: Environment files
- Service Account Keys: Secure storage required
- Production: Network policies, ingress controllers
- Development: Docker networks, port mapping
- Use semantic versioning for tags
- Monitor resource usage regularly
- Implement proper secrets management
- Use network policies for security
- Regular backups of data
- Use development tags for testing
- Monitor resource usage locally
- Keep service account keys secure
- Regular cleanup of resources
- Test locally before deploying
- Check K3s logs:
kubectl logs deployment/<service> -n be-yourmoments - Check events:
kubectl get events -n be-yourmoments - Monitor resources:
kubectl top pods -n be-yourmoments
- Check Docker logs:
docker logs <container> - Check service status:
./status.sh - Monitor resources:
docker stats
- CI_CD_README.md - Production pipeline documentation
- DEVELOPMENT_README.md - Development pipeline documentation
- scripts/README.md - Script documentation
- TROUBLESHOOTING.md - Troubleshooting guide
- Setup K3s:
./scripts/k3s-setup.sh - Deploy infrastructure:
./scripts/setup.sh - Create secrets:
./scripts/create-secrets.sh - Deploy services:
./scripts/deploy.sh latest - Monitor:
./scripts/monitor.sh status
- Setup development:
./scripts/setup-dev.sh - Start services:
cd /tmp/be-yourmoments-dev && ./start.sh - Monitor:
./scripts/monitor-dev.sh status - Create tag:
git tag x.dev.1.0.0 - Deploy:
git push origin x.dev.1.0.0
| Feature | Production (K3s) | Development (Docker Compose) |
|---|---|---|
| Complexity | High | Low |
| Resource Usage | High | Low |
| Scalability | Excellent | Limited |
| Management | Complex | Simple |
| Use Case | Production | Development/Testing |
| Setup Time | 30+ minutes | 5-10 minutes |
| Resource Requirements | 4C/8GB+ | 2C/4GB+ |
Choose your deployment strategy:
- Use K3s pipeline with tags like
v1.0.0 - Follow production documentation
- Use monitoring and rollback features
- Use Docker Compose pipeline with tags like
x.dev.1.0.0 - Follow development documentation
- Use simplified management commands
Both pipelines are fully automated and will handle the complete deployment process from code to running services.