summaryrefslogtreecommitdiff
path: root/f3s/README-ROLLOUTS.md
blob: 60ec9b64bace903fe6c2595e85c33aa253890434 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# Argo Rollouts - Quick Reference

Progressive delivery (canary deployments) for the f3s cluster.

## TL;DR - Get Started in 5 Minutes

```bash
# 1. Install controller
cd /home/paul/git/conf/f3s/argo-rollouts
just install

# 2. Wait for ArgoCD sync (or force)
argocd app sync argo-rollouts
argocd app sync tracing-demo

# 3. Verify setup
cd /home/paul/git/conf/f3s/tracing-demo
just rollout-status

# 4. Run a demo (Terminal 1)
just rollout-watch

# 5. Trigger in another terminal (Terminal 2)
kubectl patch rollout tracing-demo-frontend -n services \
  --type='json' \
  -p='[{"op":"replace","path":"/spec/template/spec/containers/0/image","value":"registry.lan.buetow.org:30001/tracing-demo-frontend:latest"}]'

# 6. Watch progress in Terminal 1 (~4 minutes total)
```

Expected flow:
- 0-2 min: **50% traffic** to new version (canary phase 1)
- 2-4 min: **Wait** for confirmation (canary phase 2)
- 4+ min: **100% traffic** to new version (auto-promoted)

## Files Created

### Setup & Installation
- `argo-rollouts/Justfile` - Install/manage controller
- `argo-rollouts/values.yaml` - Helm config
- `argocd-apps/cicd/argo-rollouts.yaml` - ArgoCD app

### Demo App Configuration
- `tracing-demo/helm-chart/templates/frontend-rollout.yaml` - Canary definition
- `tracing-demo/Justfile` - New `just rollout-*` commands
- `tracing-demo/rollout-demo.sh` - Demo automation script

### Documentation
- `ARGO-ROLLOUTS-SUMMARY.md` - **START HERE** - Full overview
- `ROLLOUTS-SETUP.md` - **DETAILED GUIDE** - 5 demo scenarios
- `ROLLOUTS-CHECKLIST.md` - **DEPLOYMENT CHECKLIST** - Step-by-step
- `tracing-demo/ROLLOUTS-DEMO.md` - Technical walkthrough
- `README-ROLLOUTS.md` - This file

## Why Canary Deployments?

**Old way (Deployment)**:
- 2 old pods → removed
- 2 new pods → created
- ~5 seconds of potential traffic loss
- No way to validate before 100% rollout

**New way (Rollout with Canary)**:
- 2 old pods → 1 old + 1 new (50/50 traffic)
- Observe for 2 minutes
- If healthy → automatically promote to 2 new pods
- If unhealthy → abort, revert to 2 old pods
- Zero downtime, validated before full rollout

## Common Commands

```bash
cd /home/paul/git/conf/f3s/tracing-demo

# Watch rollout progress (real-time)
just rollout-watch

# Check current status
just rollout-status

# Detailed info
just rollout-info

# Skip waiting, promote now
just rollout-promote

# Abort and rollback
just rollout-abort

# View history
just rollout-history

# Generate load during rollout
just load-test
```

## What Happens During Canary

### Step 1: 50% Traffic (0-2 minutes)
```
Frontend Service
├── Stable ReplicaSet (old version): 1 pod → receives 50% traffic
└── Canary ReplicaSet (new version): 1 pod → receives 50% traffic
```

Monitor during this phase:
- Error rates
- Response latency
- Logs and traces
- Prometheus metrics

### Step 2: Pause (2 minutes)
```
Service pauses traffic shift, waiting for:
- Manual promotion via: kubectl argo rollouts promote ...
- Auto-promotion after 2 minutes
- Or abort: kubectl argo rollouts abort ...
```

### Step 3: 100% Traffic (4+ minutes)
```
Frontend Service
├── Stable ReplicaSet (new version): 2 pods → receives 100% traffic
└── Canary ReplicaSet (old version): 0 pods → terminated
```

## Architecture

```
Git Commit (new image)
    ↓
Git Server (conf.git)
    ↓
ArgoCD detects change
    ↓
Updates Rollout resource
    ↓
Argo Rollouts Controller
    ↓
    ├─→ Scales Canary ReplicaSet (1 new pod)
    ├─→ Frontend Service routes 50/50 traffic
    ├─→ Monitors health/metrics for 2 minutes
    └─→ Auto-promotes or waits for manual action
        ├─→ If healthy: Scale to 2 new, remove old
        └─→ If abort: Remove canary, keep old
```

## Demo Scenarios

See `ROLLOUTS-SETUP.md` for complete walkthrough of:

1. **Basic Canary** - Watch 50% → 100% progression
2. **Manual Promotion** - Skip waiting with `just rollout-promote`
3. **Abort/Rollback** - Fail canary and revert
4. **Prometheus Monitoring** - Track metrics during rollout
5. **GitOps Flow** - Commit code, watch auto-rollout

## Monitoring

### Command-line
```bash
# Real-time watch
kubectl argo rollouts get rollout tracing-demo-frontend -n services --watch

# Check metrics
kubectl top pods -n services -l app=tracing-demo-frontend
```

### Grafana
https://grafana.f3s.buetow.org

1. Explore → Tempo
2. Query: `{ resource.service.name = "frontend" }`
3. See traces from old and new versions

### Prometheus
```bash
# Port-forward
kubectl port-forward -n monitoring svc/prometheus 9090:9090
# Open http://localhost:9090

# Query pod status
kube_pod_status_phase{namespace="services", pod=~".*frontend.*"}
```

## Troubleshooting

**Controller not running?**
```bash
kubectl get pods -n cicd -l app.kubernetes.io/name=argo-rollouts
kubectl logs -n cicd -l app.kubernetes.io/name=argo-rollouts
```

**Rollout stuck?**
```bash
kubectl describe rollout tracing-demo-frontend -n services
kubectl get pods -n services -l app=tracing-demo-frontend
```

**Need plugin?**
```bash
curl -LO https://github.com/argoproj/argo-rollouts/releases/latest/download/kubectl-argo-rollouts-linux-amd64
sudo install -m 755 kubectl-argo-rollouts-linux-amd64 /usr/local/bin/kubectl-argo-rollouts
```

## Next Steps

1. Complete setup using `ROLLOUTS-CHECKLIST.md`
2. Run demo scenarios from `ROLLOUTS-SETUP.md`
3. Share with team
4. Optional: Add Istio for advanced traffic routing
5. Optional: Deploy Flagger for automated analysis
6. Migrate other services to Rollout

## Key Resources

| File | Purpose |
|------|---------|
| `ARGO-ROLLOUTS-SUMMARY.md` | Architecture & what was created |
| `ROLLOUTS-SETUP.md` | Complete setup & 5 demo scenarios |
| `ROLLOUTS-CHECKLIST.md` | Step-by-step deployment |
| `tracing-demo/ROLLOUTS-DEMO.md` | Technical details & troubleshooting |
| `argo-rollouts/README.md` | Controller installation guide |

## Support

- Argo Rollouts Docs: https://argoproj.github.io/argo-rollouts/
- Canary Strategy: https://argoproj.github.io/argo-rollouts/features/canary/
- Kubectl Plugin: https://argoproj.github.io/argo-rollouts/getting-started/#using-kubectl-with-argo-rollouts