Skip to content

Instantly share code, notes, and snippets.

@Mykolaichenko
Last active October 17, 2019 11:52
Show Gist options
  • Save Mykolaichenko/e539ef266e0c57190a76be5b257779e9 to your computer and use it in GitHub Desktop.
Save Mykolaichenko/e539ef266e0c57190a76be5b257779e9 to your computer and use it in GitHub Desktop.
Envoy as TCP proxy: helpful config parts
## Server configuration example
#
# In our relal case we have x4 address block in listener and x4 name block in cluster
#
static_resources:
listeners:
- address:
socket_address:
address: 0.0.0.0
port_value: 21211
filter_chains:
- filters:
- name: envoy.tcp_proxy
config:
stat_prefix: aws-prod-memcached-node-1
cluster: aws-prod-memcached-node-1
idle_timeout: { seconds: 600 }
max_connect_attempts: 3
access_log:
- name: envoy.file_access_log
config:
path: /dev/stdout
tls_context:
common_tls_context:
tls_certificates:
- certificate_chain:
filename: "/etc/envoy/certs/aws-prod-envoy.blah.com.crt"
private_key:
filename: "/etc/envoy/certs/aws-prod-envoy.blah.com.key"
validation_context:
trusted_ca:
filename: "/etc/ssl/certs/ca-certificates.crt"
clusters:
- name: aws-prod-memcached-node-1
connect_timeout: 10s
type: strict_dns
dns_refresh_rate: 60s
lb_policy: round_robin
hosts:
- socket_address:
address: elite-aws-prod-memcached-node-aws-prod-0.blah.com
port_value: 11211
health_checks:
- timeout: 10s
interval: 60s
unhealthy_threshold: 10
healthy_threshold: 5
tcp_health_check:
send: {text: '0101'}
always_log_health_check_failures: true
admin:
access_log_path: "/dev/null"
address:
socket_address:
address: 0.0.0.0
port_value: 8082
## Client configuration example
#
# In our relal case we have x4 address block in listener and x4 name block in cluster
#
static_resources:
listeners:
- address:
socket_address:
address: 0.0.0.0
port_value: 21211
protocol: TCP
filter_chains:
- filters:
- name: envoy.tcp_proxy
config:
stat_prefix: aws-prod-memcached-node-1
cluster: aws-prod-memcached-node-1
max_connect_attempts: 3
access_log:
- name: envoy.file_access_log
config:
path: /dev/stdout
clusters:
- name: aws-prod-memcached-node-1
connect_timeout: 1s
type: strict_dns
lb_policy: round_robin
hosts:
- socket_address:
address: aws-prod-envoy-1.blah.com
port_value: 21211
- socket_address:
address: aws-prod-envoy-2.blah.com
port_value: 21211
tls_context:
common_tls_context:
tls_certificates:
- certificate_chain:
filename: "/etc/envoy/certs/aws-prod-envoy.blah.com.crt"
private_key:
filename: "/etc/envoy/certs/aws-prod-envoy.blah.com.key"
validation_context:
trusted_ca:
filename: "/etc/ssl/certs/ca-certificates.crt"
verify_subject_alt_name:
- aws-prod-envoy.blah.com
health_checks:
- timeout: 10s
interval: 60s
unhealthy_threshold: 10
healthy_threshold: 5
tcp_health_check:
send: {text: '0101'}
always_log_health_check_failures: true
admin:
access_log_path: "/dev/null"
address:
socket_address:
address: 0.0.0.0
port_value: 8081
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment