Skip to content

Commit 5e0d80e

Browse files
committed
v2 api support
1 parent 299bbad commit 5e0d80e

File tree

12 files changed

+333
-169
lines changed

12 files changed

+333
-169
lines changed

httproute-blue-green/README.md

Lines changed: 61 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -34,34 +34,49 @@ Key definition 2 - `clusters` in [front-envoy.yaml](front-envoy.yaml)
3434
type: strict_dns
3535
lb_policy: round_robin
3636
http2_protocol_options: {}
37-
hosts:
38-
- socket_address:
39-
address: service_blue
40-
port_value: 80
37+
load_assignment:
38+
cluster_name: service_blue
39+
endpoints:
40+
- lb_endpoints:
41+
- endpoint:
42+
address:
43+
socket_address:
44+
address: service_blue
45+
port_value: 80
4146
- name: service_green
4247
connect_timeout: 0.25s
4348
type: strict_dns
4449
lb_policy: round_robin
4550
http2_protocol_options: {}
46-
hosts:
47-
- socket_address:
48-
address: service_green
49-
port_value: 80
51+
load_assignment:
52+
cluster_name: service_green
53+
endpoints:
54+
- lb_endpoints:
55+
- endpoint:
56+
address:
57+
socket_address:
58+
address: service_green
59+
port_value: 80
5060
- name: service_red
5161
connect_timeout: 0.25s
5262
type: strict_dns
5363
lb_policy: round_robin
5464
http2_protocol_options: {}
55-
hosts:
56-
- socket_address:
57-
address: service_red
58-
port_value: 80
65+
load_assignment:
66+
cluster_name: service_red
67+
endpoints:
68+
- lb_endpoints:
69+
- endpoint:
70+
address:
71+
socket_address:
72+
address: service_red
73+
port_value: 80
5974
```
6075

6176
## Getting Started
6277
```sh
63-
$ git clone https://github.com/yokawasa/envoy-proxy-demos.git
64-
$ cd envoy-proxy-demos/httproute-blue-green
78+
git clone https://github.com/yokawasa/envoy-proxy-demos.git
79+
cd envoy-proxy-demos/httproute-blue-green
6580
```
6681

6782
> [NOTICE] Before you run this demo, make sure that all demo containers in previous demo are stopped!
@@ -71,37 +86,60 @@ $ cd envoy-proxy-demos/httproute-blue-green
7186
### Build and Run containers
7287

7388
```sh
74-
$ docker-compose up --build -d
89+
docker-compose up --build -d
7590
7691
# check all services are up
77-
$ docker-compose ps --service
92+
docker-compose ps --service
7893
7994
front-envoy
8095
service_blue
8196
service_green
8297
service_red
8398
8499
# List containers
85-
$ docker-compose ps
100+
docker-compose ps
86101
87102
Name Command State Ports
88103
---------------------------------------------------------------------------------------------------------------------------------------
89-
httproute-blue-green_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
90-
httproute-blue-green_service_blue_1 /bin/sh -c /usr/local/bin/ ... Up 10000/tcp, 80/tcp
91-
httproute-blue-green_service_green_1 /bin/sh -c /usr/local/bin/ ... Up 10000/tcp, 80/tcp
104+
httproute-blue-green_front-envoy_1 /docker-entrypoint.sh /bin ... Up 10000/tcp, 0.0.0.0:8000->8000/tcp, 0.0.0.0:8001->8001/tcp
105+
httproute-blue-green_service_blue_1 /bin/sh -c /usr/local/bin/ ... Up 10000/tcp, 80/tcp
106+
httproute-blue-green_service_green_1 /bin/sh -c /usr/local/bin/ ... Up 10000/tcp, 80/tcp
92107
httproute-blue-green_service_red_1 /bin/sh -c /usr/local/bin/ ... Up 10000/tcp, 80/tcp
93108
```
94109

95110
### Access each services
96111

97112
Access serivce_blue and check if blue background page is displayed with 90% possibility and green background page is displayed with 10% possibility
113+
114+
```sh
115+
curl -s -v http://localhost:8000/service/blue
116+
```
117+
118+
For example, you can repeat the access to '/service/blue' like this
119+
98120
```sh
99-
$ curl -s -v http://localhost:8000/service/blue
121+
while true; do curl -s http://localhost:8000/service/blue | grep Hello && sleep 1; done
122+
123+
Hello from blue (hostname: 7d82da79d3bf resolvedhostname:172.31.0.5)
124+
Hello from green (hostname: 7d82da79d3bf resolvedhostname:172.31.0.5)
125+
Hello from blue (hostname: 7d82da79d3bf resolvedhostname:172.31.0.5)
126+
Hello from blue (hostname: 7d82da79d3bf resolvedhostname:172.31.0.5)
127+
Hello from blue (hostname: 7d82da79d3bf resolvedhostname:172.31.0.5)
128+
Hello from blue (hostname: 7d82da79d3bf resolvedhostname:172.31.0.5)
129+
Hello from blue (hostname: 7d82da79d3bf resolvedhostname:172.31.0.5)
130+
Hello from blue (hostname: 7d82da79d3bf resolvedhostname:172.31.0.5)
131+
Hello from blue (hostname: 7d82da79d3bf resolvedhostname:172.31.0.5)
132+
Hello from blue (hostname: 7d82da79d3bf resolvedhostname:172.31.0.5)
133+
Hello from blue (hostname: 7d82da79d3bf resolvedhostname:172.31.0.5)
134+
Hello from green (hostname: 14de8b900934 resolvedhostname:172.31.0.4)
135+
Hello from blue (hostname: 7d82da79d3bf resolvedhostname:172.31.0.5)
136+
Hello from blue (hostname: 7d82da79d3bf resolvedhostname:172.31.0.5)
100137
```
101138

139+
102140
Access serivce_red and check if red background page is displayed
103141
```
104-
$ curl -s -v http://localhost:8000/service/red
142+
curl -s -v http://localhost:8000/service/red
105143
```
106144
107145
## Stop & Cleanup
@@ -110,4 +148,4 @@ $ docker-compose down --remove-orphans --rmi all
110148
```
111149

112150
---
113-
[Top](../README.md)
151+
[Top](../README.md)

httproute-blue-green/docker-compose.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '2'
1+
version: '3.7'
22
services:
33

44
front-envoy:
@@ -10,12 +10,12 @@ services:
1010
networks:
1111
- envoymesh
1212
expose:
13-
# Expose ports 80 (for general traffic) and 8001 (for the admin server)
14-
- "80"
13+
# Expose ports 8000 (for general traffic) and 8001 (for the admin server)
14+
- "8000"
1515
- "8001"
1616
ports:
17-
# Map the host port 8000 to container port 80, and the host port 8001 to container port 8001
18-
- "8000:80"
17+
# Map the host port 8000 to container port 8000, and the host port 8001 to container port 8001
18+
- "8000:8000"
1919
- "8001:8001"
2020

2121
service_blue:

httproute-blue-green/front-envoy.yaml

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ static_resources:
33
- address:
44
socket_address:
55
address: 0.0.0.0
6-
port_value: 80
6+
port_value: 8000
77
filter_chains:
88
- filters:
9-
- name: envoy.http_connection_manager
10-
config:
9+
- name: envoy.filters.network.http_connection_manager
10+
typed_config:
11+
"@type": type.googleapis.com/envoy.config.filter.network.http_connection_manager.v2.HttpConnectionManager
1112
codec_type: auto
1213
stat_prefix: ingress_http
1314
route_config:
@@ -31,39 +32,63 @@ static_resources:
3132
route:
3233
cluster: service_red
3334
http_filters:
34-
- name: envoy.router
35-
config: {}
35+
- name: envoy.filters.http.router
36+
typed_config: {}
3637
clusters:
3738
- name: service_blue
3839
connect_timeout: 0.25s
3940
type: strict_dns
4041
lb_policy: round_robin
4142
http2_protocol_options: {}
42-
hosts:
43-
- socket_address:
44-
address: service_blue
45-
port_value: 80
43+
load_assignment:
44+
cluster_name: service_blue
45+
endpoints:
46+
- lb_endpoints:
47+
- endpoint:
48+
address:
49+
socket_address:
50+
address: service_blue
51+
port_value: 80
4652
- name: service_green
4753
connect_timeout: 0.25s
4854
type: strict_dns
4955
lb_policy: round_robin
5056
http2_protocol_options: {}
51-
hosts:
52-
- socket_address:
53-
address: service_green
54-
port_value: 80
57+
load_assignment:
58+
cluster_name: service_green
59+
endpoints:
60+
- lb_endpoints:
61+
- endpoint:
62+
address:
63+
socket_address:
64+
address: service_green
65+
port_value: 80
5566
- name: service_red
5667
connect_timeout: 0.25s
5768
type: strict_dns
5869
lb_policy: round_robin
5970
http2_protocol_options: {}
60-
hosts:
61-
- socket_address:
62-
address: service_red
63-
port_value: 80
71+
load_assignment:
72+
cluster_name: service_red
73+
endpoints:
74+
- lb_endpoints:
75+
- endpoint:
76+
address:
77+
socket_address:
78+
address: service_red
79+
port_value: 80
6480
admin:
6581
access_log_path: "/dev/null"
6682
address:
6783
socket_address:
6884
address: 0.0.0.0
6985
port_value: 8001
86+
layered_runtime:
87+
layers:
88+
- name: static_layer_0
89+
static_layer:
90+
envoy:
91+
resource_limits:
92+
listener:
93+
example_listener_name:
94+
connection_limit: 10000

httproute-blue-green/service-envoy.yaml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ static_resources:
66
port_value: 80
77
filter_chains:
88
- filters:
9-
- name: envoy.http_connection_manager
10-
config:
9+
- name: envoy.filters.network.http_connection_manager
10+
typed_config:
11+
"@type": type.googleapis.com/envoy.config.filter.network.http_connection_manager.v2.HttpConnectionManager
1112
codec_type: auto
1213
stat_prefix: ingress_http
1314
route_config:
@@ -22,17 +23,22 @@ static_resources:
2223
route:
2324
cluster: local_service
2425
http_filters:
25-
- name: envoy.router
26-
config: {}
26+
- name: envoy.filters.http.router
27+
typed_config: {}
2728
clusters:
2829
- name: local_service
2930
connect_timeout: 0.25s
3031
type: strict_dns
3132
lb_policy: round_robin
32-
hosts:
33-
- socket_address:
34-
address: 127.0.0.1
35-
port_value: 8080
33+
load_assignment:
34+
cluster_name: local_service
35+
endpoints:
36+
- lb_endpoints:
37+
- endpoint:
38+
address:
39+
socket_address:
40+
address: 127.0.0.1
41+
port_value: 8080
3642
admin:
3743
access_log_path: "/dev/null"
3844
address:

0 commit comments

Comments
 (0)