Stage 3 · Build
Testing & Release Confidence
Release Health Gates
Gate deploys with smoke tests, readiness probes, metric checks, canary analysis, and rollback triggers.
Why Health Gates
Deploying bad code causes outages. Health gates prevent broken code from reaching production. They verify the new version works before routing traffic to it. This is the last line of defense.
Smoke Tests
#!/bin/bash
set -e
URL="https://api.example.com"
TOKEN="$1"
echo "Running smoke tests..."
# Health check
curl -sf "$URL/healthz" || exit 1
# Auth check
STATUS=$(curl -s -o /dev/null -w "%{http_code}" -H "Authorization: Bearer $TOKEN" "$URL/api/v1/users")
[ "$STATUS" = "200" ] || exit 1
# Create and delete resource
ORDER_ID=$(curl -s -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" -d '{"product_id":"test","quantity":1}' "$URL/api/v1/orders" | jq -r '.id')
curl -sf -X DELETE -H "Authorization: Bearer $TOKEN" "$URL/api/v1/orders/$ORDER_ID"
echo "All smoke tests passed"Smoke tests verify basic functionality after deployment. They run against the live service and test critical paths. If smoke tests fail, the deployment is rolled back.
Readiness Probes
apiVersion: apps/v1
kind: Deployment
spec:
template:
spec:
containers:
- name: api
readinessProbe:
httpGet:
path: /readyz
port: 8080
initialDelaySeconds: 5
periodSeconds: 5
failureThreshold: 3
livenessProbe:
httpGet:
path: /healthz
port: 8080
initialDelaySeconds: 10
periodSeconds: 10
failureThreshold: 3Readiness probes prevent traffic from reaching pods that are not ready. The pod must pass readiness checks before Kubernetes adds it to the load balancer.
Metric Checks
Canary Analysis
Canary deployments route a small percentage of traffic to the new version. If the canary performs well, gradually increase traffic. If it fails, rollback immediately.
- Deploy new version to 5% of traffic.
- Monitor error rate, latency, and saturation for 10 minutes.
- If metrics are stable, increase to 25%, then 50%, then 100%.
- If metrics degrade, rollback immediately.
- Automate canary analysis with Flagger or Argo Rollouts.
Rollback Triggers
Manual rollback is slow. Automate it. If smoke tests fail or metrics degrade, rollback automatically. Humans can investigate afterward. Speed matters during outages.
Mark this lesson complete to store local progress and unlock a cleaner resume path the next time you visit.