others-Example YAML configuration file for Envoy
Purpose
Hi, this post would demo a fully working yaml configuration file for envoy, which is the leading open source software for microservice proxy and a core component in service mesh.
About Envoy
Envoy is hosted by the Cloud Native Computing Foundation (CNCF). If you are a company that wants to help shape the evolution of technologies that are container-packaged, dynamically-scheduled and microservices-oriented, consider joining the CNCF. For details about who’s involved and how Envoy plays a role, read the CNCF announcement.
The Yaml
static_resources:
listeners:
- name: listener
address:
socket_address: { address: 0.0.0.0, port_value: 10080 }
filter_chains:
- filters:
- name: envoy.http_connection_manager
config:
stat_prefix: ingress_http
route_config:
name: local_route
virtual_hosts:
- name: local_service
domains: ["*"]
routes:
- match: { prefix: "/" }
route: { host_rewrite: www.bswen.com, cluster: service_bswen }
http_filters:
- name: envoy.router
clusters:
- name: service_bswen
connect_timeout: 0.25s
type: LOGICAL_DNS
dns_lookup_family: V4_ONLY
lb_policy: ROUND_ROBIN
hosts: [{ socket_address: { address: bswen.com, port_value: 443 }}]
tls_context: { sni: www.bswen.com }
admin:
access_log_path: /tmp/admin_access.log
address:
socket_address: { address: 0.0.0.0, port_value: 9901 }
The above yaml would accomplish these jobs:
- Listen on localhost’s 10080, wait for the http requests
- It would proxy all incoming http requests to www.bswen.com
Start/Run envoy and test the url proxy
Now let’s save the above configuration file as envoy.yaml, and then start a docker instance like this:
docker run --name=bswenproxy -d -p 80:10080 \
-v envoy.yaml envoyproxy/envoy:latest
Here we start an envoy instance with the latest version.
Then we cat test the proxy like this:
curl localhost
You should see the homepage of bswen.com.
References
You can view some references as follows: