2
2
3
3
[ ![ e2e] ( https://github.com/stefanprodan/gitops-istio/workflows/e2e/badge.svg )] ( https://github.com/stefanprodan/gitops-istio/actions )
4
4
5
- This guide walks you through setting up Istio on a Kubernetes cluster and
6
- automating A/B testing and canary releases with GitOps pipelines .
5
+ This is a self-paced workshop where you will get hands- on experience with GitOps and
6
+ Progressive Delivery using Kubernetes and Istio .
7
7
8
- ![ Progressive Delivery GitOps Pipeline] ( https://raw.githubusercontent.com/weaveworks/flagger/master/docs/diagrams/flagger-gitops-istio.png )
8
+ ## Introduction
9
+
10
+ ### What is GitOps?
11
+
12
+ GitOps is a way to do Continuous Delivery, it works by using Git as a source of truth
13
+ for declarative infrastructure and workloads.
14
+ For Kubernetes this means using ` git push ` instead of ` kubectl create/apply ` or ` helm install/upgrade ` .
15
+
16
+ In this workshop you'll be using GitHub to host the config repository and Flux as the GitOps delivery solution.
9
17
10
- Components:
18
+ ### What is Progressive Delivery?
11
19
12
- * ** Istio** service mesh
13
- * manages the traffic flows between microservices, enforcing access policies and aggregating telemetry data
14
- * ** Prometheus** monitoring system
15
- * time series database that collects and stores the service mesh metrics
16
- * ** Flux v2** continuous delivery
17
- * syncs YAMLs and Helm charts between git and clusters
18
- * scans container registries and deploys new images
19
- * ** Flagger** progressive delivery
20
- * automates the release process using Istio routing for traffic shifting and Prometheus metrics for canary analysis
20
+ Progressive delivery is an umbrella term for advanced deployment patterns like canaries, feature flags and A/B testing.
21
+ Progressive delivery techniques are used to reduce the risk of introducing a new software version in production
22
+ by giving app developers and SRE teams a fine-grained control over the blast radius.
23
+
24
+ In this workshop you'll be using Flagger and Prometheus to automate Canary Releases and A/B Testing for your applications.
25
+
26
+ ![ Progressive Delivery GitOps Pipeline] ( https://raw.githubusercontent.com/weaveworks/flagger/master/docs/diagrams/flagger-gitops-istio.png )
21
27
22
- ### Prerequisites
28
+ ## Prerequisites
23
29
24
30
You'll need a Kubernetes cluster ** v1.16** or newer with ` LoadBalancer ` support.
25
31
For testing purposes you can use Minikube with four CPUs and 4GB of memory.
26
32
27
- Install Flux CLI and yq :
33
+ Install the ` flux ` CLI and ` yq ` with Homebrew :
28
34
29
35
``` bash
30
36
brew install fluxcd/tap/flux yq
31
37
```
32
38
39
+ Binaries for macOS, Windows and Linux AMD64/ARM are available
40
+ to download on the [ flux2 release page] ( https://github.com/fluxcd/flux2/releases ) .
41
+
42
+ Verify that your cluster satisfies the prerequisites with:
43
+
44
+ ``` bash
45
+ flux check --pre
46
+ ```
47
+
33
48
Fork this repository and clone it:
34
49
35
50
``` bash
36
51
git clone https://github.com/< YOUR-USERNAME> /gitops-istio
37
52
cd gitops-istio
38
53
```
39
54
40
- ### Cluster bootstrap
55
+ ## Cluster bootstrap
41
56
42
57
Install Flux by specifying your fork URL:
43
58
@@ -57,7 +72,7 @@ When Flux has access to your repository it will do the following:
57
72
58
73
* installs the Istio operator
59
74
* waits for Istio control plane to be ready
60
- * installs Flagger and Grafana
75
+ * installs Flagger, Prometheus and Grafana
61
76
* creates the Istio public gateway
62
77
* creates the ` prod ` namespace
63
78
* creates the load tester deployment
@@ -69,7 +84,7 @@ pods to be injected with Istio sidecar, the Istio control plane must be up and r
69
84
70
85
With Flux v2 you can specify the execution order by defining dependencies between objects.
71
86
For example, in [ clusters/my-cluster/apps.yaml] ( https://github.com/stefanprodan/gitops-istio/blob/main/clusters/my-cluster/apps.yaml )
72
- we tell Flux that the ` apps ` reconciliation depends on the ` istio ` one:
87
+ we tell Flux that the ` apps ` reconciliation depends on the ` istio-system ` one:
73
88
74
89
``` yaml
75
90
apiVersion : kustomize.toolkit.fluxcd.io/v1beta1
@@ -88,13 +103,13 @@ spec:
88
103
prune : true
89
104
` ` `
90
105
91
- Watch Flux reconciling Istio, then the demo apps:
106
+ Watch Flux installing Istio first , then the demo apps:
92
107
93
108
` ` ` bash
94
109
watch flux get kustomizations
95
110
```
96
111
97
- ### Istio customization
112
+ ## Istio customization
98
113
99
114
![ Flux Istio Operator] ( https://raw.githubusercontent.com/fluxcd/helm-operator-get-started/master/diagrams/flux-istio-operator.png )
100
115
@@ -121,7 +136,7 @@ spec:
121
136
After modifying the Istio settings, you can push the change to git and Flux will apply it on the cluster.
122
137
The Istio operator will reconfigure the Istio control plane according to your changes.
123
138
124
- ### App bootstrap
139
+ ## Application bootstrap
125
140
126
141
When Flux syncs the Git repository with your cluster, it creates the frontend/backend deployment, HPA and a canary object.
127
142
Flagger uses the canary definition to create a series of objects: Kubernetes deployments,
@@ -166,7 +181,7 @@ kubectl -n istio-system get svc istio-ingressgateway -ojson | jq .status.loadBal
166
181
167
182
Open a browser and navigate to the ingress address, you'll see the frontend UI.
168
183
169
- ### Canary releases
184
+ ## Canary releases
170
185
171
186
Flagger implements a control loop that gradually shifts traffic to the canary while measuring key performance indicators
172
187
like HTTP requests success rate, requests average duration and pod health.
@@ -244,7 +259,7 @@ http://localhost:3000/d/flagger-istio/istio-canary?refresh=10s&orgId=1&var-names
244
259
245
260
Note that if new changes are applied to the deployment during the canary analysis, Flagger will restart the analysis phase.
246
261
247
- ### A/B testing
262
+ ## A/B testing
248
263
249
264
Besides weighted routing, Flagger can be configured to route traffic to the canary based on HTTP match conditions.
250
265
In an A/B testing scenario, you'll be using HTTP headers or cookies to target a certain segment of your users.
@@ -279,7 +294,7 @@ Trigger a deployment by updating the frontend container image:
279
294
yq e '.images[0].newTag="5.0.1"' -i ./apps/frontend/kustomization.yaml
280
295
281
296
git add -A && \
282
- git commit -m "backend 5.0.1" && \
297
+ git commit -m "frontend 5.0.1" && \
283
298
git push origin main
284
299
285
300
flux reconcile source git flux-system
@@ -311,7 +326,7 @@ prod frontend Progressing 100
311
326
prod backend Succeeded 0
312
327
` ` `
313
328
314
- # ## Rollback based on Istio metrics
329
+ # # Rollback based on Istio metrics
315
330
316
331
Flagger makes use of the metrics provided by Istio telemetry to validate the canary workload.
317
332
The frontend app [analysis](https://github.com/stefanprodan/gitops-istio/blob/main/apps/frontend/canary.yaml)
@@ -376,7 +391,7 @@ You can extend the analysis with custom metric checks targeting
376
391
For configuring alerting of the canary analysis for Slack, MS Teams, Discord or Rocket see the
377
392
[docs](https://docs.flagger.app/usage/alerting#canary-configuration).
378
393
379
- # ## Getting Help
394
+ # # Getting Help
380
395
381
396
If you have any questions about progressive delivery :
382
397
0 commit comments