• Stars
    star
    131
  • Rank 266,110 (Top 6 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created about 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Caching, aggregation, and relaying for xDS compliant clients and origin servers

xds-relay

Caching, aggregation, and relaying for xDS compliant clients and origin servers

Contact

  • Slack: Slack, to get invited go here. Please join the #xds-relay channel for communication regarding this project.

Contributing

To get started:

Example

In this example we're going to run an instance of a management server that emits xDS data every 10 seconds which will be relayed by an instance of xds-relay to 2 instances of envoy.

The goal of this example is to have the envoy instances mapped to the same key in xds-relay, namely the cache key staging_cds.

Requirements

Steps

Management Server

First build the example management server:

make build-example-management-server

This will produce a binary called example-management-server under the bin directory. This binary runs a simple management server based on go-control-plane SnapshotCache. It produces a batch of xDS data with a random version every 10 seconds.

Open a window on your terminal and simply run:

./bin/example-management-server

xds-relay instance

Next step is to configure the xds-relay server. For that we need to provide 2 files:

  • an aggregation rules file
  • a bootstrap file

You'll find one example of each file in the example/config-files directory, aggregation-rules.yaml and xds-relay-bootstrap.yaml respectively.

You're now ready to run xds-relay locally. Open another window in your terminal and run:

./bin/xds-relay -a example/config-files/aggregation-rules.yaml -c example/config-files/xds-relay-bootstrap.yaml -m serve

Two envoy instances

As a final step, it's time to connect 2 envoy clients to xds-relay. If you do not have envoy installed, you can use getenvoy to install the binary for your OS. You're going to find 2 files named envoy-bootstrap-1.yaml and envoy-bootstrap-2.yaml that we're going to use to connect the envoy instances to xds-relay. Open 2 terminal windows and run:

envoy --base-id 0 -c example/config-files/envoy-bootstrap-1.yaml # on the first window
envoy --base-id 1 -c example/config-files/envoy-bootstrap-2.yaml # on the second window

And voilà! You should be seeing logs flowing in both the terminal window where you're running xds-relay and on each of the envoy ones.

How to validate that xds-relay is working?

We expose the contents of the cache in xds-relay via an endpoint, so we can use that to verify what are the contents of the cache for the keys being requested by the two envoy clients:

curl -s 0:6070/cache/staging_cds | jq '(.Cache[0].Resp.Resources.Clusters | map({"name": .name})) as $resp_clusters | (.Cache[0].Requests | map({"version_info": .version_info, "node.id": .node.id, "node.cluster": .node.cluster})) as $reqs | {"response": {"version": .Cache[0].Resp.VersionInfo, "clusters": $resp_clusters}, "requests": $reqs}'

Sample result:

curl -s 0:6070/cache/staging_cds | jq '(.Cache[0].Resp.Resources.Clusters | map({"name": .name})) as $resp_clusters | (.Cache[0].Requests | map({"version_info": .version_info, "node.id": .node.id, "node.cluster": .node.cluster})) as $reqs | {"response": {"version": .Cache[0].Resp.VersionInfo, "clusters": $resp_clusters}, "requests": $reqs}'
{
  "response": {
    "version": "v66936",
    "clusters": [
      {
        "name": "cluster-v66936-0"
      },
      {
        "name": "cluster-v66936-1"
      },
      {
        "name": "cluster-v66936-2"
      }
    ],
    "requests": [
      {
        "version_info": "v66936",
        "node.id": "envoy-client-1",
        "node.cluster": "staging"
      },
      {
        "version_info": "v66936",
        "node.id": "envoy-client-2",
        "node.cluster": "staging"
      }
    ]
  }
}

Envoy also exposes an endpoint that lets us investigate what's the current state of the configuration data. If we focus solely on the dynamic cluster information being relayed by xds-relay, we can use curl to inspect the envoys by running:

curl -s 0:19000/config_dump | jq '.configs | (.[1].dynamic_active_clusters | map({"version": .version_info, "cluster": .cluster.name})) as $clusters | {"clusters": $clusters}'

Sample result:

curl -s 0:19000/config_dump | jq '.configs | (.[1].dynamic_active_clusters | map({"version": .version_info, "cluster": .cluster.name})) as $clusters | {"clusters": $clusters}'
{
  "clusters": [
    {
      "version": "v56870",
      "cluster": "cluster-v56870-0"
    },
    {
      "version": "v56870",
      "cluster": "cluster-v56870-1"
    },
    {
      "version": "v56870",
      "cluster": "cluster-v56870-2"
    }
  ]
}

This is a gif of a tmux session demonstrating this example:

demo

More Repositories

1

envoy

Cloud-native high-performance edge/middle/service proxy
C++
23,692
star
2

ratelimit

Go/gRPC service designed to enable generic rate limit scenarios from different types of applications.
Go
2,080
star
3

go-control-plane

Go implementation of data-plane-api
Go
1,441
star
4

gateway

Manages Envoy Proxy as a Standalone or Kubernetes-based Application Gateway
Go
1,305
star
5

envoy-mobile

Client HTTP and networking library based on the Envoy project for iOS, Android, and more.
Java
554
star
6

data-plane-api

[READ ONLY MIRROR] Envoy REST/proto API definitions and documentation.
Starlark
546
star
7

nighthawk

L7 (HTTP/HTTPS/HTTP2/HTTP3) performance characterization tool
C++
329
star
8

envoy-filter-example

Example of consuming Envoy and adding a custom filter
C++
320
star
9

java-control-plane

Java implementation of an Envoy gRPC control plane
Java
285
star
10

envoy-wasm

*ATTENTION!: The content of this repo is merged into https://github.com/envoyproxy/envoy and future development is happening there.
C++
205
star
11

envoy-perf

Envoy performance testing
Python
127
star
12

learnenvoy

LearnEnvoy is a community content site that helps organizations get the most out of the Envoy proxy.
HTML
55
star
13

envoy-tools

Companion tooling for Envoy proxy
Go
49
star
14

envoy-build-tools

Common build tools shared by the Envoy/UDPA ecosystem
Starlark
42
star
15

envoy-openssl

Envoy OpenSSL extensions
C++
41
star
16

envoy-website

Envoy Proxy website
HTML
39
star
17

katacoda-scenarios

Katacoda Scenarios for Envoy Proxy
Python
27
star
18

artwork

Envoy Logo and Artwork
11
star
19

toolshed

Python
11
star
20

playground

Playing nice with the neighbours
JavaScript
8
star
21

community

Issues global to the Envoy Proxy organization
8
star
22

ci-infra

HCL
8
star
23

management-plane-api

API definitions for the network management plane
Shell
5
star
24

envoybot

3
star
25

envoy-distro

Starlark
2
star
26

archive

2
star
27

apt

2
star
28

mobile-website

Starlark
2
star
29

misc

1
star