forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
envoy_service_to_service.template.yaml
600 lines (600 loc) · 20.9 KB
/
envoy_service_to_service.template.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
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
{% import 'routing_helper.template.yaml' as helper -%}
{% import 'access_log_format_helper.template.yaml' as access_log_helper -%}
{% macro ingress_listener(protocol, address, port_value) -%}
- address:
socket_address:
protocol: {{protocol}}
address: {{address}}
port_value: {{port_value}}
traffic_direction: INBOUND
filter_chains:
- filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
codec_type: AUTO
stat_prefix: ingress_http
route_config:
name: local_route
virtual_hosts:
- name: local_service
domains:
- "*"
routes:
- match:
prefix: "/"
headers:
- name: content-type
string_match:
exact: application/grpc
route:
cluster: local_service_grpc
- match:
prefix: "/"
route:
cluster: local_service
http_filters:
- name: envoy.filters.http.health_check
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.health_check.v3.HealthCheck
pass_through_mode: true
headers:
- name: ":path"
string_match:
exact: "/healthcheck"
cache_time: 2.5s
- name: envoy.filters.http.buffer
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.buffer.v3.Buffer
max_request_bytes: 5242880
- name: envoy.filters.http.router
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
access_log:
- name: envoy.access_loggers.file
filter:
not_health_check_filter: {}
typed_config:
"@type": type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog
path: "/var/log/envoy/ingress_http.log"
{{ access_log_helper.ingress_full()|indent(10)}}
- name: envoy.access_loggers.file
filter:
and_filter:
filters:
- or_filter:
filters:
- status_code_filter:
comparison:
op: GE
value:
default_value: 400
runtime_key: access_log.access_error.status
- status_code_filter:
comparison:
op: EQ
value:
default_value: 0
runtime_key: access_log.access_error.status
- duration_filter:
comparison:
op: GE
value:
default_value: 2000
runtime_key: access_log.access_error.duration
- not_health_check_filter: {}
typed_config:
"@type": type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog
path: "/var/log/envoy/ingress_http_error.log"
{{ access_log_helper.ingress_sampled_log()|indent(10)}}
- name: envoy.access_loggers.file
filter:
and_filter:
filters:
- not_health_check_filter: {}
- runtime_filter:
runtime_key: access_log.ingress_http
typed_config:
"@type": type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog
path: "/var/log/envoy/ingress_http_sampled.log"
{{ access_log_helper.ingress_sampled_log()|indent(10)}}
common_http_protocol_options:
idle_timeout: 840s
{% endmacro -%}
static_resources:
listeners:
{{ ingress_listener("tcp", "0.0.0.0", 9211) | indent(2)}}
- address:
socket_address:
protocol: TCP
port_value: 9001
address: 127.0.0.1
traffic_direction: OUTBOUND
filter_chains:
- filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
codec_type: AUTO
stat_prefix: egress_http
route_config:
name: local_route
virtual_hosts:
{% for service, options in internal_virtual_hosts.items() %}
- name: {{ service }}
domains:
- {{ service }}
routes:
- match:
prefix: "/"
route:
{{ helper.make_route_internal(service, options)|indent(16) }}
{% endfor %}
add_user_agent: true
common_http_protocol_options:
idle_timeout: 840s
access_log:
- name: envoy.access_loggers.file
filter:
or_filter:
filters:
- status_code_filter:
comparison:
op: GE
value:
default_value: 400
runtime_key: access_log.access_error.status
- duration_filter:
comparison:
op: GE
value:
default_value: 2000
runtime_key: access_log.access_error.duration
- traceable_filter: {}
typed_config:
"@type": type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog
path: "/var/log/envoy/egress_http_error.log"
{{ access_log_helper.egress_error_log()|indent(10) }}
use_remote_address: true
http_filters:
- name: envoy.filters.http.ratelimit
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.ratelimit.v3.RateLimit
domain: envoy_service_to_service
rate_limit_service:
transport_api_version: V3
grpc_service:
envoy_grpc:
cluster_name: ratelimit
- name: envoy.filters.http.grpc_http1_bridge
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.grpc_http1_bridge.v3.Config
- name: envoy.filters.http.router
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
- address:
socket_address:
protocol: TCP
port_value: 9002
address: 127.0.0.1
traffic_direction: OUTBOUND
filter_chains:
- filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
codec_type: AUTO
stat_prefix: egress_http
rds:
config_source:
resource_api_version: V3
api_config_source:
api_type: GRPC
transport_api_version: V3
grpc_services:
envoy_grpc:
cluster_name: "rds"
route_config_name: rds_config_for_listener_1
add_user_agent: true
common_http_protocol_options:
idle_timeout: 840s
access_log:
- name: envoy.access_loggers.file
filter:
or_filter:
filters:
- status_code_filter:
comparison:
op: GE
value:
default_value: 400
runtime_key: access_log.access_error.status
- duration_filter:
comparison:
op: GE
value:
default_value: 2000
runtime_key: access_log.access_error.duration
- traceable_filter: {}
typed_config:
"@type": type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog
path: "/var/log/envoy/egress_http_error.log"
{{ access_log_helper.egress_error_log()|indent(10) }}
use_remote_address: true
http_filters:
- name: envoy.filters.http.ratelimit
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.ratelimit.v3.RateLimit
domain: envoy_service_to_service
rate_limit_service:
transport_api_version: V3
grpc_service:
envoy_grpc:
cluster_name: ratelimit
- name: envoy.filters.http.grpc_http1_bridge
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.grpc_http1_bridge.v3.Config
- name: envoy.filters.http.router
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
{% if external_virtual_hosts|length > 0 or mongos_servers|length > 0 %}{% endif -%}
{% for mapping in external_virtual_hosts -%}
- name: "{{ mapping['address']}}"
address:
socket_address:
address: "{{ mapping['address'] }}"
protocol: TCP
port_value: 9901
filter_chains:
- filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
codec_type: AUTO
common_http_protocol_options:
idle_timeout: 840s
stat_prefix: egress_{{ mapping['name'] }}
#update access_logs here
route_config:
virtual_hosts:
{% for host in mapping['hosts'] %}
- name: egress_{{ host['name'] }}
domains:
- "{{ host['domain'] }}"
routes:
- match:
prefix: "/"
route:
cluster: egress_{{ host['name'] }}
retry_policy:
retry_on: connect-failure
{% if host.get('host_rewrite', False) %}
host_rewrite_literal: "{{host['host_rewrite']}}"
{% endif %}
{% endfor %}
http_filters:
- name: envoy.filters.http.router
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
access_log:
- name: envoy.access_loggers.file
filter:
or_filter:
filters:
- status_code_filter:
comparison:
op: GE
value:
default_value: 400
runtime_key: access_log.access_error.status
- status_code_filter:
comparison:
op: EQ
value:
default_value: 0
runtime_key: access_log.access_error.status
{% if mapping.get('log_high_latency_requests', True) %}
- duration_filter:
comparison:
op: GE
value:
default_value: 2000
runtime_key: access_log.access_error.duration
{% endif %}
typed_config:
"@type": type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog
path: "/var/log/envoy/egress_{{ mapping['name'] }}_http_error.log"
{% if mapping.get('is_amzn_service', False) -%}
{{ access_log_helper.egress_error_amazon_service()|indent(10) }}
{% else -%}
{{ access_log_helper.egress_error_log()|indent(10) }}
{% endif %}
{% if (mongos_servers|length > 0) or (mongos_servers|length == 0 and not loop.last ) %}{% endif -%}
{% endfor -%}
{% for key, value in mongos_servers.items() -%}
- name : "{{ value['address'] }}"
address:
socket_address:
address: "{{ value['address'] }}"
protocol: TCP
port_value: 9003
filter_chains:
- filters:
- name: envoy.filters.network.tcp_proxy
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.tcp_proxy.v3.TcpProxy
stat_prefix: mongo_{{ key }}
cluster: mongo_{{ key }}
- name: envoy.filters.network.mongo_proxy
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.mongo_proxy.v3.MongoProxy
stat_prefix: "{{ key }}"
access_log: "/var/log/envoy/mongo_{{ key }}.log"
{% if value.get('ratelimit', False) %}
- name: envoy.filters.network.ratelimit
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.ratelimit.v3.RateLimit
stat_prefix: "{{ key }}"
domain: envoy_mongo_cps
descriptors:
entries:
- key: database
value: "{{ key }}"
{% endif %}
{% endfor -%}
clusters:
{% for service, options in internal_virtual_hosts.items() -%}
- {{ helper.internal_cluster_definition(service, options)|indent(2)}}
{% endfor -%}
{% for mapping in external_virtual_hosts -%}
{% for host in mapping['hosts'] -%}
- name: egress_{{ host['name'] }}
{% if host.get('ssl', False) %}
transport_socket:
name: envoy.transport_sockets.tls
typed_config:
"@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
common_tls_context:
validation_context:
trusted_ca:
filename: certs/cacert.pem
{% if host.get('verify_subject_alt_name', False) %}
match_typed_subject_alt_names:
- san_type: DNS
matcher:
exact: "{{host['verify_subject_alt_name'] }}"
{% endif %}
{% if host.get('sni', False) %}
sni: "{{ host['sni'] }}"
{% endif %}
connect_timeout: 1s
{% else %}
connect_timeout: 0.25s
{% endif %}
type: LOGICAL_DNS
lb_policy: ROUND_ROBIN
load_assignment:
cluster_name: egress_{{ host['name'] }}
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: {{ host['remote_address'] }}
port_value: {{ host['port_value'] }}
protocol: {{ host['protocol'] }}
{% endfor -%}
{% endfor -%}
{% for key, value in mongos_servers.items() -%}
- name: mongo_{{ key }}
connect_timeout: 0.25s
type: STRICT_DNS
lb_policy: RANDOM
load_assignment:
cluster_name: mongo_{{ key }}
endpoints:
- lb_endpoints:
{% for server in value['hosts'] -%}
- endpoint:
address:
socket_address:
address: {{ server['address'] }}
port_value: {{ server['port_value'] }}
protocol: {{ server['protocol'] }}
{% endfor -%}
{% endfor %}
- name: main_website
connect_timeout: 0.25s
type: LOGICAL_DNS
# Comment out the following line to test on v6 networks
dns_lookup_family: V4_ONLY
lb_policy: ROUND_ROBIN
load_assignment:
cluster_name: main_website
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: main_website.com
port_value: 443
protocol: TCP
transport_socket:
name: envoy.transport_sockets.tls
typed_config:
"@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
sni: www.main_website.com
- name: local_service
connect_timeout: 0.25s
type: STATIC
lb_policy: ROUND_ROBIN
load_assignment:
cluster_name: main_website
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: 127.0.0.1
port_value: 8080
protocol: TCP
circuit_breakers:
thresholds:
max_pending_requests: 30
max_connections: 100
- name: local_service_grpc
connect_timeout: 0.25s
type: STATIC
lb_policy: ROUND_ROBIN
typed_extension_protocol_options:
envoy.extensions.upstreams.http.v3.HttpProtocolOptions:
"@type": type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions
explicit_http_config:
http2_protocol_options: {}
load_assignment:
cluster_name: local_service_grpc
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: 127.0.0.1
port_value: 8081
protocol: TCP
circuit_breakers:
thresholds:
max_requests: 200
dns_lookup_family: V4_ONLY
- name: rds
connect_timeout: 0.25s
type: STRICT_DNS
lb_policy: ROUND_ROBIN
typed_extension_protocol_options:
envoy.extensions.upstreams.http.v3.HttpProtocolOptions:
"@type": type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions
explicit_http_config:
http2_protocol_options:
connection_keepalive:
interval: 30s
timeout: 5s
load_assignment:
cluster_name: rds
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: rds.yourcompany.net
port_value: 80
protocol: TCP
dns_lookup_family: V4_ONLY
- name: statsd
connect_timeout: 0.25s
type: STATIC
lb_policy: ROUND_ROBIN
load_assignment:
cluster_name: statsd
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: 127.0.0.1
port_value: 8125
protocol: TCP
dns_lookup_family: V4_ONLY
- name: lightstep_saas
connect_timeout: 1s
type: LOGICAL_DNS
lb_policy: ROUND_ROBIN
load_assignment:
cluster_name: lightstep_saas
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: collector-grpc.lightstep.com
port_value: 443
protocol: TCP
typed_extension_protocol_options:
envoy.extensions.upstreams.http.v3.HttpProtocolOptions:
"@type": type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions
explicit_http_config:
http2_protocol_options:
max_concurrent_streams: 100
transport_socket:
name: envoy.transport_sockets.tls
typed_config:
"@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
common_tls_context:
validation_context:
trusted_ca:
filename: certs/cacert.pem
match_typed_subject_alt_names:
- san_type: DNS
matcher:
exact: "collector-grpc.lightstep.com"
- name: cds_cluster
connect_timeout: 0.25s
type: STRICT_DNS
lb_policy: ROUND_ROBIN
load_assignment:
cluster_name: cds_cluster
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: cds.yourcompany.net
port_value: 80
protocol: TCP
- name: sds
connect_timeout: 0.25s
type: STRICT_DNS
lb_policy: ROUND_ROBIN
load_assignment:
cluster_name: sds
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: discovery.yourcompany.net
port_value: 80
protocol: TCP
dynamic_resources:
cds_config:
resource_api_version: V3
api_config_source:
api_type: REST
transport_api_version: V3
cluster_names:
- cds_cluster
refresh_delay: 30s
cluster_manager: {}
flags_path: "/etc/envoy/flags"
stats_sinks:
- name: envoy.stat_sinks.statsd
typed_config:
"@type": type.googleapis.com/envoy.config.metrics.v3.StatsdSink
tcp_cluster_name: statsd
layered_runtime:
layers:
- name: root
disk_layer:
symlink_root: /srv/configset/envoydata/current
subdirectory: envoy
- name: override
disk_layer:
symlink_root: /srv/configset/envoydata/current
subdirectory: envoy_override
append_service_cluster: true
- name: admin
admin_layer: {}
admin:
address:
socket_address:
protocol: TCP
address: 0.0.0.0
port_value: 9901