📋 Task Description
Create production-ready Kubernetes manifests for deploying StarGate to Kubernetes clusters. Include Deployments, Services, ConfigMaps, Secrets, Ingress, HorizontalPodAutoscaler, and all necessary configurations. Setup local Kubernetes deployment using minikube or kind for testing and validation.
🎯 Objectives
- Create Kubernetes Deployment manifests
- Create Service manifests (ClusterIP, LoadBalancer)
- Create ConfigMaps for configuration
- Create Secrets for sensitive data
- Configure Ingress for external access
- Setup HorizontalPodAutoscaler (HPA)
- Configure resource requests and limits
- Setup persistent volume claims
- Create namespace configuration
- Configure health checks (liveness, readiness)
- Setup RBAC if needed
- Test deployment on local cluster (minikube/kind)
- Document Kubernetes deployment procedures
🎯 TECHNICAL-ANALYSIS.md Coverage
This issue covers Phase 11 - Sprint 11.1: Kubernetes:
✅ Create Kubernetes manifests - All manifests in k8s/ directory
✅ Setup ConfigMaps and Secrets - Configuration and credentials management
✅ Configure pod autoscaling - HPA with CPU/Memory metrics
✅ Deploy to local cluster (minikube/kind) - Scripts and documentation
📦 Deliverables
1. Create Namespace Configuration
Create k8s/namespace.yaml:
apiVersion: v1
kind: Namespace
metadata:
name: stargate
labels:
app: stargate
environment: production
2. Create ConfigMap
Create k8s/configmap.yaml:
apiVersion: v1
kind: ConfigMap
metadata:
name: stargate-config
namespace: stargate
labels:
app: stargate
data:
# Application Settings
ASPNETCORE_ENVIRONMENT: "Production"
# MongoDB Configuration
MongoDB__DatabaseName: "stargate"
# Redis Configuration
Redis__ConnectionString: "redis-service:6379"
# RabbitMQ Configuration
RabbitMQ__HostName: "rabbitmq-service"
RabbitMQ__Port: "5672"
RabbitMQ__VirtualHost: "stargate"
# Resilience Configuration
Resilience__Retry__MaxRetryAttempts: "3"
Resilience__CircuitBreaker__FailureThreshold: "0.5"
Resilience__CircuitBreaker__BreakDurationSeconds: "30"
Resilience__Timeout__DatabaseTimeoutSeconds: "30"
# Logging Configuration
Logging__LogLevel__Default: "Information"
Logging__LogLevel__Microsoft.AspNetCore: "Warning"
Logging__LogLevel__StarGate: "Information"
3. Create Secrets
Create k8s/secrets.yaml:
apiVersion: v1
kind: Secret
metadata:
name: stargate-secrets
namespace: stargate
labels:
app: stargate
type: Opaque
stringData:
# MongoDB Credentials
mongodb-username: admin
mongodb-password: CHANGE_ME_IN_PRODUCTION
mongodb-connection-string: mongodb://admin:CHANGE_ME_IN_PRODUCTION@mongodb-service:27017/stargate?authSource=admin
# Redis Credentials
redis-password: CHANGE_ME_IN_PRODUCTION
# RabbitMQ Credentials
rabbitmq-username: stargate
rabbitmq-password: CHANGE_ME_IN_PRODUCTION
4. Create MongoDB StatefulSet
Create k8s/mongodb-statefulset.yaml with Service and StatefulSet including:
- Persistent volume claims (10Gi)
- Resource requests/limits (CPU: 500m-2000m, Memory: 1Gi-2Gi)
- Liveness and readiness probes
5. Create Redis and RabbitMQ Deployments
Create k8s/redis-deployment.yaml and k8s/rabbitmq-deployment.yaml with:
- Services (ClusterIP)
- Deployments with PVCs
- Resource limits
- Health checks
6. Create StarGate Deployment
Create k8s/stargate-deployment.yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: stargate-server
namespace: stargate
spec:
replicas: 2
selector:
matchLabels:
app: stargate-server
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
template:
metadata:
labels:
app: stargate-server
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "8081"
spec:
containers:
- name: stargate-server
image: stargate/stargate-server:latest
ports:
- containerPort: 8080
name: http
- containerPort: 8081
name: metrics
env:
# ConfigMap and Secret references
- name: MongoDB__ConnectionString
valueFrom:
secretKeyRef:
name: stargate-secrets
key: mongodb-connection-string
resources:
requests:
cpu: 500m
memory: 512Mi
limits:
cpu: 2000m
memory: 1Gi
livenessProbe:
httpGet:
path: /health/live
port: 8080
initialDelaySeconds: 30
periodSeconds: 10
readinessProbe:
httpGet:
path: /health/ready
port: 8080
initialDelaySeconds: 10
periodSeconds: 5
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app
operator: In
values: [stargate-server]
topologyKey: kubernetes.io/hostname
7. Create Services
Create k8s/stargate-service.yaml with ClusterIP and LoadBalancer services.
8. Create Ingress
Create k8s/ingress.yaml for external HTTP/HTTPS access with TLS support.
9. Create HorizontalPodAutoscaler
Create k8s/hpa.yaml:
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: stargate-hpa
namespace: stargate
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: stargate-server
minReplicas: 2
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: 80
behavior:
scaleDown:
stabilizationWindowSeconds: 300
policies:
- type: Percent
value: 50
periodSeconds: 60
scaleUp:
stabilizationWindowSeconds: 0
policies:
- type: Percent
value: 100
periodSeconds: 30
10. Create RBAC
Create k8s/rbac.yaml with ServiceAccount, Role, and RoleBinding.
11. Create Deployment Scripts
Create scripts/setup-minikube.sh:
- Install minikube
- Start with 4 CPU, 8GB RAM, 20GB disk
- Enable metrics-server and ingress addons
Create scripts/k8s-deploy.sh:
- Deploy all manifests in correct order
- Wait for dependencies to be healthy
- Verify deployment
Create scripts/k8s-destroy.sh:
- Clean removal of all resources
12. Create Documentation
Create docs/KUBERNETES.md with:
- Quick start guide
- Architecture diagram
- Resource descriptions
- Configuration management
- Scaling procedures
- Monitoring commands
- Troubleshooting guide
- Production deployment checklist
✅ Acceptance Criteria
📝 Testing Instructions
# Setup local cluster
./scripts/setup-minikube.sh
# Build image
eval $(minikube docker-env)
./scripts/build-docker.sh
# Deploy
./scripts/k8s-deploy.sh minikube
# Verify
kubectl get all -n stargate
kubectl get pods -n stargate
# Check health
kubectl port-forward svc/stargate-service 8080:8080 -n stargate
curl http://localhost:8080/health
# Test autoscaling
kubectl get hpa -n stargate --watch
# Generate load
kubectl run -it --rm load-generator --image=busybox --restart=Never -- \
/bin/sh -c "while true; do wget -q -O- http://stargate-service.stargate:8080/health; done"
# Watch scaling
kubectl get pods -n stargate -w
# Cleanup
./scripts/k8s-destroy.sh
📚 References
🏷️ Labels
phase-11 production-readiness sprint-11.1 kubernetes k8s autoscaling
⏱️ Estimated Effort
12-16 hours
🔗 Dependencies
🔗 Related Issues
Part of Phase 11: Production Readiness - Sprint 11.1: Kubernetes
📋 Task Description
Create production-ready Kubernetes manifests for deploying StarGate to Kubernetes clusters. Include Deployments, Services, ConfigMaps, Secrets, Ingress, HorizontalPodAutoscaler, and all necessary configurations. Setup local Kubernetes deployment using minikube or kind for testing and validation.
🎯 Objectives
🎯 TECHNICAL-ANALYSIS.md Coverage
This issue covers Phase 11 - Sprint 11.1: Kubernetes:
✅ Create Kubernetes manifests - All manifests in k8s/ directory
✅ Setup ConfigMaps and Secrets - Configuration and credentials management
✅ Configure pod autoscaling - HPA with CPU/Memory metrics
✅ Deploy to local cluster (minikube/kind) - Scripts and documentation
📦 Deliverables
1. Create Namespace Configuration
Create
k8s/namespace.yaml:2. Create ConfigMap
Create
k8s/configmap.yaml:3. Create Secrets
Create
k8s/secrets.yaml:4. Create MongoDB StatefulSet
Create
k8s/mongodb-statefulset.yamlwith Service and StatefulSet including:5. Create Redis and RabbitMQ Deployments
Create
k8s/redis-deployment.yamlandk8s/rabbitmq-deployment.yamlwith:6. Create StarGate Deployment
Create
k8s/stargate-deployment.yaml:7. Create Services
Create
k8s/stargate-service.yamlwith ClusterIP and LoadBalancer services.8. Create Ingress
Create
k8s/ingress.yamlfor external HTTP/HTTPS access with TLS support.9. Create HorizontalPodAutoscaler
Create
k8s/hpa.yaml:10. Create RBAC
Create
k8s/rbac.yamlwith ServiceAccount, Role, and RoleBinding.11. Create Deployment Scripts
Create
scripts/setup-minikube.sh:Create
scripts/k8s-deploy.sh:Create
scripts/k8s-destroy.sh:12. Create Documentation
Create
docs/KUBERNETES.mdwith:✅ Acceptance Criteria
📝 Testing Instructions
📚 References
🏷️ Labels
phase-11production-readinesssprint-11.1kubernetesk8sautoscaling⏱️ Estimated Effort
12-16 hours
🔗 Dependencies
🔗 Related Issues
Part of Phase 11: Production Readiness - Sprint 11.1: Kubernetes