Skip to content

Instantly share code, notes, and snippets.

@angelachin
Last active March 2, 2018 00:46
Show Gist options
  • Save angelachin/c9e09c5c930cf68cb52840ed83943a96 to your computer and use it in GitHub Desktop.
Save angelachin/c9e09c5c930cf68cb52840ed83943a96 to your computer and use it in GitHub Desktop.
A guide to getting started on the spike for Envoy load-balancing

To get started

Link here

  1. Clone the envoy repo into workspace. git clone https://github.com/envoyproxy/envoy.git

  2. cd into the configs directory and modify the Dockerfile so that it has the following

# This configuration will build a Docker container containing
# an Envoy proxy that routes to Google.

FROM envoyproxy/envoy:latest
RUN apt-get update
COPY google_com_proxy.v2.yaml /etc/envoy.yaml
CMD tail -f /dev/null
  1. Build and run the Dockerfile
docker build -t envoy-google-test:v1 .
docker run -d -p 10000:10000 envoy-google-test:v1
  1. Open a second window and shell into the docker container
export ENVOY_CONTAINER=$(docker ps | sed "1 d" | cut -d" " -f 1)
docker exec -it $ENVOY_CONTAINER "/bin/sh"

The script above gets the container id assuming you only have 1 docker container running.

  1. The basic envoy config is located at etc/envoy.yaml. Start the envoy process
cd etc
envoy -c envoy.yaml
  1. From the first window, you can now see the Envoy is proxying traffic by running curl -v -o /dev/null localhost:10000 and seeing that the header has server: envoy.

Now go forth and mess around with the Envoy config!

Types of load balancing

For a cluster, you can define a lb policy.

For a HTTP route, you can define weights amongst the clusters it will send traffic to.

Which method of load-balancing you use depends on the data mapping of Envoy-to-CF concepts.

Helpful links

Envoy documentation can be found here. You will want to be using the v2 api.

@adobley
Copy link

adobley commented Mar 1, 2018

Apparently it will only update based on a file system watch on a symlinked file https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/runtime.html#arch-overview-runtime

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment