Skip to content

Commit 8c3e1a2

Browse files
authored
feat: support management of multiple Istio VirtualService objects (argoproj#1381)
Signed-off-by: Darshan Hassan Shashikumar <[email protected]> Signed-off-by: Darshan Hassan Shashikumar <[email protected]>
1 parent f3af58a commit 8c3e1a2

File tree

20 files changed

+948
-137
lines changed

20 files changed

+948
-137
lines changed

docs/features/specification.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,19 @@ spec:
289289

290290
# Istio traffic routing configuration
291291
istio:
292+
# Either virtualService or virtualServices can be configured.
292293
virtualService:
293294
name: rollout-vsvc # required
294295
routes:
295296
- primary # optional if there is a single route in VirtualService, required otherwise
297+
virtualServices:
298+
# One or more virtualServices can be configured
299+
- name: rollouts-vsvc1 # required
300+
routes:
301+
- primary # optional if there is a single route in VirtualService, required otherwise
302+
- name: rollouts-vsvc2 # required
303+
routes:
304+
- secondary # optional if there is a single route in VirtualService, required otherwise
296305

297306
# NGINX Ingress Controller routing configuration
298307
nginx:

docs/getting-started/istio/index.md

Lines changed: 121 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ spec:
3030
stableService: rollouts-demo-stable
3131
trafficRouting:
3232
istio:
33-
virtualService:
34-
# Reference to a VirtualService which the controller updates with canary weights
35-
name: rollouts-demo-vsvc
33+
virtualServices:
34+
# One or more virtualServices can be configured
35+
# Reference to a VirtualService which the controller updates with canary weights
36+
- name: rollouts-demo-vsvc1
3637
# Optional if there is a single HTTP route in the VirtualService, otherwise required
3738
routes:
3839
- http-primary
@@ -44,18 +45,34 @@ spec:
4445
sniHosts:
4546
- reviews.bookinfo.com
4647
- localhost
48+
- name: rollouts-demo-vsvc2
49+
# Optional if there is a single HTTP route in the VirtualService, otherwise required
50+
routes:
51+
- http-secondary
52+
# Optional if there is a single HTTPS/TLS route in the VirtualService, otherwise required
53+
tlsRoutes:
54+
# Below fields are optional but if defined, they should match exactly with at least one of the TLS route match rules in your VirtualService
55+
- port: 443 # Only required if you want to match any rule in your VirtualService which contains this port
56+
# Only required if you want to match any rule in your VirtualService which contain all these SNI hosts
57+
sniHosts:
58+
- reviews.bookinfo.com
59+
- localhost
4760
...
4861
```
4962

50-
The VirtualService and route referenced in `trafficRouting.istio.virtualService` are required
51-
to have either HTTP or TLS, or both route specs that splits between the stable and the canary
63+
The VirtualService and route referenced in either `trafficRouting.istio.virtualService` or
64+
`trafficRouting.istio.virtualServices`. `trafficRouting.istio.virtualServices` helps in adding
65+
one or more virtualServices unlike `trafficRouting.istio.virtualService` where only single virtualService can be added.
66+
This is required to have either HTTP or TLS, or both route specs that splits between the stable and the canary
5267
services referenced in the rollout. If the route is HTTPS/TLS, we can match it based on the
5368
given port number and/or SNI hosts. Note that both of them are optional and only needed if you
5469
want to match any rule in your VirtualService which contains these.
5570

5671
In this guide, the two services are: `rollouts-demo-stable` and `rollouts-demo-canary` respectively.
5772
The weights for these two services should initially be set to 100% on the stable service and 0% on
5873
the canary service. During an update, these values will get modified by the controller.
74+
If there are multiple VirtualService then weight values for stable and canary service of each VirtualService
75+
will be modified by the controller simultaneously.
5976

6077
Note that since we have both the HTTP and HTTPS routes in our rollout spec and they match the
6178
VirtualService specs, weights will get modified for both these routes.
@@ -64,25 +81,67 @@ VirtualService specs, weights will get modified for both these routes.
6481
apiVersion: networking.istio.io/v1alpha3
6582
kind: VirtualService
6683
metadata:
67-
name: rollouts-demo-vsvc
84+
name: rollouts-demo-vsvc1
85+
spec:
86+
gateways:
87+
- rollouts-demo-gateway
88+
hosts:
89+
- rollouts-demo-vsvc1.local
90+
http:
91+
- name: http-primary # Should match rollout.spec.strategy.canary.trafficRouting.istio.virtualServices.routes
92+
route:
93+
- destination:
94+
host: rollouts-demo-stable # Should match rollout.spec.strategy.canary.stableService
95+
port:
96+
number: 15372
97+
weight: 100
98+
- destination:
99+
host: rollouts-demo-canary # Should match rollout.spec.strategy.canary.canaryService
100+
port:
101+
number: 15372
102+
weight: 0
103+
tls:
104+
- match:
105+
- port: 443 # Should match the port number of the route defined in rollout.spec.strategy.canary.trafficRouting.istio.virtualServices.tlsRoutes
106+
sniHosts: # Should match all the SNI hosts of the route defined in rollout.spec.strategy.canary.trafficRouting.istio.virtualServices.tlsRoutes
107+
- reviews.bookinfo.com
108+
- localhost
109+
route:
110+
- destination:
111+
host: rollouts-demo-stable # Should match rollout.spec.strategy.canary.stableService
112+
weight: 100
113+
- destination:
114+
host: rollouts-demo-canary # Should match rollout.spec.strategy.canary.canaryService
115+
weight: 0
116+
```
117+
118+
```yaml
119+
apiVersion: networking.istio.io/v1alpha3
120+
kind: VirtualService
121+
metadata:
122+
name: rollouts-demo-vsvc2
68123
spec:
69124
gateways:
70125
- rollouts-demo-gateway
71126
hosts:
72-
- rollouts-demo.local
127+
- rollouts-demo-vsvc2.local
73128
http:
74-
- name: http-primary # Should match rollout.spec.strategy.canary.trafficRouting.istio.virtualService.routes
129+
- name: http-secondary # Should match rollout.spec.strategy.canary.trafficRouting.istio.virtualServices.routes
75130
route:
76131
- destination:
77132
host: rollouts-demo-stable # Should match rollout.spec.strategy.canary.stableService
133+
port:
134+
number: 15373
78135
weight: 100
79136
- destination:
80137
host: rollouts-demo-canary # Should match rollout.spec.strategy.canary.canaryService
138+
port:
139+
number: 15373
81140
weight: 0
82141
tls:
83142
- match:
84-
- port: 443 # Should match the port number of the route defined in rollout.spec.strategy.canary.trafficRouting.istio.virtualService.tlsRoutes
85-
sniHosts: # Should match all the SNI hosts of the route defined in rollout.spec.strategy.canary.trafficRouting.istio.virtualService.tlsRoutes
143+
- port: 443 # Should match the port number of the route defined in rollout.spec.strategy.canary.trafficRouting.istio.virtualServices.tlsRoutes
144+
sniHosts: # Should match all the SNI hosts of the route defined in rollout.spec.strategy.canary.trafficRouting.istio.virtualServices.tlsRoutes
86145
- reviews.bookinfo.com
87146
route:
88147
- destination:
@@ -97,13 +156,13 @@ Run the following commands to deploy:
97156
98157
* A Rollout
99158
* Two Services (stable and canary)
100-
* An Istio VirtualService
159+
* One or more Istio VirtualServices
101160
* An Istio Gateway
102161
103162
```shell
104163
kubectl apply -f https://raw.githubusercontent.com/argoproj/argo-rollouts/master/docs/getting-started/istio/rollout.yaml
105164
kubectl apply -f https://raw.githubusercontent.com/argoproj/argo-rollouts/master/docs/getting-started/istio/services.yaml
106-
kubectl apply -f https://raw.githubusercontent.com/argoproj/argo-rollouts/master/docs/getting-started/istio/virtualsvc.yaml
165+
kubectl apply -f https://raw.githubusercontent.com/argoproj/argo-rollouts/master/docs/getting-started/istio/multipleVirtualsvc.yaml
107166
kubectl apply -f https://raw.githubusercontent.com/argoproj/argo-rollouts/master/docs/getting-started/istio/gateway.yaml
108167
```
109168

@@ -121,8 +180,9 @@ rollouts-demo-canary ClusterIP 10.103.146.137 <none> 80/TCP 37s
121180
rollouts-demo-stable ClusterIP 10.101.158.227 <none> 80/TCP 37s
122181

123182
$ kubectl get virtualservice
124-
NAME GATEWAYS HOSTS AGE
125-
rollouts-demo-vsvc [rollouts-demo-gateway] [rollouts-demo.local] 54s
183+
NAME GATEWAYS HOSTS AGE
184+
rollouts-demo-vsvc1 [rollouts-demo-gateway] [rollouts-demo-vsvc1.local] 54s
185+
rollouts-demo-vsvc2 [rollouts-demo-gateway] [rollouts-demo-vsvc2.local] 54s
126186

127187
$ kubectl get gateway
128188
NAME AGE
@@ -149,28 +209,71 @@ kubectl argo rollouts get rollout rollouts-demo
149209

150210
At this point, both the canary and stable version of the Rollout are running, with 5% of the
151211
traffic directed to the canary. To understand how this works, inspect the VirtualService which
152-
the Rollout was referencing. When looking at the VirtualService, we see that the route destination
212+
the Rollout was referencing. When looking at both the VirtualService, we see that the route destination
153213
weights have been modified by the controller to reflect the current weight of the canary.
154214

155215
```yaml
156216
apiVersion: networking.istio.io/v1beta1
157217
kind: VirtualService
158218
metadata:
159-
name: rollouts-demo-vsvc
219+
name: rollouts-demo-vsvc1
220+
namespace: default
221+
spec:
222+
gateways:
223+
- rollouts-demo-gateway
224+
hosts:
225+
- rollouts-demo-vsvc1.local
226+
http:
227+
- name: http-primary
228+
route:
229+
- destination:
230+
host: rollouts-demo-stable
231+
port:
232+
number: 15372
233+
weight: 95
234+
- destination:
235+
host: rollouts-demo-canary
236+
port:
237+
number: 15372
238+
weight: 5
239+
tls:
240+
- match:
241+
- port: 443
242+
sniHosts:
243+
- reviews.bookinfo.com
244+
- localhost
245+
route:
246+
- destination:
247+
host: rollouts-demo-stable
248+
weight: 95
249+
- destination:
250+
host: rollouts-demo-canary
251+
weight: 5
252+
```
253+
254+
```yaml
255+
apiVersion: networking.istio.io/v1beta1
256+
kind: VirtualService
257+
metadata:
258+
name: rollouts-demo-vsvc2
160259
namespace: default
161260
spec:
162261
gateways:
163262
- rollouts-demo-gateway
164263
hosts:
165-
- rollouts-demo.local
264+
- rollouts-demo-vsvc2.local
166265
http:
167266
- name: http-primary
168267
route:
169268
- destination:
170269
host: rollouts-demo-stable
270+
port:
271+
number: 15373
171272
weight: 95
172273
- destination:
173274
host: rollouts-demo-canary
275+
port:
276+
number: 15373
174277
weight: 5
175278
tls:
176279
- match:
@@ -187,4 +290,4 @@ spec:
187290
```
188291
189292
As the Rollout progresses through steps, the HTTP and/or TLS route(s) destination weights will be
190-
adjusted to match the current `setWeight` of the steps.
293+
adjusted to match the current `setWeight` of the steps.
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
apiVersion: networking.istio.io/v1alpha3
2+
kind: VirtualService
3+
metadata:
4+
name: rollouts-demo-vsvc1
5+
spec:
6+
gateways:
7+
- rollouts-demo-gateway
8+
hosts:
9+
- rollouts-demo-vsvc1.local
10+
http:
11+
- name: primary
12+
route:
13+
- destination:
14+
host: rollouts-demo-stable
15+
port:
16+
number: 15372
17+
weight: 100
18+
- destination:
19+
host: rollouts-demo-canary
20+
port:
21+
number: 15372
22+
weight: 0
23+
tls:
24+
- match:
25+
- port: 3000
26+
sniHosts:
27+
- reviews.bookinfo.com
28+
- localhost
29+
route:
30+
- destination:
31+
host: rollouts-demo-stable
32+
weight: 100
33+
- destination:
34+
host: rollouts-demo-canary
35+
weight: 0
36+
37+
---
38+
apiVersion: networking.istio.io/v1alpha3
39+
kind: VirtualService
40+
metadata:
41+
name: rollouts-demo-vsvc2
42+
spec:
43+
gateways:
44+
- rollouts-demo-gateway
45+
hosts:
46+
- rollouts-demo-vsvc2.local
47+
http:
48+
- name: secondary
49+
route:
50+
- destination:
51+
host: rollouts-demo-stable
52+
port:
53+
number: 15373
54+
weight: 100
55+
- destination:
56+
host: rollouts-demo-canary
57+
port:
58+
number: 15373
59+
weight: 0
60+
tls:
61+
- match:
62+
- port: 3000
63+
sniHosts:
64+
- reviews.bookinfo.com
65+
- localhost
66+
route:
67+
- destination:
68+
host: rollouts-demo-stable
69+
weight: 100
70+
- destination:
71+
host: rollouts-demo-canary
72+
weight: 0

docs/getting-started/istio/rollout.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ spec:
1010
stableService: rollouts-demo-stable
1111
trafficRouting:
1212
istio:
13-
virtualService:
14-
name: rollouts-demo-vsvc
13+
virtualServices:
14+
- name: rollouts-demo-vsvc1 # At least one virtualService is required
1515
routes:
1616
- primary # At least one route is required
17+
- name: rollouts-demo-vsvc2
18+
routes:
19+
- secondary # At least one route is required
1720
steps:
1821
- setWeight: 5
1922
- pause: {}

manifests/crds/rollout-crd.yaml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,8 +558,31 @@ spec:
558558
required:
559559
- name
560560
type: object
561-
required:
562-
- virtualService
561+
virtualServices:
562+
items:
563+
properties:
564+
name:
565+
type: string
566+
routes:
567+
items:
568+
type: string
569+
type: array
570+
tlsRoutes:
571+
items:
572+
properties:
573+
port:
574+
format: int64
575+
type: integer
576+
sniHosts:
577+
items:
578+
type: string
579+
type: array
580+
type: object
581+
type: array
582+
required:
583+
- name
584+
type: object
585+
type: array
563586
type: object
564587
nginx:
565588
properties:

0 commit comments

Comments
 (0)