Skip to content

Commit 5958eb6

Browse files
Matt Turnerianmiell
authored andcommitted
Examples for Istio VirtualService.networking.istio.io/v1beta1
1 parent 9e8ca44 commit 5958eb6

File tree

9 files changed

+234
-0
lines changed

9 files changed

+234
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: networking.istio.io/v1beta1
2+
kind: VirtualService
3+
metadata:
4+
name: delay-injection
5+
spec:
6+
hosts:
7+
- service-a
8+
http:
9+
- fault:
10+
delay:
11+
fixedDelay: 10s
12+
percentage:
13+
value: 100.0
14+
route:
15+
- destination:
16+
host: service-a
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: networking.istio.io/v1beta1
2+
kind: VirtualService
3+
metadata:
4+
name: error-injection
5+
spec:
6+
hosts:
7+
- service-a
8+
http:
9+
- fault:
10+
abort:
11+
httpStatus: 500
12+
# percentage:
13+
# value: 100.0
14+
route:
15+
- destination:
16+
host: service-a
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
apiVersion: networking.istio.io/v1beta1
2+
kind: VirtualService
3+
metadata:
4+
name: header-manipulation
5+
spec:
6+
hosts:
7+
- service-a
8+
http:
9+
- headers:
10+
# These rules are always applied
11+
request:
12+
set:
13+
manipulated: "true"
14+
route:
15+
- weight: 90
16+
destination:
17+
host: service-a-current
18+
headers:
19+
# These rules are applied only when this route is taken
20+
request:
21+
set:
22+
test-subset: "false"
23+
response:
24+
add:
25+
new-header: "foo"
26+
remove:
27+
- old-header
28+
- weight: 90
29+
destination:
30+
host: service-a-next
31+
headers:
32+
# These rules are applied only when this route is taken
33+
request:
34+
set:
35+
test-subset: "true"

Istio/VirtualService/identity.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: networking.istio.io/v1beta1
2+
kind: VirtualService
3+
metadata:
4+
name: identity
5+
spec:
6+
hosts:
7+
- service-a
8+
http:
9+
- route:
10+
- destination:
11+
host: service-a
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
apiVersion: networking.istio.io/v1beta1
2+
kind: VirtualService
3+
metadata:
4+
name: path-routing
5+
spec:
6+
hosts:
7+
- service-a
8+
http:
9+
- match:
10+
- uri:
11+
prefix: "/beta"
12+
ignoreUriCase: true
13+
route:
14+
- destination:
15+
host: service-a-vnext
16+
- route:
17+
- destination:
18+
host: service-a-current
19+
---
20+
apiVersion: networking.istio.io/v1beta1
21+
kind: VirtualService
22+
metadata:
23+
name: header-routing
24+
spec:
25+
hosts:
26+
- service-a
27+
http:
28+
- match:
29+
- headers:
30+
x-beta:
31+
exact: "yes please"
32+
route:
33+
- destination:
34+
host: service-a-vnext
35+
- route:
36+
- destination:
37+
host: service-a-current
38+
---
39+
apiVersion: networking.istio.io/v1beta1
40+
kind: VirtualService
41+
metadata:
42+
name: combined-routing
43+
spec:
44+
hosts:
45+
- service-a
46+
http:
47+
- match:
48+
- uri:
49+
prefix: "/beta"
50+
ignoreUriCase: true
51+
method:
52+
exact: "POST"
53+
headers: # Has header 'x-beta: im_sure'
54+
x-beta:
55+
exact: "im_sure"
56+
queryParams: # '?beta=really_sure'
57+
beta:
58+
exact: "really_sure"
59+
withoutHeaders: # Doesn't have header 'x-feeling: scared'
60+
x-feeling:
61+
exact: "scared"
62+
route:
63+
- destination:
64+
host: service-a-vnext
65+
- route:
66+
- destination:
67+
host: service-a-current
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
apiVersion: networking.istio.io/v1beta1
2+
kind: VirtualService
3+
metadata:
4+
name: redirect
5+
spec:
6+
hosts:
7+
- service-a
8+
http:
9+
# Sends an HTTP 301.
10+
- redirect:
11+
authority: service-a-vnext
12+
uri: /app
13+
---
14+
apiVersion: networking.istio.io/v1beta1
15+
kind: VirtualService
16+
metadata:
17+
name: rewrite
18+
spec:
19+
hosts:
20+
- service-a
21+
http:
22+
# Transparently re-writes the destination.
23+
- rewrite:
24+
authority: service-a-vnext
25+
uri: /app
26+
route:
27+
- destination:
28+
host: service-a-vnext

Istio/VirtualService/retry.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: networking.istio.io/v1beta1
2+
kind: VirtualService
3+
metadata:
4+
name: retry
5+
spec:
6+
hosts:
7+
- service-a
8+
http:
9+
- route:
10+
- destination:
11+
host: service-a
12+
retries:
13+
attempts: 3
14+
perTryTimeout: 1s
15+
retryOn: 5xx # Any HTTP 5xx status, timed-out/rejected/closed TCP connection

Istio/VirtualService/timeout.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: networking.istio.io/v1beta1
2+
kind: VirtualService
3+
metadata:
4+
name: timeout
5+
spec:
6+
hosts:
7+
- service-a
8+
http:
9+
# Istio will return an HTTP 504 to the caller if the destination doesn't reply in time
10+
- route:
11+
- destination:
12+
host: service-a
13+
timeout: 10s
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
apiVersion: networking.istio.io/v1beta1
2+
kind: VirtualService
3+
metadata:
4+
name: split-between-services
5+
spec:
6+
hosts:
7+
- service-a
8+
http:
9+
- route:
10+
- weight: 90
11+
destination:
12+
host: service-a-current
13+
- weight: 10
14+
destination:
15+
host: service-a-next
16+
---
17+
apiVersion: networking.istio.io/v1beta1
18+
kind: VirtualService
19+
metadata:
20+
name: split-between-subsets
21+
spec:
22+
hosts:
23+
- service-a
24+
http:
25+
- route:
26+
- weight: 90
27+
destination:
28+
host: service-a
29+
subset: v1
30+
- weight: 10
31+
destination:
32+
host: service-a
33+
subset: v2

0 commit comments

Comments
 (0)