Skip to content

andref5/engovy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Envoy control-plane example

This is a simple example of Envoy control plane connected via gRPC using Go

How it works

                        | /config_dump (1900)
                        | 
                        |
  http req (8000)    +---------------+   proxy to 5000   +-----------------+
---------------------|     envoy     |-------------------| upstream-tester |
  (/ping | /pong)    +---------------+  (/ping | /pong)  +-----------------+
                           |  |
                           |  |
                           |  | gRPC (18000)
                           |  |
                           |  |
                     +---------------+
                     |    golang     |
                     | control-plane |
                     +---------------+
                        |
                        |
                        | /changeRoute (8001)
├── main.go (Startup control-plane(18000) and a http server(8001) to test change envoy configs)
├── pkg
│   ├── control-plane (Envoy control plane impl. Adapted from https://github.com/envoyproxy/go-control-plane/tree/main/internal/)
│   │   ├── logger.go (simple logger impl to set go-control-plane)
│   │   ├── resource.go (funcs to create envoy API structs https://www.envoyproxy.io/docs/envoy/latest/api/api)
│   │   └── server.go (control plane gRPC server. Envoy will establish gRPC stream to sync configs)
│   └── upstream-tester (Simple Go http server to test proxy to upstream cluster)
│       └── main.go (port 5000 - paths "/ping" "/pong")
└── deploy
    └── envoy-bootstrap-xds.yaml (Base config for Envoy xDS https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/operations/dynamic_configuration)

Install

Install getenvoy.io

curl -L https://getenvoy.io/cli | bash -s -- -b /usr/local/bin

Install Golang

https://golang.org/doc/install

Running

Runs an instance of Envoy

func-e run -c ./deploy/envoy-bootstrap-xds.yaml --drain-time-s 1 -l debug

New terminal to startup golang gRPC control-plane and HTTP server

go run main.go

New terminal to startup upstream tester

cd pkg/upstream-tester
go run main.go

Testing

/*\ Only a simple path change implemented

curl -sS http://localhost:19000/config_dump | jq '.configs[1].dynamic_active_clusters'
curl -sS http://localhost:19000/config_dump | jq '.configs[4].dynamic_route_configs'

curl -v localhost:8000/ping

curl -v localhost:8001/changeRoute -d path=/pong

curl -sS http://localhost:19000/config_dump | jq '.configs[4].dynamic_route_configs'

curl -v localhost:8000/pong

References

About

Envoy Golang control-plane sample

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages