Examples
Below we will use YAML representation of the config protos and a running example of a service proxying HTTP from 127.0.0.1:10000 to 127.0.0.2:1234.
Static
A minimal fully static bootstrap config is provided below:
admin:access_log_path: /tmp/admin_access.logaddress:socket_address: { address: 127.0.0.1, port_value: 9901 }static_resources:listeners:- name: listener_0address:socket_address: { address: 127.0.0.1, port_value: 10000 }filter_chains:- filters:- name: envoy.http_connection_managertyped_config:"@type": type.googleapis.com/envoy.config.filter.network.http_connection_manager.v2.HttpConnectionManagerstat_prefix: ingress_httpcodec_type: AUTOroute_config:name: local_routevirtual_hosts:- name: local_servicedomains: ["*"]routes:- match: { prefix: "/" }route: { cluster: some_service }http_filters:- name: envoy.routerclusters:- name: some_serviceconnect_timeout: 0.25stype: STATIClb_policy: ROUND_ROBINload_assignment:cluster_name: some_serviceendpoints:- lb_endpoints:- endpoint:address:socket_address:address: 127.0.0.1port_value: 1234
Mostly static with dynamic EDS
A bootstrap config that continues from the above example with dynamic endpoint discovery via an EDS gRPC management server listening on 127.0.0.1:5678 is provided below:
admin:access_log_path: /tmp/admin_access.logaddress:socket_address: { address: 127.0.0.1, port_value: 9901 }static_resources:listeners:- name: listener_0address:socket_address: { address: 127.0.0.1, port_value: 10000 }filter_chains:- filters:- name: envoy.http_connection_managertyped_config:"@type": type.googleapis.com/envoy.config.filter.network.http_connection_manager.v2.HttpConnectionManagerstat_prefix: ingress_httpcodec_type: AUTOroute_config:name: local_routevirtual_hosts:- name: local_servicedomains: ["*"]routes:- match: { prefix: "/" }route: { cluster: some_service }http_filters:- name: envoy.routerclusters:- name: some_serviceconnect_timeout: 0.25slb_policy: ROUND_ROBINtype: EDSeds_cluster_config:eds_config:api_config_source:api_type: GRPCgrpc_services:envoy_grpc:cluster_name: xds_cluster- name: xds_clusterconnect_timeout: 0.25stype: STATIClb_policy: ROUND_ROBINhttp2_protocol_options: {}upstream_connection_options:# configure a TCP keep-alive to detect and reconnect to the admin# server in the event of a TCP socket half open connectiontcp_keepalive: {}load_assignment:cluster_name: xds_clusterendpoints:- lb_endpoints:- endpoint:address:socket_address:address: 127.0.0.1port_value: 5678
Notice above that xds_cluster is defined to point Envoy at the management server. Even in an otherwise completely dynamic configurations, some static resources need to be defined to point Envoy at its xDS management server(s).
It’s important to set appropriate TCP Keep-Alive options in the tcp_keepalive block. This will help detect TCP half open connections to the xDS management server and re-establish a full connection.
In the above example, the EDS management server could then return a proto encoding of a DiscoveryResponse:
version_info: "0"resources:- "@type": type.googleapis.com/envoy.api.v2.ClusterLoadAssignmentcluster_name: some_serviceendpoints:- lb_endpoints:- endpoint:address:socket_address:address: 127.0.0.2port_value: 1234
The versioning and type URL scheme that appear above are explained in more detail in the streaming gRPC subscription protocol documentation.
Dynamic
A fully dynamic bootstrap configuration, in which all resources other than those belonging to the management server are discovered via xDS is provided below:
admin:access_log_path: /tmp/admin_access.logaddress:socket_address: { address: 127.0.0.1, port_value: 9901 }dynamic_resources:lds_config:api_config_source:api_type: GRPCgrpc_services:envoy_grpc:cluster_name: xds_clustercds_config:api_config_source:api_type: GRPCgrpc_services:envoy_grpc:cluster_name: xds_clusterstatic_resources:clusters:- name: xds_clusterconnect_timeout: 0.25stype: STATIClb_policy: ROUND_ROBINhttp2_protocol_options: {}upstream_connection_options:# configure a TCP keep-alive to detect and reconnect to the admin# server in the event of a TCP socket half open connectiontcp_keepalive: {}load_assignment:cluster_name: xds_clusterendpoints:- lb_endpoints:- endpoint:address:socket_address:address: 127.0.0.1port_value: 5678
The management server could respond to LDS requests with:
version_info: "0"resources:- "@type": type.googleapis.com/envoy.api.v2.Listenername: listener_0address:socket_address:address: 127.0.0.1port_value: 10000filter_chains:- filters:- name: envoy.http_connection_managertyped_config:"@type": type.googleapis.com/envoy.config.filter.network.http_connection_manager.v2.HttpConnectionManagerstat_prefix: ingress_httpcodec_type: AUTOrds:route_config_name: local_routeconfig_source:api_config_source:api_type: GRPCgrpc_services:envoy_grpc:cluster_name: xds_clusterhttp_filters:- name: envoy.router
The management server could respond to RDS requests with:
version_info: "0"resources:- "@type": type.googleapis.com/envoy.api.v2.RouteConfigurationname: local_routevirtual_hosts:- name: local_servicedomains: ["*"]routes:- match: { prefix: "/" }route: { cluster: some_service }
The management server could respond to CDS requests with:
version_info: "0"resources:- "@type": type.googleapis.com/envoy.api.v2.Clustername: some_serviceconnect_timeout: 0.25slb_policy: ROUND_ROBINtype: EDSeds_cluster_config:eds_config:api_config_source:api_type: GRPCgrpc_services:envoy_grpc:cluster_name: xds_cluster
The management server could respond to EDS requests with:
version_info: "0"resources:- "@type": type.googleapis.com/envoy.api.v2.ClusterLoadAssignmentcluster_name: some_serviceendpoints:- lb_endpoints:- endpoint:address:socket_address:address: 127.0.0.2port_value: 1234