Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/octu0/example-envoy-xds
Example implementation of envoy xDS v3 API
https://github.com/octu0/example-envoy-xds
envoy envoy-xds envoyproxy grpc grpc-server load-balancer proxy-server weighted-round-robin xds xds-server
Last synced: 3 months ago
JSON representation
Example implementation of envoy xDS v3 API
- Host: GitHub
- URL: https://github.com/octu0/example-envoy-xds
- Owner: octu0
- License: apache-2.0
- Created: 2020-12-17T15:58:10.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-03-25T09:06:22.000Z (10 months ago)
- Last Synced: 2024-06-19T06:55:59.360Z (7 months ago)
- Topics: envoy, envoy-xds, envoyproxy, grpc, grpc-server, load-balancer, proxy-server, weighted-round-robin, xds, xds-server
- Language: Go
- Homepage:
- Size: 75.2 KB
- Stars: 10
- Watchers: 2
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `example-envoy-xds`
[![Apache License](https://img.shields.io/github/license/octu0/example-envoy-xds)](https://github.com/octu0/example-envoy-xds/blob/master/LICENSE)
[![GoDoc](https://godoc.org/github.com/octu0/example-envoy-xds?status.svg)](https://godoc.org/github.com/octu0/example-envoy-xds)
[![Go Report Card](https://goreportcard.com/badge/github.com/octu0/example-envoy-xds)](https://goreportcard.com/report/github.com/octu0/example-envoy-xds)
[![Releases](https://img.shields.io/github/v/release/octu0/example-envoy-xds)](https://github.com/octu0/example-envoy-xds/releases)`example-envoy-xds` is an example of implementation of [envoy](https://www.envoyproxy.io/) and [control-plane](https://github.com/envoyproxy/go-control-plane/) using [v3 xDS](https://www.envoyproxy.io/docs/envoy/v1.15.3/api-docs/xds_protocol) API.
Features:
- xDS (EDS/CDS/LDS/RDS/ALS)
- Dynamic update of yaml files (using [fsnotify](github.com/fsnotify/fsnotify))
- Access log storage using ALS
- Configuration examples of various settings
- Configuration of Weighted Round Robin LoadBalancer## Bootstrapping
As bootstrap, in [envoy/envoy.yaml](https://github.com/octu0/example-envoy-xds/blob/master/envoy/envoy.yaml), specify `example-envoy-xds` in `xds_cluster` and `als_cluster`
This will allow xDS communication with grpc.For general use, `envoy.yaml` is used as a template file and replaced by `sed` in [docker-entrypoint.sh](https://github.com/octu0/example-envoy-xds/blob/master/envoy/docker-entrypoint.sh).
```yaml
node:
cluster: @ENVOY_XDS_CLUSTER@
id: @ENVOY_XDS_NODE_ID@
locality:
region: @ENVOY_XDS_LOCALITY_REGION@
zone: @ENVOY_XDS_LOCALITY_ZONE@admin:
access_log_path: /dev/null
address:
socket_address: { protocol: TCP, address: @ENVOY_ADMIN_LISTEN_HOST@, port_value: @ENVOY_ADMIN_LISTEN_PORT@ }dynamic_resources:
lds_config:
resource_api_version: V3
api_config_source:
api_type: GRPC
transport_api_version: V3
grpc_services:
- envoy_grpc: { cluster_name: xds_cluster }
set_node_on_first_message_only: true
cds_config:
resource_api_version: V3
api_config_source:
api_type: GRPC
transport_api_version: V3
grpc_services:
- envoy_grpc: { cluster_name: xds_cluster }
set_node_on_first_message_only: truestatic_resources:
clusters:
- name: xds_cluster
connect_timeout: 1s
type: STATIC
lb_policy: ROUND_ROBIN
http2_protocol_options: {}
load_assignment:
cluster_name: xds_cluster
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address: { protocol: TCP, address: @ENVOY_XDS_HOST@, port_value: @ENVOY_XDS_PORT@ }
- name: als_cluster
connect_timeout: 1s
type: STATIC
lb_policy: ROUND_ROBIN
http2_protocol_options: {}
upstream_connection_options:
tcp_keepalive: {}
load_assignment:
cluster_name: als_cluster
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address: { protocol: TCP, address: @ENVOY_ALS_HOST@, port_value: @ENVOY_ALS_PORT@ }layered_runtime:
layers:
- name: runtime0
rtds_layer:
rtds_config:
resource_api_version: V3
api_config_source:
transport_api_version: V3
api_type: GRPC
grpc_services:
envoy_grpc:
cluster_name: xds_cluster
name: runtime0
```When you start envoy with docker, you can specify IP and port of `example-envoy-xds` with environment variables.
```shell
$ docker run --net=host \
-e ENVOY_XDS_CLUSTER=example0 \
-e ENVOY_XDS_NODE_ID=envoy-node1 \
-e ENVOY_XDS_HOST=10.10.0.101 \
-e ENVOY_XDS_PORT=5000 \
-e ENVOY_XDS_LOCALITY_REGION=asia-northeast1 \
-e ENVOY_XDS_LOCALITY_ZONE=asia-northeast1-a \
-e ENVOY_ALS_HOST=10.10.0.101 \
-e ENVOY_ALS_PORT=5001 \
docker.pkg.github.com/octu0/example-envoy-xds/envoy:1.21.6
```Configure xDS with grpc, `example-envoy-xds` will be started so that envoy can communicate with it.
At this time, `node.id` of envoy (specified by `ENVOY_XDS_NODE_ID`) must be the same value,
otherwise the Snapshot will not be changed.```shell
$ docker run --net=host \
-e XDS_NODE_ID=envoy-node1 \
-e XDS_LISTEN_ADDR=0.0.0.0:5000 \
-e ALS_LISTEN_ADDR=0.0.0.0:5001 \
-e CDS_YAML=/app/vol/cds.yaml \
-e EDS_YAML=/app/vol/eds.yaml \
-e RDS_YAML=/app/vol/rds.yaml \
-e LDS_YAML=/app/vol/lds.yaml \
-v $(pwd):/app/vol \
docker.pkg.github.com/octu0/example-envoy-xds/example-envoy-xds:1.0.3 server
```Edit eds.yaml in current directory to make sure EDS are updated.
## Execution example
Using docker-compose to check the behavior.
```shell
$ docker-compose up -d
```and curl it.
```shell
$ curl -H 'Host:example.com' localhost:8080
legacy node-003$ curl -H 'Host:example.com' localhost:8080
new node-102
```## License
Apache 2.0, see LICENSE file for details.