Skip to content

Commit

Permalink
support v2 api
Browse files Browse the repository at this point in the history
  • Loading branch information
yokawasa committed Aug 14, 2020
1 parent 0d02bfe commit 99cfbfe
Show file tree
Hide file tree
Showing 18 changed files with 635 additions and 343 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@

## v2.0.0 (envoy api v2 based demo apps)

WIP
Prominent changes from v1 based demo app are:

- Changed general port for front proxy from 80 to 8000
- Changed docker compose version from 2 to 3.7 (see [Compose file version 3 reference](https://docs.docker.com/compose/compose-file/))
- HTTP Connection Manager API Change:
- v1 API: envoy.http_connection_manager in v1 API
- v2 API: [envoy.filters.network.http_connection_manager](https://www.envoyproxy.io/docs/envoy/latest/api-v2/config/filter/network/http_connection_manager/v2/http_connection_manager.proto)
- Tracking config for both Jaeger and Zipkin
- endpoint: /api/v1/spans to /api/v2/spans
- Stopped using `envoy.api.v2.route.RouteMatch.regex`, deprecated option

## v1.0.0 (envoy api v1 based demo apps)

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ This project is a fork of the [Envoy's example demo sets](https://github.com/env
- [Zipkin Tracing](zipkin-tracing)

## Demo versions and supported envoy versions
- v2.0.0 (WIP): envoy api V2 based demo apps
- latest: envoy api v2 based demo apps
- [v2.0.0](https://github.com/yokawasa/envoy-proxy-demos/releases/tag/v2.0.0): envoy api v2 based demo apps
- [v1.0.0](https://github.com/yokawasa/envoy-proxy-demos/releases/tag/v1.0.0): envoy api v1 based demo apps

## Contributing
Expand Down
2 changes: 1 addition & 1 deletion apps/Dockerfile-frontenvoy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM envoyproxy/envoy:v1.12.3
FROM envoyproxy/envoy:v1.15.0

RUN apt-get update && apt-get -q install -y \
curl
Expand Down
4 changes: 2 additions & 2 deletions apps/Dockerfile-service
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM envoyproxy/envoy-alpine:v1.12.3
FROM envoyproxy/envoy-alpine-dev:latest

RUN apk update && apk add python3 bash
RUN apk update && apk add py3-pip bash curl
RUN python3 --version && pip3 --version
RUN pip3 install -q Flask==0.11.1 requests==2.18.4
RUN mkdir /code
Expand Down
20 changes: 10 additions & 10 deletions circuit-breaker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ Key definition - `clusters` in [service-envoy-circuitbreaker.yaml](service-envo

## Getting Started
```sh
$ git clone https://github.com/yokawasa/envoy-proxy-demos.git
$ cd envoy-proxy-demos/circuit-breaker
git clone https://github.com/yokawasa/envoy-proxy-demos.git
cd envoy-proxy-demos/circuit-breaker
```
> [NOTICE] Before you run this demo, make sure that all demo containers in previous demo are stopped!

Expand All @@ -41,17 +41,17 @@ $ cd envoy-proxy-demos/circuit-breaker
### Build and Run containers

```sh
$ docker-compose up --build -d
docker-compose up --build -d
# check all services are up
$ docker-compose ps --service
docker-compose ps --service
front-envoy
service_green
service_red
# List containers
$ docker-compose ps
docker-compose ps
Name Command State Ports
----------------------------------------------------------------------------------------------------------------------------------
circuit-breaker_front-envoy_1 /usr/bin/dumb-init -- /bin ... Up 10000/tcp, 0.0.0.0:8000->80/tcp, 0.0.0.0:8001->8001/tcp
Expand All @@ -64,25 +64,25 @@ circuit-breaker_service_red_1 /bin/sh -c /usr/local/bin/ ... Up 10000
Access serivce_blue and check if green background page is displayed. It is expected that nothting special will occur.

```sh
$ curl -s http://localhost:8000/service/green
curl -s http://localhost:8000/service/green
```

Try paralell access to service_green. It is expected that nothting special will occur. The following helper command allow you to send parallel requests repeatedly (For example, send 5 parallel requests to http://localhost:8000/service/green, each thread make 30 consequent requests).

```sh
$ ../helpers/parallel-requests.sh http://localhost:8000/service/green 5
../helpers/parallel-requests.sh http://localhost:8000/service/green 5
```

Make at least 5 parallel requests to service_red in order to trigger circit breaker and see a few of requests receive 503 HTTP status code.

```sh
$ ../helpers/parallel-requests.sh http://localhost:8000/service/red 5
../helpers/parallel-requests.sh http://localhost:8000/service/red 5
```

To make it more conveniently, exclude 200 status code to identify 503 status code easily like this:

```sh
$ ../helpers/parallel-requests.sh http://localhost:8000/service/red 5 | grep -v 200
../helpers/parallel-requests.sh http://localhost:8000/service/red 5 | grep -v 200
Parallel# 1
Sending GET request: http://localhost:8000/service/red
Expand Down Expand Up @@ -118,7 +118,7 @@ Sending GET request: http://localhost:8000/service/red

## Stop & Cleanup
```sh
$ docker-compose down --remove-orphans --rmi all
docker-compose down --remove-orphans --rmi all
```

---
Expand Down
16 changes: 8 additions & 8 deletions fault-injection/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ Key definition 2 - `http_filters` in [service-envoy-fault-injection-delay.yaml](

## Getting Started
```sh
$ git clone https://github.com/yokawasa/envoy-proxy-demos.git
$ cd envoy-proxy-demos/fault-injection
git clone https://github.com/yokawasa/envoy-proxy-demos.git
cd envoy-proxy-demos/fault-injection
```

> [NOTICE] Before you run this demo, make sure that all demo containers in previous demo are stopped!
Expand All @@ -51,18 +51,18 @@ $ cd envoy-proxy-demos/fault-injection
### Build and Run containers using docker-compose

```sh
$ docker-compose up --build -d
docker-compose up --build -d
# check all services are up
$ docker-compose ps --service
docker-compose ps --service
front-envoy
service_blue
service_green
service_red
# List containers
$ docker-compose ps
docker-compose ps
Name Command State Ports
----------------------------------------------------------------------------------------------------------------------------------
Expand All @@ -76,7 +76,7 @@ fault-injection_service_red_1 /bin/sh -c /usr/local/bin/ ... Up 10000
Access serivce_blue and check if 50% of requests to service_blue are 10 seconds delayed. The following helper command allow you to send requests repeatedly (For example, send 10 requests to http://localhost:8000/service/blue).

```sh
$ ../helpers/send-requests.sh http://localhost:8000/service/blue 10
../helpers/send-requests.sh http://localhost:8000/service/blue 10
Sending GET request: http://localhost:8000/service/blue
200
Expand All @@ -88,7 +88,7 @@ Sending GET request: http://localhost:8000/service/blue
Access serivce_red and check if 50% of requests to service_red are aborted with 503 HTTP status code. The following helper command allow you to send requests repeatedly (For example, send 10 requests to http://localhost:8000/service/red).

```sh
$ ../helpers/send-requests.sh http://localhost:8000/service/red 10
../helpers/send-requests.sh http://localhost:8000/service/red 10
Sending GET request: http://localhost:8000/service/red
503
Expand All @@ -101,7 +101,7 @@ Sending GET request: http://localhost:8000/service/red
## Stop & Cleanup

```sh
$ docker-compose down --remove-orphans --rmi all
docker-compose down --remove-orphans --rmi all
```

---
Expand Down
133 changes: 85 additions & 48 deletions jaeger-tracing/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Distributed Tracing: Jaeger Tracing

## Demo Overview
This is a Jaeger tracing example built based on the [Envoy sandboxes (Jaeger Tracing)](https://www.envoyproxy.io/docs/envoy/latest/start/sandboxes/jaeger_tracing) that demonstrates Envoy’s [tracing](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/tracing#arch-overview-tracing) capabilities using [Jaeger](https://www.jaegertracing.io/) as the tracing provider.
This is a Jaeger tracing example built based on the [Envoy sandboxes (Jaeger Tracing)](https://www.envoyproxy.io/docs/envoy/latest/start/sandboxes/jaeger_tracing) that demonstrates Envoy’s [tracing](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/observability/tracing) capabilities using [Jaeger](https://www.jaegertracing.io/) as the tracing provider.

All services in the demo support not only `service` endpoint (which is basically the same as [HTTP Routing: Simple Match Routing](../httproute-simple-match/README.md)) but also `trace` endpoint. All traffic is routed by the `front envoy` to the `service containers`. Internally the traffic is routed to the service envoys, then the service envoys route the request to the flask app via the loopback address. All trace data is collected into a `Jaeger` container.
All services in the demo support not only `service` endpoint (which is basically the same as [HTTP Routing: Simple Match Routing](../httproute-simple-match/README.md)) but also `trace` endpoint. All traffic is routed from the `front envoy` to the `service containers`. Internally the traffic is routed to the service envoys, then the service envoys route the request to the flask app via the loopback address. All trace data is collected into a `Jaeger` container.

![](../assets/demo-jaeger-tracing.png)

Expand All @@ -19,51 +19,89 @@ In accessing to `trace` endpoint, all traffic is routed to the service envoys wi
![](../assets/demo-jaeger-tracing-req-trace.png)

#### Key configuration 1: The HTTP connection manager
All envoys are configured to collect request traces (e.g., http_connection_manager/config/tracing setup in front envoy).
```
- filters:
- name: envoy.http_connection_manager
config:
tracing:
operation_name: egress
All envoys are configured to collect request traces (e.g., [tracing](https://www.envoyproxy.io/docs/envoy/latest/api-v2/config/filter/network/http_connection_manager/v2/http_connection_manager.proto#envoy-api-msg-config-filter-network-http-connection-manager-v2-httpconnectionmanager-tracing) in config.filter.network.http_connection_manager.v2.HttpConnectionManager in front envoy).
```yaml
static_resources:
listeners:
- address:
socket_address:
address: 0.0.0.0
port_value: 80
traffic_direction: INBOUND
filter_chains:
- filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.config.filter.network.http_connection_manager.v2.HttpConnectionManager
tracing:
provider:
name: envoy.tracers.zipkin
typed_config:
"@type": type.googleapis.com/envoy.config.trace.v2.ZipkinConfig
collector_cluster: jaeger
collector_endpoint: "/api/v2/spans"
shared_span_context: false
collector_endpoint_version: HTTP_JSON
```
> - The HTTP connection manager that handles the request must have the tracing object set. Please refer to [tracing object](https://www.envoyproxy.io/docs/envoy/latest/api-v2/config/filter/network/http_connection_manager/v2/http_connection_manager.proto#envoy-api-msg-config-filter-network-http-connection-manager-v2-httpconnectionmanager-tracing).
> - `operation_name`: The span name will be derived from this field (`ingress` or `egress`)
> - `ingress` (default): ⁣The HTTP listener is used for ingress/incoming requests.
> - `egress`: The HTTP listener is used for egress/outgoing requests
> - For the configuration for an HTTP tracer provider used by Envoy, see [config.trace.v2.Tracing.Http](https://www.envoyproxy.io/docs/envoy/latest/api-v2/config/trace/v2/http_tracer.proto#envoy-api-msg-config-trace-v2-tracing-http)
>
> Presence of the object defines whether the connection manager emits tracing data to the configured tracing provider. You configure `tracing driver` in `name` field. Here are 4 parameter options for `tracing driver` and `envoy.tracers.zipkin` is selected here:
> - envoy.tracers.lightstep
> - envoy.tracers.zipkin
> - envoy.tracers.dynamic_ot
> - envoy.tracers.datadog
> - envoy.tracers.opencensus
> - envoy.tracers.xray
>
> Parameters for Config parts in zipkin deiver are [here](https://www.envoyproxy.io/docs/envoy/latest/api-v2/config/trace/v2/zipkin.proto#envoy-api-msg-config-trace-v2-zipkinconfig)

#### Key configuration 2: Spans propagation setup (Trace deiver setup)

All envoys in the demo are also configured to setup to propagate the spans generated by the Jaeger tracer to a Jaeger cluster.

```YAML
static_resources:
listeners:
...
- address:
socket_address:
address: 0.0.0.0
port_value: 9000
traffic_direction: OUTBOUND
filter_chains:
- filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.config.filter.network.http_connection_manager.v2.HttpConnectionManager
tracing:
provider:
name: envoy.tracers.zipkin
typed_config:
"@type": type.googleapis.com/envoy.config.trace.v2.ZipkinConfig
collector_cluster: jaeger
collector_endpoint: "/api/v2/spans"
shared_span_context: false
collector_endpoint_version: HTTP_JSON
...
clusters:
...
- name: jaeger
connect_timeout: 1s
type: strict_dns
lb_policy: round_robin
hosts:
- socket_address:
address: jaeger
port_value: 9411
tracing:
http:
name: envoy.zipkin
config:
collector_cluster: jaeger
collector_endpoint: "/api/v1/spans"
shared_span_context: false
load_assignment:
cluster_name: jaeger
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: jaeger
port_value: 9411
```
> Presence of the object defines whether the connection manager emits tracing data to the configured tracing provider. You configure `tracing driver` in `name` field. Here are 4 parameter options for `tracing driver` and `envoy.zipkin` is selected here:
> - envoy.lightstep
> - envoy.zipkin
> - envoy.dynamic.ot
> - envoy.tracers.datadog

> Parameters for Config parts in zipkin deiver are [here](https://www.envoyproxy.io/docs/envoy/latest/api-v2/config/trace/v2/trace.proto#envoy-api-msg-config-trace-v2-zipkinconfig)

#### Key configuration 3: Trace header propagation
One of the most important benefits of tracing from Envoy is that it will take care of propagating the traces to the Jaeger service cluster. However, in order to fully take advantage of tracing, the application has to propagate trace headers that Envoy generates. The sample `trace header propagations` setup in servcie application code ([apps/service.py](../apps/service.py)) is this:
Expand Down Expand Up @@ -124,8 +162,8 @@ if __name__ == "__main__":

## Getting Started
```sh
$ git clone https://github.com/yokawasa/envoy-proxy-demos.git
$ cd envoy-proxy-demos/jaeger-tracing
git clone https://github.com/yokawasa/envoy-proxy-demos.git
cd envoy-proxy-demos/jaeger-tracing
```
> [NOTICE] Before you run this demo, make sure that all demo containers in previous demo are stopped!

Expand All @@ -134,10 +172,10 @@ $ cd envoy-proxy-demos/jaeger-tracing
### Build and Run containers

```sh
$ docker-compose up --build -d
docker-compose up --build -d
# check all services are up
$ docker-compose ps --service
docker-compose ps --service
front-envoy
service_blue
Expand All @@ -146,30 +184,29 @@ service_red
jaeger
# List containers
$ docker-compose ps
docker-compose ps
Name Command State Ports
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
jaeger-tracing_front-envoy_1 /usr/bin/dumb-init -- /bin ... Up 10000/tcp, 0.0.0.0:8000->80/tcp, 0.0.0.0:8001->8001/tcp
jaeger-tracing_jaeger_1 /go/bin/all-in-one-linux - ... Up 14250/tcp, 14268/tcp, 0.0.0.0:16686->16686/tcp, 5775/udp, 5778/tcp, 6831/udp, 6832/udp,
0.0.0.0:9411->9411/tcp
jaeger-tracing_service_blue_1 /bin/sh -c /usr/local/bin/ ... Up 10000/tcp, 80/tcp
jaeger-tracing_service_green_1 /bin/sh -c /usr/local/bin/ ... Up 10000/tcp, 80/tcp
jaeger-tracing_service_red_1 /bin/sh -c /usr/local/bin/ ... Up 10000/tcp, 80/tcp
jaeger-tracing_front-envoy_1 /docker-entrypoint.sh /bin ... Up 10000/tcp, 0.0.0.0:8000->8000/tcp, 0.0.0.0:8001->8001/tcp
jaeger-tracing_jaeger_1 /go/bin/all-in-one-linux - ... Up 14250/tcp, 14268/tcp, 0.0.0.0:16686->16686/tcp, 5775/udp, 5778/tcp, 6831/udp, 6832/udp, 0.0.0.0:9411->9411/tcp
jaeger-tracing_service_blue_1 /bin/sh -c /usr/local/bin/ ... Up 10000/tcp, 80/tcp
jaeger-tracing_service_green_1 /bin/sh -c /usr/local/bin/ ... Up 10000/tcp, 80/tcp
jaeger-tracing_service_red_1 /bin/sh -c /usr/local/bin/ ... Up 10000/tcp, 80/tcp
```

### Access each services and check tracing results

Access the following 3 endpoints for tracing test.
```
$ curl -s -v http://localhost:8000/trace/blue
$ curl -s -v http://localhost:8000/trace/green
$ curl -s -v http://localhost:8000/trace/red
curl -s -v http://localhost:8000/trace/blue
curl -s -v http://localhost:8000/trace/green
curl -s -v http://localhost:8000/trace/red
```
For example, when you access `/trace/blue`, you'll see the following output
```sh
$ curl -s -v http://localhost:8000/trace/blue
curl -s -v http://localhost:8000/trace/blue
* Trying ::1...
* TCP_NODELAY set
Expand All @@ -195,7 +232,7 @@ Hello from blue (hostname: 9f71b1513720 resolvedhostname:172.21.0.5)
Trace data would automatically have been generated and pushed to Jaeger via Envoy. In this part, check the Jaeger UI to see how the Jaeger visualize all the trace data collected. Here is a Jaeger UI url:

```
$ open http://localhost:16686
open http://localhost:16686
```

![](../assets/jaeger-ui.png)
Expand All @@ -211,8 +248,8 @@ You'll come up with Jager UI page like above, then search each traces. Here are
## Stop & Cleanup

```sh
$ docker-compose down --remove-orphans --rmi all
docker-compose down --remove-orphans --rmi all
```

---
[Top](../README.md)
[Top](../README.md)
Loading

0 comments on commit 99cfbfe

Please sign in to comment.