The Deployment Platform is a web-based application designed to streamline the deployment of microservices to Kubernetes clusters using ArgoCD. It provides a user-friendly interface for managing deployments, secrets, and approvals, with integration to GitHub for pull requests and DockerHub for image tags. The platform supports real-time status updates via WebSocket, notifications via Slack/Email, and a comprehensive deployment history.
- Service Deployment: Deploy microservices to DEV, STAG, or PROD environments with automated GitHub PR creation.
- Secret Management: Generate Kubernetes secrets for environment variables.
- Approval Workflow: Require approvals for STAG/PROD deployments with PR merge integration.
- Real-Time Status: WebSocket-based updates for PR and deployment status with Mermaid diagrams.
- Deployment History: Paginated history with filters by service and environment.
- DockerHub Integration: Fetch available tags for service images.
- Notifications: Slack and Email notifications for deployment events (pending, approved, rejected).
- Error Handling: Robust validation, Git conflict detection, and kubeconfig retries.
- Backend: FastAPI application with PostgreSQL for user and deployment data, integrated with GitHub, DockerHub, and Kubernetes.
- Frontend: React application with Material-UI, featuring a deployment wizard, approvals, and history views.
- Infrastructure:
- Docker Compose for local development (backend, frontend, PostgreSQL).
- ArgoCD for Kubernetes deployments, using ApplicationSet templates.
- GitHub for configuration management (
nxh-applications-{env}repos).
- Workflow:
- User logs in and initiates deployment via UI.
- Backend validates input, generates secrets/values YAML, updates ApplicationSet.
- GitHub PR created, logged in DB, and notified via Slack/Email (STAG/PROD requires approval).
- Real-time status updates via WebSocket.
- Post-approval, PR is merged, and ArgoCD syncs the deployment.
- Docker and Docker Compose for local development.
- Python 3.12 for backend dependencies.
- Node.js 18+ and npm for frontend.
- GitHub Token with repo access (
reposcope). - DockerHub Credentials for private image access.
- Kubernetes Configs (
~/.kube/{env}.yamlfor DEV/STAG/PROD). - PostgreSQL database (local or remote).
- Optional: Slack Webhook URL and SMTP server for notifications.
-
Clone the Repository:
git clone https://github.com/nexahub/deployment-control-center.git cd deployment-control-center -
Set Up Environment Variables: Copy
.env.exampleto.envand fill in:cp .env.example .env
Example
.env:DATABASE_URL=postgresql://user:pass@localhost:5432/deployment_db GITHUB_TOKEN=your_github_token DOCKERHUB_USERNAME=your_dockerhub_username DOCKERHUB_TOKEN=your_dockerhub_token KUBE_CONFIG_PATH=/root/.kube/{env}.yaml SLACK_WEBHOOK_URL=your_slack_webhook_url SMTP_SERVER=your_smtp_server SMTP_PORT=587 SMTP_USER=your_smtp_user SMTP_PASSWORD=your_smtp_password SMTP_FROM=your_email@example.com SMTP_TO=recipient@example.com
-
Build and Run with Docker Compose:
docker-compose build --no-cache docker-compose up -d
-
Initialize Database:
docker-compose exec backend python -m models -
Access the Application:
- Backend:
http://localhost:8000 - Frontend:
http://localhost:3000
- Backend:
- Kubeconfigs: Ensure
~/.kube/dev.yaml,~/.kube/stag.yaml, and~/.kube/prod.yamlexist and are accessible to the backend container (mounted via Docker Compose). - GitHub Repositories: Configure
nxh-applications-dev,nxh-applications-stag, andnxh-applications-prodwith write access for theGITHUB_TOKEN. - DockerHub: Verify
DOCKERHUB_USERNAMEandDOCKERHUB_TOKENhave access tonexah/*repositories. - Notifications: Provide
SLACK_WEBHOOK_URLor SMTP settings for notifications. - Services: Update
backend/templates.pyto add new services and their environment variables.
- Health Check:
GET /health- Returns:
{"status": "ok"}
- Returns:
- Suggest Tags:
GET /suggest-tags/{org}/{repo}- Example:
curl http://localhost:8000/suggest-tags/nexah/contract-api - Returns available DockerHub tags.
- Example:
- Register User:
POST /register- Payload:
{"username": "test", "password": "pass"}
- Payload:
- Login:
POST /login- Payload:
{"username": "test", "password": "pass"}
- Payload:
- Generate Secret:
POST /generate-secret- Payload:
{"service": "contract-api", "env": "dev", "vars": {"NXH_DATABASE_HOST": "myhost"}, "secrets": ["NXH_DATABASE_HOST"], "namespace_type": "internal"}
- Payload:
- List Services:
GET /services- Returns available services and their environments.
- Get Service Env Keys:
GET /service-env-keys/{service}- Example:
curl http://localhost:8000/service-env-keys/contract-api
- Example:
- Deploy:
POST /deploy- Payload:
{"service": "contract-api", "tag": "v1.0.5", "env": "dev", "vars": {"NXH_DATABASE_HOST": "myhost", ...}, "secrets": ["NXH_DATABASE_HOST"], "namespace_type": "internal"} - Creates PR, logs deployment, and notifies for STAG/PROD.
- Payload:
- PR Status:
GET /pr-status/{pr_id}- Example:
curl http://localhost:8000/pr-status/123
- Example:
- WebSocket Status:
ws://localhost:8000/ws/pr-status/{deploy_id}- Streams PR and deployment status updates.
- List Pending Deployments:
GET /deployments- Returns pending STAG/PROD deployments.
- Get Deployment:
GET /deployments/{deploy_id}- Returns deployment status.
- Approve/Reject:
POST /approve- Payload:
{"deploy_id": 1, "approved": true}
- Payload:
- Deployment History:
GET /deployments/history?service={service}&env={env}&page={page}&per_page={per_page}- Example:
curl http://localhost:8000/deployments/history?service=contract-api&env=dev&page=1&per_page=10
- Example:
- Login: Enter credentials to access the dashboard.
- Services Tab: View available services and initiate deployments.
- Deploy Wizard: Select service, tag, environment, and input vars/secrets.
- Approvals Tab: Approve/reject pending STAG/PROD deployments.
- History Tab: View deployment history with filters and pagination.
- Status View: Real-time updates via WebSocket with Mermaid diagrams.
- Start Services:
docker-compose up -d
- Test Backend:
curl -X POST http://localhost:8000/register -d '{"username": "test", "password": "pass"}' -H "Content-Type: application/json" curl -X POST http://localhost:8000/login -d '{"username": "test", "password": "pass"}' -H "Content-Type: application/json" curl http://localhost:8000/services curl -X POST http://localhost:8000/deploy -d '{"service": "contract-api", "tag": "v1.0.5", "env": "dev", "vars": {"NXH_DATABASE_HOST": "myhost", "NXH_DATABASE_PORT": "5432", "NXH_DATABASE_NAME": "db", "NXH_DATABASE_USER": "user", "NXH_DATABASE_PASSWORD": "pass", "NXH_SHORTY_API_URL": "url", "NXH_SHORTY_API_KEY": "key", "NXH_SMS_API_URL": "url", "NXH_SMS_API_TOKEN": "token", "NXH_AWS_ACCESS_KEY_ID": "id", "NXH_AWS_SECRET_ACCESS_KEY": "key", "NXH_AWS_DEFAULT_REGION": "region", "NXH_AWS_BUCKET": "bucket", "NXH_AWS_USE_PATH_STYLE_ENDPOINT": "true", "NXH_AWS_SUPPRESS_PHP_DEPRECATION_WARNING": "true", "NXH_ORG_API_URL": "url", "NXH_AUTH_API_URL": "url", "NXH_APP_SLUG": "slug", "NXH_APP_ID": "id"}, "secrets": ["NXH_DATABASE_HOST"], "namespace_type": "internal"}' -H "Content-Type: application/json"
- Test Frontend:
- Open
http://localhost:3000 - Login, deploy a service, check status, approve a STAG deployment, and view history.
- Open
- Test WebSocket:
- Use a WebSocket client (e.g., Postman) to connect to
ws://localhost:8000/ws/pr-status/<deploy_id>.
- Use a WebSocket client (e.g., Postman) to connect to
- Fork the repository.
- Create a feature branch (
git checkout -b feature/my-feature). - Commit changes (
git commit -m "Add my feature"). - Push to the branch (
git push origin feature/my-feature). - Create a Pull Request.