Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Istio/VirtualService/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# VirtualService
`VirtualServices` configure routing rules for traffic.

Traffic is identified by the _Host_ it's addressed to in its layer 7 request header (there must be at most one VirtualService per Host).
For a given protocol, Routing Rules are then tried in order until one matches the attributes of the request.
The matching routing rule specifies a Service to which to send the request (a _Service_ is effectively a Kubernetes `Service`, qv).
Optionally, a subset of the Service's Pods can be targeted using Subsets (see `DestinationRule`)

VirtualServices can be thought of as an "active" bump-on-the-wire through which requests are sent.
They can apply various transforms to the traffic passing through them, such as header manipulation, delay injection, etc.
16 changes: 16 additions & 0 deletions Istio/VirtualService/delay-injection.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: delay-injection
spec:
hosts:
- service-a
http:
- fault:
delay:
fixedDelay: 10s
percentage:
value: 100.0
route:
- destination:
host: service-a
16 changes: 16 additions & 0 deletions Istio/VirtualService/error-injection.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: error-injection
spec:
hosts:
- service-a
http:
- fault:
abort:
httpStatus: 500
# percentage:
# value: 100.0
route:
- destination:
host: service-a
35 changes: 35 additions & 0 deletions Istio/VirtualService/header-manipulation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: header-manipulation
spec:
hosts:
- service-a
http:
- headers:
# These rules are always applied
request:
set:
manipulated: "true"
route:
- weight: 90
destination:
host: service-a-current
headers:
# These rules are applied only when this route is taken
request:
set:
test-subset: "false"
response:
add:
new-header: "foo"
remove:
- old-header
- weight: 90
destination:
host: service-a-next
headers:
# These rules are applied only when this route is taken
request:
set:
test-subset: "true"
11 changes: 11 additions & 0 deletions Istio/VirtualService/identity.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: identity
spec:
hosts:
- service-a
http:
- route:
- destination:
host: service-a
67 changes: 67 additions & 0 deletions Istio/VirtualService/layer-7-routing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: path-routing
spec:
hosts:
- service-a
http:
- match:
- uri:
prefix: "/beta"
ignoreUriCase: true
route:
- destination:
host: service-a-vnext
- route:
- destination:
host: service-a-current
---
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: header-routing
spec:
hosts:
- service-a
http:
- match:
- headers:
x-beta:
exact: "yes please"
route:
- destination:
host: service-a-vnext
- route:
- destination:
host: service-a-current
---
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: combined-routing
spec:
hosts:
- service-a
http:
- match:
- uri:
prefix: "/beta"
ignoreUriCase: true
method:
exact: "POST"
headers: # Has header 'x-beta: im_sure'
x-beta:
exact: "im_sure"
queryParams: # '?beta=really_sure'
beta:
exact: "really_sure"
withoutHeaders: # Doesn't have header 'x-feeling: scared'
x-feeling:
exact: "scared"
route:
- destination:
host: service-a-vnext
- route:
- destination:
host: service-a-current
28 changes: 28 additions & 0 deletions Istio/VirtualService/redirect-rewrite.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: redirect
spec:
hosts:
- service-a
http:
# Sends an HTTP 301.
- redirect:
authority: service-a-vnext
uri: /app
---
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: rewrite
spec:
hosts:
- service-a
http:
# Transparently re-writes the destination.
- rewrite:
authority: service-a-vnext
uri: /app
route:
- destination:
host: service-a-vnext
15 changes: 15 additions & 0 deletions Istio/VirtualService/retry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: retry
spec:
hosts:
- service-a
http:
- route:
- destination:
host: service-a
retries:
attempts: 3
perTryTimeout: 1s
retryOn: 5xx # Any HTTP 5xx status, timed-out/rejected/closed TCP connection
13 changes: 13 additions & 0 deletions Istio/VirtualService/timeout.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: timeout
spec:
hosts:
- service-a
http:
# Istio will return an HTTP 504 to the caller if the destination doesn't reply in time
- route:
- destination:
host: service-a
timeout: 10s
33 changes: 33 additions & 0 deletions Istio/VirtualService/traffic-split.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: split-between-services
spec:
hosts:
- service-a
http:
- route:
- weight: 90
destination:
host: service-a-current
- weight: 10
destination:
host: service-a-next
---
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: split-between-subsets
spec:
hosts:
- service-a
http:
- route:
- weight: 90
destination:
host: service-a
subset: v1
- weight: 10
destination:
host: service-a
subset: v2