stripe / skycfg

Skycfg is an extension library for the Starlark language that adds support for constructing Protocol Buffer messages.
Apache License 2.0
648 stars 54 forks source link

Add Envoy Skycfg Example #82

Closed idiamond-stripe closed 4 years ago

idiamond-stripe commented 4 years ago

This PR adds a very simple Skcyfg example that runs an Envoy xDS using https://github.com/envoyproxy/go-control-plane. The example loads the provided config on start, and reloads the config on SIGHUP.

go run main.go launches the XDS running by default on 0.0.0.0:8080. It loads the provided config, for example go run envoy.cfg and exposes an ADS interface and the default gRPC health server.

The run-envoy.sh script starts an instance of Envoy running in a container, mounting ports 9901,10000, 10001. There is a bootstrap config for Envoy which connects outside the container to an ADS instance on 8080 (described in YAML). There's a health check configured for the ADS to determine if it's gone away.

The ADS should inject the provided listeners and clusters creating two routes to example.com and example.org respectively on :10000 and :10001. Visiting these at http://localhost:10000 or http://localhost:10001 produces a working example.com page for me:

image

idiamond-stripe commented 4 years ago

I've removed the any changes and landed them here: https://github.com/stripe/skycfg/pull/83. The places where I encode an any method in the skycfg have been replaced with a call to proto.to_any.

I've also simplified the example to run on two ports (10000 and 10001) and proxied them to example.com and example.org respectively.

All the other changes from the first, in progress review here are minor. I've added a health check and improved some go modules by go mod tidy, but overall these are mainly cosmetic. I should probably document the way this example works, but can do so in a follow up PR.