-
Notifications
You must be signed in to change notification settings - Fork 1
/
virtualservice.yaml
85 lines (85 loc) · 3.2 KB
/
virtualservice.yaml
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
{{- if and .Values.virtualService.enabled .Values.ports }}
{{- $global := . }}
{{- $istioNs := .Values.virtualService.namespace }}
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: {{ include "nd-common.fullname" . }}
labels:
{{- include "nd-common.labels" . | nindent 4 }}
{{- with .Values.virtualService.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- with .Values.virtualService.gateways }}
gateways:
{{- range $gw := . }}
{{- if not (contains "/" $gw) }}
{{ fail ".Values.virtualService.gateways entries must be in the form of: namespace/gateway-name" }}
{{- end }}
- {{ $gw }}
{{- end }}
{{- end }}
hosts:
{{- range .Values.virtualService.hosts }}
- {{ tpl . $global | quote }}
{{- end }}
{{- /* https://istio.io/latest/docs/reference/config/networking/virtual-service/#HTTPRoute */}}
http:
- match:
{{- /* https://istio.io/latest/docs/reference/config/networking/virtual-service/#HTTPMatchRequest */}}
{{- with .Values.virtualService.matches }}
{{- tpl (toYaml .) $ | nindent 6 }}
{{- end }}
{{- /* https://istio.io/latest/docs/reference/config/networking/virtual-service/#HTTPMatchRequest */}}
{{- if .Values.virtualService.paths }}
{{- range $path := .Values.virtualService.paths }}
- uri:
prefix: {{ $path }}
{{- end }}
{{- else }}
- uri:
prefix: {{ .Values.virtualService.path }}
{{- end }}
{{- /* https://istio.io/latest/docs/reference/config/networking/virtual-service/#CorsPolicy */}}
{{- with .Values.virtualService.corsPolicy }}
corsPolicy:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- /* https://istio.io/latest/docs/reference/config/networking/virtual-service/#HTTPRetry */}}
{{- with .Values.virtualService.retries }}
retries:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- /* https://istio.io/latest/docs/reference/config/networking/virtual-service/#HTTPRoute */}}
{{- with .Values.virtualService.timeout }}
timeout: {{ . }}
{{- end }}
{{- /* https://istio.io/latest/docs/reference/config/networking/virtual-service/#HTTPRouteDestination */}}
route:
- destination:
host: {{ include "nd-common.serviceName" $ }}
port:
number: {{ .Values.virtualService.port }}
{{- /* https://istio.io/latest/docs/reference/config/networking/virtual-service/#HTTPFaultInjection */}}
{{- if and .Values.virtualService.maintenanceMode.enabled .Values.virtualService.fault }}
{{ fail "Both virtualService.maintenanceMode.enabled and virtualService.fault are set. Either set enabled to false or fault to {}" }}
{{- end }}
{{- if .Values.virtualService.maintenanceMode.enabled }}
fault:
abort:
httpStatus: {{ .Values.virtualService.maintenanceMode.httpStatus }}
percentage:
value: 100
{{- else }}
{{- with .Values.virtualService.fault }}
fault:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
{{- with .Values.virtualService.tls }}
tls:
{{- tpl . $global | nindent 4 }}
{{- end }}
{{- end }}