Skip to content

Commit 99cfbfe

Browse files
committed
support v2 api
1 parent 0d02bfe commit 99cfbfe

18 files changed

+635
-343
lines changed

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,16 @@
22

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

5-
WIP
5+
Prominent changes from v1 based demo app are:
6+
7+
- Changed general port for front proxy from 80 to 8000
8+
- Changed docker compose version from 2 to 3.7 (see [Compose file version 3 reference](https://docs.docker.com/compose/compose-file/))
9+
- HTTP Connection Manager API Change:
10+
- v1 API: envoy.http_connection_manager in v1 API
11+
- 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)
12+
- Tracking config for both Jaeger and Zipkin
13+
- endpoint: /api/v1/spans to /api/v2/spans
14+
- Stopped using `envoy.api.v2.route.RouteMatch.regex`, deprecated option
615

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

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ This project is a fork of the [Envoy's example demo sets](https://github.com/env
2020
- [Zipkin Tracing](zipkin-tracing)
2121

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

2627
## Contributing

apps/Dockerfile-frontenvoy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM envoyproxy/envoy:v1.12.3
1+
FROM envoyproxy/envoy:v1.15.0
22

33
RUN apt-get update && apt-get -q install -y \
44
curl

apps/Dockerfile-service

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
FROM envoyproxy/envoy-alpine:v1.12.3
1+
FROM envoyproxy/envoy-alpine-dev:latest
22

3-
RUN apk update && apk add python3 bash
3+
RUN apk update && apk add py3-pip bash curl
44
RUN python3 --version && pip3 --version
55
RUN pip3 install -q Flask==0.11.1 requests==2.18.4
66
RUN mkdir /code

circuit-breaker/README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ Key definition - `clusters` in [service-envoy-circuitbreaker.yaml](service-envo
3131

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

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

4343
```sh
44-
$ docker-compose up --build -d
44+
docker-compose up --build -d
4545
4646
# check all services are up
47-
$ docker-compose ps --service
47+
docker-compose ps --service
4848
4949
front-envoy
5050
service_green
5151
service_red
5252
5353
# List containers
54-
$ docker-compose ps
54+
docker-compose ps
5555
Name Command State Ports
5656
----------------------------------------------------------------------------------------------------------------------------------
5757
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
@@ -64,25 +64,25 @@ circuit-breaker_service_red_1 /bin/sh -c /usr/local/bin/ ... Up 10000
6464
Access serivce_blue and check if green background page is displayed. It is expected that nothting special will occur.
6565

6666
```sh
67-
$ curl -s http://localhost:8000/service/green
67+
curl -s http://localhost:8000/service/green
6868
```
6969

7070
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).
7171

7272
```sh
73-
$ ../helpers/parallel-requests.sh http://localhost:8000/service/green 5
73+
../helpers/parallel-requests.sh http://localhost:8000/service/green 5
7474
```
7575

7676
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.
7777

7878
```sh
79-
$ ../helpers/parallel-requests.sh http://localhost:8000/service/red 5
79+
../helpers/parallel-requests.sh http://localhost:8000/service/red 5
8080
```
8181

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

8484
```sh
85-
$ ../helpers/parallel-requests.sh http://localhost:8000/service/red 5 | grep -v 200
85+
../helpers/parallel-requests.sh http://localhost:8000/service/red 5 | grep -v 200
8686
8787
Parallel# 1
8888
Sending GET request: http://localhost:8000/service/red
@@ -118,7 +118,7 @@ Sending GET request: http://localhost:8000/service/red
118118

119119
## Stop & Cleanup
120120
```sh
121-
$ docker-compose down --remove-orphans --rmi all
121+
docker-compose down --remove-orphans --rmi all
122122
```
123123

124124
---

fault-injection/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ Key definition 2 - `http_filters` in [service-envoy-fault-injection-delay.yaml](
4040

4141
## Getting Started
4242
```sh
43-
$ git clone https://github.com/yokawasa/envoy-proxy-demos.git
44-
$ cd envoy-proxy-demos/fault-injection
43+
git clone https://github.com/yokawasa/envoy-proxy-demos.git
44+
cd envoy-proxy-demos/fault-injection
4545
```
4646

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

5353
```sh
54-
$ docker-compose up --build -d
54+
docker-compose up --build -d
5555
5656
# check all services are up
57-
$ docker-compose ps --service
57+
docker-compose ps --service
5858
5959
front-envoy
6060
service_blue
6161
service_green
6262
service_red
6363
6464
# List containers
65-
$ docker-compose ps
65+
docker-compose ps
6666
6767
Name Command State Ports
6868
----------------------------------------------------------------------------------------------------------------------------------
@@ -76,7 +76,7 @@ fault-injection_service_red_1 /bin/sh -c /usr/local/bin/ ... Up 10000
7676
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).
7777

7878
```sh
79-
$ ../helpers/send-requests.sh http://localhost:8000/service/blue 10
79+
../helpers/send-requests.sh http://localhost:8000/service/blue 10
8080
8181
Sending GET request: http://localhost:8000/service/blue
8282
200
@@ -88,7 +88,7 @@ Sending GET request: http://localhost:8000/service/blue
8888
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).
8989

9090
```sh
91-
$ ../helpers/send-requests.sh http://localhost:8000/service/red 10
91+
../helpers/send-requests.sh http://localhost:8000/service/red 10
9292
9393
Sending GET request: http://localhost:8000/service/red
9494
503
@@ -101,7 +101,7 @@ Sending GET request: http://localhost:8000/service/red
101101
## Stop & Cleanup
102102

103103
```sh
104-
$ docker-compose down --remove-orphans --rmi all
104+
docker-compose down --remove-orphans --rmi all
105105
```
106106

107107
---

jaeger-tracing/README.md

Lines changed: 85 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Distributed Tracing: Jaeger Tracing
22

33
## Demo Overview
4-
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.
4+
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.
55

6-
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.
6+
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.
77

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

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

2121
#### Key configuration 1: The HTTP connection manager
22-
All envoys are configured to collect request traces (e.g., http_connection_manager/config/tracing setup in front envoy).
23-
```
24-
- filters:
25-
- name: envoy.http_connection_manager
26-
config:
27-
tracing:
28-
operation_name: egress
22+
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).
23+
```yaml
24+
static_resources:
25+
listeners:
26+
- address:
27+
socket_address:
28+
address: 0.0.0.0
29+
port_value: 80
30+
traffic_direction: INBOUND
31+
filter_chains:
32+
- filters:
33+
- name: envoy.filters.network.http_connection_manager
34+
typed_config:
35+
"@type": type.googleapis.com/envoy.config.filter.network.http_connection_manager.v2.HttpConnectionManager
36+
tracing:
37+
provider:
38+
name: envoy.tracers.zipkin
39+
typed_config:
40+
"@type": type.googleapis.com/envoy.config.trace.v2.ZipkinConfig
41+
collector_cluster: jaeger
42+
collector_endpoint: "/api/v2/spans"
43+
shared_span_context: false
44+
collector_endpoint_version: HTTP_JSON
2945
```
46+
3047
> - 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).
31-
> - `operation_name`: The span name will be derived from this field (`ingress` or `egress`)
32-
> - `ingress` (default): ⁣The HTTP listener is used for ingress/incoming requests.
33-
> - `egress`: The HTTP listener is used for egress/outgoing requests
48+
> - 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)
49+
>
50+
51+
> 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:
52+
> - envoy.tracers.lightstep
53+
> - envoy.tracers.zipkin
54+
> - envoy.tracers.dynamic_ot
55+
> - envoy.tracers.datadog
56+
> - envoy.tracers.opencensus
57+
> - envoy.tracers.xray
58+
>
59+
> 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)
3460

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

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

3965
```YAML
4066
static_resources:
67+
listeners:
68+
...
69+
- address:
70+
socket_address:
71+
address: 0.0.0.0
72+
port_value: 9000
73+
traffic_direction: OUTBOUND
74+
filter_chains:
75+
- filters:
76+
- name: envoy.filters.network.http_connection_manager
77+
typed_config:
78+
"@type": type.googleapis.com/envoy.config.filter.network.http_connection_manager.v2.HttpConnectionManager
79+
tracing:
80+
provider:
81+
name: envoy.tracers.zipkin
82+
typed_config:
83+
"@type": type.googleapis.com/envoy.config.trace.v2.ZipkinConfig
84+
collector_cluster: jaeger
85+
collector_endpoint: "/api/v2/spans"
86+
shared_span_context: false
87+
collector_endpoint_version: HTTP_JSON
4188
...
4289
clusters:
4390
...
4491
- name: jaeger
4592
connect_timeout: 1s
4693
type: strict_dns
4794
lb_policy: round_robin
48-
hosts:
49-
- socket_address:
50-
address: jaeger
51-
port_value: 9411
52-
tracing:
53-
http:
54-
name: envoy.zipkin
55-
config:
56-
collector_cluster: jaeger
57-
collector_endpoint: "/api/v1/spans"
58-
shared_span_context: false
95+
load_assignment:
96+
cluster_name: jaeger
97+
endpoints:
98+
- lb_endpoints:
99+
- endpoint:
100+
address:
101+
socket_address:
102+
address: jaeger
103+
port_value: 9411
59104
```
60-
> 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:
61-
> - envoy.lightstep
62-
> - envoy.zipkin
63-
> - envoy.dynamic.ot
64-
> - envoy.tracers.datadog
65-
66-
> 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)
67105

68106
#### Key configuration 3: Trace header propagation
69107
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:
@@ -124,8 +162,8 @@ if __name__ == "__main__":
124162

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

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

136174
```sh
137-
$ docker-compose up --build -d
175+
docker-compose up --build -d
138176
139177
# check all services are up
140-
$ docker-compose ps --service
178+
docker-compose ps --service
141179
142180
front-envoy
143181
service_blue
@@ -146,30 +184,29 @@ service_red
146184
jaeger
147185
148186
# List containers
149-
$ docker-compose ps
187+
docker-compose ps
150188
151189
Name Command State Ports
152190
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
153-
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
154-
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,
155-
0.0.0.0:9411->9411/tcp
156-
jaeger-tracing_service_blue_1 /bin/sh -c /usr/local/bin/ ... Up 10000/tcp, 80/tcp
157-
jaeger-tracing_service_green_1 /bin/sh -c /usr/local/bin/ ... Up 10000/tcp, 80/tcp
158-
jaeger-tracing_service_red_1 /bin/sh -c /usr/local/bin/ ... Up 10000/tcp, 80/tcp
191+
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
192+
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
193+
jaeger-tracing_service_blue_1 /bin/sh -c /usr/local/bin/ ... Up 10000/tcp, 80/tcp
194+
jaeger-tracing_service_green_1 /bin/sh -c /usr/local/bin/ ... Up 10000/tcp, 80/tcp
195+
jaeger-tracing_service_red_1 /bin/sh -c /usr/local/bin/ ... Up 10000/tcp, 80/tcp
159196
```
160197

161198
### Access each services and check tracing results
162199

163200
Access the following 3 endpoints for tracing test.
164201
```
165-
$ curl -s -v http://localhost:8000/trace/blue
166-
$ curl -s -v http://localhost:8000/trace/green
167-
$ curl -s -v http://localhost:8000/trace/red
202+
curl -s -v http://localhost:8000/trace/blue
203+
curl -s -v http://localhost:8000/trace/green
204+
curl -s -v http://localhost:8000/trace/red
168205
```
169206
170207
For example, when you access `/trace/blue`, you'll see the following output
171208
```sh
172-
$ curl -s -v http://localhost:8000/trace/blue
209+
curl -s -v http://localhost:8000/trace/blue
173210
174211
* Trying ::1...
175212
* TCP_NODELAY set
@@ -195,7 +232,7 @@ Hello from blue (hostname: 9f71b1513720 resolvedhostname:172.21.0.5)
195232
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:
196233

197234
```
198-
$ open http://localhost:16686
235+
open http://localhost:16686
199236
```
200237

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

213250
```sh
214-
$ docker-compose down --remove-orphans --rmi all
251+
docker-compose down --remove-orphans --rmi all
215252
```
216253

217254
---
218-
[Top](../README.md)
255+
[Top](../README.md)

0 commit comments

Comments
 (0)