-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jose Nino
committed
Aug 26, 2016
1 parent
6141fc5
commit 055bcc9
Showing
2 changed files
with
152 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,153 +1,2 @@ | ||
# Envoy Example | ||
|
||
The following example runs through the setup of an envoy cluster organized as is described in the [envoy docs](https://envoydocs-staging.lyft.net/docs/install/sandboxes.html) | ||
|
||
**Step 1: Install Docker** | ||
|
||
Ensure that you have a recent versions of `docker`, `docker-compose` and | ||
`docker-machine` installed. | ||
|
||
A simple way to achieve this is via the [Docker Toolbox](https://www.docker.com/products/docker-toolbox). | ||
|
||
**Step 2: Docker Machine setup** | ||
|
||
First let's create a new machine which will hold the containers | ||
|
||
```shell | ||
$ docker-machine create --driver virtualbox default | ||
$ eval $(docker-machine env default) | ||
``` | ||
**Step 4: Start all of our containers** | ||
|
||
```shell | ||
$ pwd | ||
/src/envoy/example | ||
$ docker-compose up --build -d | ||
$ docker-compose ps | ||
Name Command State Ports | ||
------------------------------------------------------------------------------------------------------------- | ||
example_service1_1 /bin/sh -c /usr/local/bin/ ... Up 80/tcp | ||
example_service2_1 /bin/sh -c /usr/local/bin/ ... Up 80/tcp | ||
example_front-envoy_1 /bin/sh -c /usr/local/bin/ ... Up 0.0.0.0:8000->80/tcp, 0.0.0.0:8001->8001/tcp | ||
``` | ||
|
||
**Step 5: Test Envoy's routing capabilities** | ||
|
||
You can now send a request to both services via the front-envoy. | ||
|
||
For service1: | ||
```shell | ||
$ curl -v $(docker-machine ip default):8000/service/1 | ||
* Trying 192.168.99.100... | ||
* Connected to 192.168.99.100 (192.168.99.100) port 8000 (#0) | ||
> GET /service/1 HTTP/1.1 | ||
> Host: 192.168.99.100:8000 | ||
> User-Agent: curl/7.43.0 | ||
> Accept: */* | ||
> | ||
< HTTP/1.1 200 OK | ||
< content-type: text/html; charset=utf-8 | ||
< content-length: 89 | ||
< x-envoy-upstream-service-time: 1 | ||
< server: envoy | ||
< date: Fri, 26 Aug 2016 19:39:19 GMT | ||
< x-envoy-protocol-version: HTTP/1.1 | ||
< | ||
Hello from behind Envoy (service 1)! hostname: f26027f1ce28 resolvedhostname: 172.19.0.6 | ||
* Connection #0 to host 192.168.99.100 left intact | ||
``` | ||
For service2: | ||
```shell | ||
$ curl -v $(docker-machine ip default):8000/service/2 | ||
* Trying 192.168.99.100... | ||
* Connected to 192.168.99.100 (192.168.99.100) port 8000 (#0) | ||
> GET /service/2 HTTP/1.1 | ||
> Host: 192.168.99.100:8000 | ||
> User-Agent: curl/7.43.0 | ||
> Accept: */* | ||
> | ||
< HTTP/1.1 200 OK | ||
< content-type: text/html; charset=utf-8 | ||
< content-length: 89 | ||
< x-envoy-upstream-service-time: 2 | ||
< server: envoy | ||
< date: Fri, 26 Aug 2016 19:39:23 GMT | ||
< x-envoy-protocol-version: HTTP/1.1 | ||
< | ||
Hello from behind Envoy (service 2)! hostname: 92f4a3737bbc resolvedhostname: 172.19.0.2 | ||
* Connection #0 to host 192.168.99.100 left intact | ||
``` | ||
Notice that each request, while sent to the front envoy, was correctly routed | ||
to the respective application. | ||
**Step 6: Test Envoy's load balancing capabilities** | ||
Now let's scale up our service1 nodes to demonstrate the clustering abilities | ||
of envoy. | ||
```shell | ||
$ docker-compose scale service1=3 | ||
Creating and starting example_service1_2 ... done | ||
Creating and starting example_service1_3 ... done | ||
``` | ||
Now if we send a request to service1, the fron envoy will load balance the | ||
request by doing a round robin of the three service1 machines: | ||
```shell | ||
$ curl -v $(docker-machine ip default):8000/service/1 | ||
* Trying 192.168.99.100... | ||
* Connected to 192.168.99.100 (192.168.99.100) port 8000 (#0) | ||
> GET /service/1 HTTP/1.1 | ||
> Host: 192.168.99.100:8000 | ||
> User-Agent: curl/7.43.0 | ||
> Accept: */* | ||
> | ||
< HTTP/1.1 200 OK | ||
< content-type: text/html; charset=utf-8 | ||
< content-length: 89 | ||
< x-envoy-upstream-service-time: 1 | ||
< server: envoy | ||
< date: Fri, 26 Aug 2016 19:40:21 GMT | ||
< x-envoy-protocol-version: HTTP/1.1 | ||
< | ||
Hello from behind Envoy (service 1)! hostname: 85ac151715c6 resolvedhostname: 172.19.0.3 | ||
* Connection #0 to host 192.168.99.100 left intact | ||
$ curl -v $(docker-machine ip default):8000/service/1 | ||
* Trying 192.168.99.100... | ||
* Connected to 192.168.99.100 (192.168.99.100) port 8000 (#0) | ||
> GET /service/1 HTTP/1.1 | ||
> Host: 192.168.99.100:8000 | ||
> User-Agent: curl/7.43.0 | ||
> Accept: */* | ||
> | ||
< HTTP/1.1 200 OK | ||
< content-type: text/html; charset=utf-8 | ||
< content-length: 89 | ||
< x-envoy-upstream-service-time: 1 | ||
< server: envoy | ||
< date: Fri, 26 Aug 2016 19:40:22 GMT | ||
< x-envoy-protocol-version: HTTP/1.1 | ||
< | ||
Hello from behind Envoy (service 1)! hostname: 20da22cfc955 resolvedhostname: 172.19.0.5 | ||
* Connection #0 to host 192.168.99.100 left intact | ||
$ curl -v $(docker-machine ip default):8000/service/1 | ||
* Trying 192.168.99.100... | ||
* Connected to 192.168.99.100 (192.168.99.100) port 8000 (#0) | ||
> GET /service/1 HTTP/1.1 | ||
> Host: 192.168.99.100:8000 | ||
> User-Agent: curl/7.43.0 | ||
> Accept: */* | ||
> | ||
< HTTP/1.1 200 OK | ||
< content-type: text/html; charset=utf-8 | ||
< content-length: 89 | ||
< x-envoy-upstream-service-time: 1 | ||
< server: envoy | ||
< date: Fri, 26 Aug 2016 19:40:24 GMT | ||
< x-envoy-protocol-version: HTTP/1.1 | ||
< | ||
Hello from behind Envoy (service 1)! hostname: f26027f1ce28 resolvedhostname: 172.19.0.6 | ||
* Connection #0 to host 192.168.99.100 left intact | ||
``` | ||
To learn about this sandbox and for instructions on how to run it please head over | ||
to the [envoy docs](https://lyft.github.io/envoy/install/sandboxes) |