┌──────────────────────────────────────────────────────────────────┐
│ Kubernetes Cluster │
│ │
│ ┌─────────────────┐ ┌─────────────────────────────────┐ │
│ │ RestAPI CRD │ │ RestAPI Operator │ │
│ │ │ │ │ │
│ │ ┌─────────────┐ │ │ ┌─────────────────────────────┐ │ │
│ │ │ Model │ │◄───┤ │ Controller Manager │ │ │
│ │ │ View │ │ │ │ │ │ │
│ │ │ Controller │ │ │ │ ┌─────────────────────────┐ │ │ │
│ │ │ Repository │ │ │ │ │ RestAPI Controller │ │ │ │
│ │ └─────────────┘ │ │ │ │ BlueGreen Manager │ │ │ │
│ │ │ │ │ │ Health Monitor │ │ │ │
│ │ ┌─────────────┐ │ │ │ │ AutoScaling Manager │ │ │ │
│ │ │AutoScaling │ │ │ │ └─────────────────────────┘ │ │ │
│ │ │HealthCheck │ │ │ └─────────────────────────────┘ │ │
│ │ │ BlueGreen │ │ └─────────────────────────────────┘ │
│ │ └─────────────┘ │ │
│ └─────────────────┘ │
│ │
│ ┌─────────────────────────────────────────────────────────────┐ │
│ │ Generated Resources │ │
│ │ │ │
│ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────────────┐ │ │
│ │ │Deployment│ │ Service │ │ HPA │ │ ConfigMap/Secret │ │ │
│ │ │ │ │ │ │ │ │ │ │ │
│ │ │ Model │ │ Model │ │ Model │ │ Environment │ │ │
│ │ │ View │ │ View │ │ View │ │ Variables │ │ │
│ │ │Controller│ │Controller│ │Controller│ │ │ │ │
│ │ │Repository│ │Repository│ │Repository│ │ │ │ │
│ │ └──────────┘ └──────────┘ └──────────┘ └──────────────────┘ │ │
│ └─────────────────────────────────────────────────────────────┘ │
└──────────────────────────────────────────────────────────────────┘
RestAPI:
spec:
# Application Configuration
image: string
replicas: int32
envVars: map[string]string
# MVC+R Components
model: ComponentSpec
view: ComponentSpec
controller: ComponentSpec
repository: ComponentSpec
# Features
autoScaling: AutoScalingSpec
healthCheck: HealthCheckSpec
blueGreen: BlueGreenSpec
status:
phase: string
replicas: int32
readyReplicas: int32
conditions: []Condition
activeEnvironment: string
lastDeploymentTime: Time- Purpose: Main reconciliation loop
- Responsibilities:
- Watch RestAPI resources
- Create/update Deployments and Services
- Manage component lifecycle
- Update resource status
- Purpose: Zero-downtime deployments
- Responsibilities:
- Maintain blue/green environments
- Traffic switching logic
- Deployment promotion
- Rollback capabilities
- Purpose: Application health management
- Responsibilities:
- Configure liveness/readiness probes
- Monitor component health
- Trigger healing actions
- Report health status
- Purpose: Dynamic scaling
- Responsibilities:
- Create HorizontalPodAutoscalers
- Monitor resource utilization
- Scale components independently
- Manage scaling policies
┌─────────────────┐
│ Model │
│ │
│ ┌─────────────┐ │
│ │ Business │ │
│ │ Logic │ │
│ │ │ │
│ │ Data │ │
│ │ Structures │ │
│ │ │ │
│ │ Validation │ │
│ └─────────────┘ │
└─────────────────┘
┌─────────────────┐
│ View │
│ │
│ ┌─────────────┐ │
│ │ Templates │ │
│ │ │ │
│ │ UI Logic │ │
│ │ │ │
│ │ Response │ │
│ │ Formatting │ │
│ └─────────────┘ │
└─────────────────┘
┌─────────────────┐
│ Controller │
│ │
│ ┌─────────────┐ │
│ │ Request │ │
│ │ Routing │ │
│ │ │ │
│ │ Input │ │
│ │ Validation │ │
│ │ │ │
│ │ Flow │ │
│ │ Control │ │
│ └─────────────┘ │
└─────────────────┘
┌─────────────────┐
│ Repository │
│ │
│ ┌─────────────┐ │
│ │ Data │ │
│ │ Access │ │
│ │ │ │
│ │ Database │ │
│ │ Operations │ │
│ │ │ │
│ │ Caching │ │
│ └─────────────┘ │
└─────────────────┘
┌─────────┐ ┌──────────────┐ ┌─────────┐ ┌────────────┐
│ Client │───►│ Controller │───►│ Model │───►│Repository │
│ │ │ │ │ │ │ │
│ │ │ • Routing │ │• Logic │ │• Database │
│ │ │ • Validation │ │• Rules │ │• Caching │
│ │◄───│ • Response │◄───│• Data │◄───│• Storage │
└─────────┘ └──────────────┘ └─────────┘ └────────────┘
│
▼
┌──────────────┐
│ View │
│ │
│ • Templates │
│ • Formatting │
│ • UI Logic │
└──────────────┘
┌─────────────────────────────────────────────────────────┐
│ Service Mesh │
│ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Model │ │ Controller │ │ Repository │ │
│ │ Service │◄──►│ Service │◄──►│ Service │ │
│ │ │ │ │ │ │ │
│ │ Port: 8080 │ │ Port: 8081 │ │ Port: 8082 │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
│ ▲ │
│ │ │
│ ┌─────────────┐ │
│ │ View │ │
│ │ Service │ │
│ │ │ │
│ │ Port: 3000 │ │
│ └─────────────┘ │
└─────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────┐
│ Blue-Green Deployment │
│ │
│ ┌──────────────────────┐ ┌─────────────────────────────┐ │
│ │ Blue Environment │ │ Green Environment │ │
│ │ │ │ │ │
│ │ ┌─────┐ ┌──────────┐ │ │ ┌─────┐ ┌─────────────────┐ │ │
│ │ │Model│ │Controller│ │ │ │Model│ │ Controller │ │ │
│ │ │ v1 │ │ v1 │ │ │ │ v2 │ │ v2 │ │ │
│ │ └─────┘ └──────────┘ │ │ └─────┘ └─────────────────┘ │ │
│ │ │ │ │ │
│ │ ┌─────┐ ┌──────────┐ │ │ ┌─────┐ ┌─────────────────┐ │ │
│ │ │View │ │Repository│ │ │ │View │ │ Repository │ │ │
│ │ │ v1 │ │ v1 │ │ │ │ v2 │ │ v2 │ │ │
│ │ └─────┘ └──────────┘ │ │ └─────┘ └─────────────────┘ │ │
│ └──────────────────────┘ └─────────────────────────────┘ │
│ ▲ │
│ │ │
│ ┌─────────────────────┐ │
│ │ Load Balancer │ │
│ │ (Service) │ │
│ │ │ │
│ │ Traffic: 100% Blue │ │
│ └─────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
┌───────────────────────────────────────────────────────────────┐
│ Auto-scaling System │
│ │
│ ┌─────────────────┐ ┌─────────────────────────────────┐ │
│ │ Metrics Server │ │ HPA Controller │ │
│ │ │ │ │ │
│ │ • CPU Usage │───►│ • Scale Decisions │ │
│ │ • Memory Usage │ │ • Target Replicas │ │
│ │ • Custom Metrics│ │ • Scaling Events │ │
│ └─────────────────┘ └─────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────────────────────────────────────────────────┐ │
│ │ Component Deployments │ │
│ │ │ │
│ │ ┌─────────┐ ┌─────────┐ ┌──────────┐ ┌─────────────────┐ │ │
│ │ │ Model │ │ View │ │Controller│ │ Repository │ │ │
│ │ │ │ │ │ │ │ │ │ │ │
│ │ │Min: 1 │ │Min: 1 │ │Min: 2 │ │ Min: 1 │ │ │
│ │ │Max: 10 │ │Max: 5 │ │Max: 20 │ │ Max: 8 │ │ │
│ │ │CPU: 70% │ │CPU: 80% │ │CPU: 60% │ │ CPU: 75% │ │ │
│ │ └─────────┘ └─────────┘ └──────────┘ └─────────────────┘ │ │
│ └──────────────────────────────────────────────────────────┘ │
└───────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────┐
│ RBAC Security │
│ │
│ ┌─────────────────┐ ┌─────────────────────────────────┐ │
│ │ Service Account │ │ Roles │ │
│ │ │ │ │ │
│ │ restapi- │───►│ • restapis (CRUD) │ │
│ │ operator │ │ • deployments (CRUD) │ │
│ │ │ │ • services (CRUD) │ │
│ └─────────────────┘ │ • hpa (CRUD) │ │
│ │ • configmaps (CRUD) │ │
│ │ • secrets (Read) │ │
│ └─────────────────────────────────┘ │
│ │
│ ┌────────────────────────────────────────────────────────┐ │
│ │ Network Policies │ │
│ │ │ │
│ │ • Operator ◄──► API Server │ │
│ │ • Components ◄──► Internal Services │ │
│ │ • External ◄──► View Component Only │ │
│ └────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
- Model: CPU-intensive, higher CPU limits
- View: Memory-intensive, higher memory limits
- Controller: Balanced CPU/Memory
- Repository: I/O intensive, persistent storage
- Horizontal: Scale replicas based on load
- Vertical: Adjust resource limits per component
- Predictive: Scale based on historical patterns
- Reactive: Scale based on real-time metrics
┌───────────────────────────────────────────────────────────────┐
│ Observability Stack │
│ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────┐ │
│ │ Prometheus │ │ Grafana │ │ Jaeger │ │
│ │ │ │ │ │ │ │
│ │ • Metrics │───►│ • Dashboard │ │ • Tracing │ │
│ │ • Alerts │ │ • Alerts │ │ • Performance │ │
│ └─────────────┘ └─────────────┘ └─────────────────┘ │
│ ▲ ▲ │
│ │ │ │
│ ┌──────────────────────────────────────────────────────────┐ │
│ │ Application Components │ │
│ │ │ │
│ │ ┌─────────┐ ┌─────────┐ ┌──────────┐ ┌─────────────────┐ │ │
│ │ │ Model │ │ View │ │Controller│ │ Repository │ │ │
│ │ │ │ │ │ │ │ │ │ │ │
│ │ │/metrics │ │/metrics │ │/metrics │ │ /metrics │ │ │
│ │ │/health │ │/health │ │/health │ │ /health │ │ │
│ │ └─────────┘ └─────────┘ └──────────┘ └─────────────────┘ │ │
│ └──────────────────────────────────────────────────────────┘ │
└───────────────────────────────────────────────────────────────┘
This architecture provides a robust, scalable, and maintainable platform for deploying MVC+R pattern applications in Kubernetes with enterprise-grade features.