Zero-downtime deployment strategies for Sentinel.
Update Strategies
Overview
| Strategy | Downtime | Rollback | Resource Usage |
|---|---|---|---|
| Rolling Update | None | Fast | +50-100% |
| Blue-Green | None | Instant | +100% |
| Canary | None | Fast | +10-25% |
| In-Place | Brief | Manual | None |
Rolling Updates
Kubernetes
apiVersion: apps/v1
kind: Deployment
metadata:
name: sentinel
spec:
replicas: 3
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1 # Add 1 new pod before removing old
maxUnavailable: 0 # Never reduce below desired replicas
template:
spec:
containers:
- name: sentinel
image: ghcr.io/raskell-io/sentinel:1.2.0
readinessProbe:
httpGet:
path: /health
port: 9090
initialDelaySeconds: 5
periodSeconds: 5
livenessProbe:
httpGet:
path: /health
port: 9090
initialDelaySeconds: 10
periodSeconds: 10
Update:
# Update image
# Watch rollout
# Rollback if needed
Docker Swarm
# docker-compose.yml
version: '3.8'
services:
sentinel:
image: ghcr.io/raskell-io/sentinel:1.2.0
deploy:
replicas: 3
update_config:
parallelism: 1
delay: 10s
failure_action: rollback
order: start-first
rollback_config:
parallelism: 1
delay: 10s
healthcheck:
test:
interval: 10s
timeout: 5s
retries: 3
start_period: 10s
Update:
# Update service
# Watch update
# Rollback
systemd
#!/bin/bash
# rolling-update.sh
NEW_VERSION=
OLD_BINARY="/usr/local/bin/sentinel"
NEW_BINARY="/usr/local/bin/sentinel.new"
# Download new version
# Validate new binary
# Swap binaries
# Graceful restart
# Wait for health
for; do
if ; then
fi
done
# Rollback on failure
Blue-Green Deployment
Architecture
┌─────────────────┐
│ Load Balancer │
└────────┬────────┘
│
┌──────────────┴──────────────┐
│ │
┌───────▼───────┐ ┌─────────▼───────┐
│ Blue (v1.2) │ │ Green (v1.3) │
│ [ACTIVE] │ │ [STANDBY] │
└───────────────┘ └─────────────────┘
Kubernetes Implementation
# blue-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: sentinel-blue
labels:
app: sentinel
version: blue
spec:
replicas: 3
selector:
matchLabels:
app: sentinel
version: blue
template:
metadata:
labels:
app: sentinel
version: blue
spec:
containers:
- name: sentinel
image: ghcr.io/raskell-io/sentinel:1.2.0
---
# green-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: sentinel-green
labels:
app: sentinel
version: green
spec:
replicas: 3
selector:
matchLabels:
app: sentinel
version: green
template:
metadata:
labels:
app: sentinel
version: green
spec:
containers:
- name: sentinel
image: ghcr.io/raskell-io/sentinel:1.3.0
---
# service.yaml
apiVersion: v1
kind: Service
metadata:
name: sentinel
spec:
selector:
app: sentinel
version: blue # Switch to 'green' for cutover
ports:
- port: 8080
targetPort: 8080
Switch traffic:
# Deploy green
# Wait for ready
# Switch traffic
# Verify
# Remove blue after verification
Docker Compose
# docker-compose.blue-green.yml
version: '3.8'
services:
sentinel-blue:
image: ghcr.io/raskell-io/sentinel:1.2.0
networks:
- sentinel-net
sentinel-green:
image: ghcr.io/raskell-io/sentinel:1.3.0
networks:
- sentinel-net
profiles:
- green # Only start with --profile green
nginx:
image: nginx:alpine
ports:
- "8080:8080"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
networks:
- sentinel-net
Canary Deployment
Kubernetes with Ingress
# canary-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: sentinel-canary
spec:
replicas: 1 # Small number for canary
template:
metadata:
labels:
app: sentinel
track: canary
spec:
containers:
- name: sentinel
image: ghcr.io/raskell-io/sentinel:1.3.0
---
# Split traffic with Ingress annotations (NGINX)
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: sentinel-canary
annotations:
nginx.ingress.kubernetes.io/canary: "true"
nginx.ingress.kubernetes.io/canary-weight: "10" # 10% to canary
spec:
rules:
- http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: sentinel-canary
port:
number: 8080
Progressive rollout:
# Start with 10%
# Monitor metrics, increase to 25%
# Continue to 50%, then 100%
# Promote canary to stable
# Remove canary
Istio Traffic Splitting
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: sentinel
spec:
hosts:
- sentinel
http:
- route:
- destination:
host: sentinel
subset: stable
weight: 90
- destination:
host: sentinel
subset: canary
weight: 10
---
apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
name: sentinel
spec:
host: sentinel
subsets:
- name: stable
labels:
version: stable
- name: canary
labels:
version: canary
Graceful Shutdown
Configuration
system {
graceful-shutdown-timeout-secs 30
}
Behavior
- Stop accepting new connections
- Complete in-flight requests (up to timeout)
- Close idle connections
- Exit
Kubernetes Pod Lifecycle
spec:
terminationGracePeriodSeconds: 60
containers:
- name: sentinel
lifecycle:
preStop:
exec:
command:
- /bin/sh
- -c
- "sleep 5" # Allow time for endpoint removal
Health Check Integration
Readiness vs Liveness
| Probe | Purpose | Failure Action |
|---|---|---|
| Liveness | Is the process healthy? | Restart container |
| Readiness | Can it serve traffic? | Remove from service |
During Updates
readinessProbe:
httpGet:
path: /health
port: 9090
initialDelaySeconds: 5
periodSeconds: 5
successThreshold: 1
failureThreshold: 2
livenessProbe:
httpGet:
path: /health
port: 9090
initialDelaySeconds: 15
periodSeconds: 10
successThreshold: 1
failureThreshold: 3
Rollback Procedures
Kubernetes
# View rollout history
# Rollback to previous
# Rollback to specific revision
Docker Swarm
Manual Binary Rollback
# Keep old binary
# Restart
Automated Rollback
Based on Metrics
# Kubernetes with Argo Rollouts
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: sentinel
spec:
strategy:
canary:
steps:
- setWeight: 10
- pause:
- setWeight: 25
- pause:
- setWeight: 50
- pause:
analysis:
templates:
- templateName: success-rate
startingStep: 1
---
apiVersion: argoproj.io/v1alpha1
kind: AnalysisTemplate
metadata:
name: success-rate
spec:
metrics:
- name: success-rate
interval: 1m
successCondition: result[0] >= 0.95
provider:
prometheus:
address: http://prometheus:9090
query: |
sum(rate(sentinel_requests_total{status!~"5.."}[5m]))
/ sum(rate(sentinel_requests_total[5m]))
Pre-Update Checklist
- New version tested in staging
- Configuration validated
- Health checks pass
- Metrics baseline captured
- Rollback plan documented
- Team notified
Post-Update Verification
# Check health
# Verify metrics
|
# Check logs for errors
|
# Verify routing
Next Steps
- Monitoring - Observability setup
- Kubernetes - Cloud-native deployment
- Configuration Management - Config updates