v1/docs/deployment/README.md
This guide provides comprehensive instructions for deploying and managing the WiFi-DensePose application infrastructure using modern DevOps practices.
The WiFi-DensePose deployment architecture includes:
Ensure the following tools are installed on your system:
# AWS CLI
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
# kubectl
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
# Helm
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
# Terraform
wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update && sudo apt install terraform
# Docker
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
Configure AWS credentials with appropriate permissions:
aws configure
# Enter your AWS Access Key ID, Secret Access Key, and default region
Required AWS permissions:
git clone <repository-url>
cd wifi-densepose
# Set environment variables
export ENVIRONMENT=production
export AWS_REGION=us-west-2
export PROJECT_NAME=wifi-densepose
# Deploy complete infrastructure and application
./deploy.sh all
# Check application status
kubectl get pods -n wifi-densepose
# Access Grafana dashboard
kubectl port-forward svc/grafana 3000:80 -n monitoring
# Open http://localhost:3000 (admin/admin)
# Access application
kubectl get ingress -n wifi-densepose
βββ deploy.sh # Main deployment script
βββ Dockerfile # Application container image
βββ docker-compose.yml # Local development setup
βββ docker-compose.prod.yml # Production deployment
βββ .dockerignore # Docker build context optimization
βββ .github/workflows/ # GitHub Actions CI/CD
β βββ ci.yml # Continuous Integration
β βββ cd.yml # Continuous Deployment
β βββ security-scan.yml # Security scanning
βββ .gitlab-ci.yml # GitLab CI configuration
βββ k8s/ # Kubernetes manifests
β βββ namespace.yaml # Namespace definition
β βββ deployment.yaml # Application deployment
β βββ service.yaml # Service configuration
β βββ ingress.yaml # Ingress rules
β βββ configmap.yaml # Configuration management
β βββ secrets.yaml # Secret management template
β βββ hpa.yaml # Horizontal Pod Autoscaler
βββ terraform/ # Infrastructure as Code
β βββ main.tf # Main infrastructure definition
β βββ variables.tf # Configuration variables
β βββ outputs.tf # Output values
βββ ansible/ # Server configuration
β βββ playbook.yml # Ansible playbook
βββ monitoring/ # Monitoring configuration
β βββ prometheus-config.yml # Prometheus configuration
β βββ grafana-dashboard.json # Grafana dashboard
β βββ alerting-rules.yml # Alert rules
βββ logging/ # Logging configuration
βββ fluentd-config.yml # Fluentd configuration
# Deploy only infrastructure
./deploy.sh infrastructure
# Deploy only Kubernetes resources
./deploy.sh kubernetes
# Deploy only monitoring stack
./deploy.sh monitoring
# Build and push Docker images
./deploy.sh images
# Run health checks
./deploy.sh health
# Setup CI/CD
./deploy.sh cicd
# Development environment
ENVIRONMENT=development ./deploy.sh all
# Staging environment
ENVIRONMENT=staging ./deploy.sh all
# Production environment
ENVIRONMENT=production ./deploy.sh all
# Start local development environment
docker-compose up -d
# View logs
docker-compose logs -f
# Stop environment
docker-compose down
# Build production image
docker build -f Dockerfile -t wifi-densepose:latest .
# Multi-stage build for optimization
docker build --target production -t wifi-densepose:prod .
# View application logs
kubectl logs -f deployment/wifi-densepose -n wifi-densepose
# Scale application
kubectl scale deployment wifi-densepose --replicas=5 -n wifi-densepose
# Update application
kubectl set image deployment/wifi-densepose wifi-densepose=new-image:tag -n wifi-densepose
# Rollback deployment
kubectl rollout undo deployment/wifi-densepose -n wifi-densepose
# View resource usage
kubectl top pods -n wifi-densepose
kubectl top nodes
# Update ConfigMap
kubectl create configmap wifi-densepose-config \
--from-file=config/ \
--dry-run=client -o yaml | kubectl apply -f -
# Update Secrets
kubectl create secret generic wifi-densepose-secrets \
--from-literal=database-password=secret \
--dry-run=client -o yaml | kubectl apply -f -
Access Prometheus at: http://localhost:9090 (via port-forward)
Key metrics to monitor:
http_requests_total - HTTP request counthttp_request_duration_seconds - Request latencywifi_densepose_data_processed_total - Data processing metricswifi_densepose_model_inference_duration_seconds - ML model performanceAccess Grafana at: http://localhost:3000 (admin/admin)
Pre-configured dashboards:
# View application logs
kubectl logs -f -l app=wifi-densepose -n wifi-densepose
# Search logs in Elasticsearch
curl -X GET "elasticsearch:9200/wifi-densepose-*/_search" \
-H 'Content-Type: application/json' \
-d '{"query": {"match": {"level": "error"}}}'
Container Security
Kubernetes Security
Infrastructure Security
CI/CD Security
# Run security scan
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock \
aquasec/trivy image wifi-densepose:latest
# Kubernetes security scan
kubectl run --rm -i --tty kube-bench --image=aquasec/kube-bench:latest \
--restart=Never -- --version 1.20
Workflows are triggered on:
ci.yml): Pull requests and pushes to maincd.yml): Tags and main branch pushessecurity-scan.yml): Daily scheduled runsConfigure GitLab CI variables:
AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEYKUBE_CONFIGECR_REPOSITORY# Initialize Terraform
cd terraform
terraform init
# Plan deployment
terraform plan -var="environment=production"
# Apply changes
terraform apply
# Destroy infrastructure
terraform destroy
# Run Ansible playbook
ansible-playbook -i inventory ansible/playbook.yml
Pod Startup Issues
kubectl describe pod <pod-name> -n wifi-densepose
kubectl logs <pod-name> -n wifi-densepose
Service Discovery Issues
kubectl get endpoints -n wifi-densepose
kubectl get services -n wifi-densepose
Ingress Issues
kubectl describe ingress wifi-densepose-ingress -n wifi-densepose
kubectl get events -n wifi-densepose
Resource Issues
kubectl top pods -n wifi-densepose
kubectl describe nodes
# Application health
curl http://<ingress-url>/health
# Database connectivity
kubectl exec -it <pod-name> -n wifi-densepose -- pg_isready
# Redis connectivity
kubectl exec -it <pod-name> -n wifi-densepose -- redis-cli ping
# View HPA status
kubectl get hpa -n wifi-densepose
# Update HPA configuration
kubectl patch hpa wifi-densepose-hpa -n wifi-densepose -p '{"spec":{"maxReplicas":10}}'
# View cluster autoscaler logs
kubectl logs -f deployment/cluster-autoscaler -n kube-system
Resource Requests/Limits
Database Optimization
Caching Strategy
# Create database backup
kubectl exec -it postgres-pod -n wifi-densepose -- \
pg_dump -U postgres wifi_densepose > backup.sql
# Restore database
kubectl exec -i postgres-pod -n wifi-densepose -- \
psql -U postgres wifi_densepose < backup.sql
# Backup Kubernetes resources
kubectl get all -n wifi-densepose -o yaml > k8s-backup.yaml
# Backup ConfigMaps and Secrets
kubectl get configmaps,secrets -n wifi-densepose -o yaml > config-backup.yaml
Weekly
Monthly
Quarterly