-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathenvoy.j2
187 lines (185 loc) · 8.03 KB
/
envoy.j2
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
{
"listeners": [
{% for listener in listeners %}
{
"address": "tcp://0.0.0.0:{{ listener.service_port }}",
{% if listener.use_proxy_proto -%}"use_proxy_proto": true,{%- endif %}
{% if listener.tls and listener.tls.ssl_context -%}
"ssl_context": {
{%- if listener.tls.cert_chain_file -%}
"cert_chain_file": "{{ listener.tls.cert_chain_file }}",
"private_key_file": "{{ listener.tls.private_key_file }}"{{ "," if listener.tls.alpn_protocols }}
{%- if listener.tls.alpn_protocols -%}
"alpn_protocols": "{{ listener.tls.alpn_protocols }}"
{%- endif -%}{{ "," if listener.tls.cacert_chain_file }}
{%- endif -%}
{%- if listener.tls.cacert_chain_file -%}
"ca_cert_file": "{{ listener.tls.cacert_chain_file }}"{{ "," if listener.tls.cert_required }}
{%- if listener.tls.cert_required -%}"require_client_certificate": true{%- endif %}
{%- endif %}
},
{%- endif -%}
"filters": [
{
"type": "read",
"name": "http_connection_manager",
"config": {
{%- if "use_remote_address" in listener -%}
"use_remote_address": {{ listener.use_remote_address | tojson }},
{%- endif -%}
"codec_type": "auto",
"stat_prefix": "ingress_http",
"access_log": [
{
"format": "ACCESS [%START_TIME%] \"%REQ(:METHOD)% %REQ(X-ENVOY-ORIGINAL-PATH?:PATH)% %PROTOCOL%\" %RESPONSE_CODE% %RESPONSE_FLAGS% %BYTES_RECEIVED% %BYTES_SENT% %DURATION% %RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)% \"%REQ(X-FORWARDED-FOR)%\" \"%REQ(USER-AGENT)%\" \"%REQ(X-REQUEST-ID)%\" \"%REQ(:AUTHORITY)%\" \"%UPSTREAM_HOST%\"\n",
"path": "/dev/fd/1"
}
],
{% if tracing -%}
"generate_request_id": true,
"tracing": {
"operation_name": "egress",
"request_headers_for_tags": {{ tracing.tag_headers | tojson }}
},
{%- endif %}
"route_config": {
"virtual_hosts": [
{
"name": "backend",
"domains": ["*"],
{%- if listener.require_tls -%}
"require_ssl": "all",
{%- endif -%}
"routes": [
{% for route in routes %}
{
"timeout_ms": {{ route.timeout_ms or 3000 }},
{%- if route.prefix -%}"prefix": "{{ route.prefix }}",{% endif %}
{%- if route.regex -%}"regex": {{ route.regex | tojson }},{% endif %}
{%- if route.case_sensitive -%}"case_sensitive": {{ route.case_sensitive | tojson }},{% endif %}
{%- if route.cors -%}
"cors": {{ route.cors | tojson }},
{% elif cors_default %}
"cors": {{ cors_default | tojson }},
{% endif %}
{%- if route.rate_limits -%}"rate_limits": {{ route.rate_limits | tojson }},{% endif %}
{%- if route.priority -%}"priority": "{{ route.priority }}",{% endif %}
{%- if route.use_websocket -%}"use_websocket": {{ route.use_websocket | tojson }},{% endif %}
{%- if route.headers -%}"headers": {{ route.headers | tojson }},{% endif %}
{%- if route.host_redirect -%}
"host_redirect": "{{ route.host_redirect }}"{%- if route.path_redirect -%},
"path_redirect": "{{ route.path_redirect }}"{% endif %}
{% else %}
{%- if route.prefix_rewrite -%}"prefix_rewrite": "{{ route.prefix_rewrite }}",{% endif %}
{%- if route.host_rewrite -%}"host_rewrite": "{{ route.host_rewrite }}",{% endif %}
{%- if route.auto_host_rewrite -%}"auto_host_rewrite": {{ route.auto_host_rewrite | tojson }},{% endif %}
{%- if route.request_headers_to_add -%}"request_headers_to_add": {{ route.request_headers_to_add | tojson }},{% endif %}
{%- if route.use_websocket -%}
"cluster": "{{ route.clusters[0].name }}"
{%- else -%}
"weighted_clusters": {
"clusters": [
{% for wc in route.clusters %}
{ "name": "{{wc.name}}", "weight": {{wc.weight}} }{{ "," if not loop.last }}
{% endfor %}
]
}{%- if route.shadow -%},
"shadow": {
"cluster": "{{ route.shadow.name }}"
}{%- endif -%}
{%- endif -%}
{% endif %}
{% if route.envoy_override %}
{% for key in route.envoy_override.keys() %},
"{{ key }}": {{ route.envoy_override[key] | tojson }}
{% endfor %}
{% endif %}
}
{{ "," if not loop.last }}
{% endfor %}
]
}
]
},
"filters": [
{
"name": "grpc_web",
"config":{}
},
{% for filter in filters -%}
{
{%- if filter.type -%}"type": "{{ filter.type }}",{% endif %}
"name": "{{ filter.name }}",
"config": {{ filter.config | tojson }}
}{{ "," if not loop.last }}
{%- endfor %}
]
}
}
]
}{{ "," if not loop.last }}
{%- endfor %}
],
"admin": {
"address": "tcp://127.0.0.1:{{ admin.admin_port }}",
"access_log_path": "/tmp/admin_access_log"
},
{% if tracing %}
"tracing": {
"http": {
"driver": {
"type": "{{ tracing.driver }}",
"config": {{ tracing.config | tojson }}
}
}
},
{% endif %}
"cluster_manager": {
"clusters": [
{% for cluster in clusters -%}
{
"name": "{{ cluster.name }}",
"connect_timeout_ms": {{ cluster.timeout_ms or 3000 }},
"type": "{{ cluster.type or 'strict_dns' }}",
"lb_type": "{{ cluster.lb_type or 'round_robin' }}",
{%- if cluster.features -%}"features": "{{ cluster.features }}",{% endif %}
"hosts": [
{% for url in cluster.urls -%}
{
"url": "{{ url }}"
}{{ "," if not loop.last }}
{% endfor %}
]{%- if cluster.circuit_breakers -%},
"circuit_breakers": {
"default": {
"max_connections": {{ cluster.circuit_breakers.max_connections or 1024 }},
"max_pending_requests": {{ cluster.circuit_breakers.max_pending or 1024 }},
"max_requests": {{ cluster.circuit_breakers.max_requests or 1024 }},
"max_retries": {{ cluster.circuit_breakers.max_retries or 3 }}
}
}{%- endif -%}{%- if cluster.outlier_detection -%},
"outlier_detection": {
"consecutive_5xx": {{ cluster.outlier_detection.consecutive_5xx or 5 }},
"max_ejection_percent": {{ cluster.outlier_detection.max_ejection or 100 }},
"interval_ms": {{ cluster.outlier_detection.interval_ms or 3000 }}
}{%- endif -%}{%- if cluster.tls_context -%},
"ssl_context": {
{% for entry in cluster.tls_array %}
"{{ entry.key }}": "{{ entry.value }}"{{ "," if not loop.last }}
{% endfor %}
}{%- endif -%}
}{{ "," if not loop.last }}
{% endfor %}
]
},
{% for grpc_service in grpc_services -%}
"{{ grpc_service.name }}": {
"type": "grpc_service",
"config": {
"cluster_name": "{{ grpc_service.cluster_name }}"
}
},
{% endfor %}
"statsd_udp_ip_address": "127.0.0.1:8125",
"stats_flush_interval_ms": 1001
}