Skip to content

Commit

Permalink
feat(envoy): adding envoy grpc-web proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
xmlking committed Feb 3, 2020
1 parent 9193727 commit 59c22ff
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 10 deletions.
14 changes: 14 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: '3.7'

services:
envoy:
image: envoyproxy/envoy:latest
command: /usr/local/bin/envoy -c etc/envoy/envoy.yaml
volumes:
- './envoy.yaml:/etc/envoy/envoy.yaml'
expose:
- '9090'
- '9901'
ports:
- '9090:9090'
- '9901:9901'
19 changes: 18 additions & 1 deletion docs/advanced/envoy.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ protoc -I="./protos" ./protos/echo.proto \
### Reference

```bash
minikube mount /Users/schintha/Developer/Work:/Work
# minikube mount /Users/schintha/Developer/Work:/Work
# mount '/Work/SPA/yeti/envoy.yaml:/etc/envoy/envoy.yaml'
docker-compose up envoy


Expand Down Expand Up @@ -49,6 +50,22 @@ docker exec -it envoy /bin/bash
}'


curl 'http://localhost:9090/echo/yeti.EchoService/Echo' \
-H 'Content-Type: application/grpc-web+proto' \
-H 'X-Grpc-Web: 1' \
-H 'custom-header-1: value1' \
-H 'Accept: */*' \
-H 'Connection: keep-alive' \
--data-binary $'\x00\x00\x00\x00\x05\n\x03abc' --compressed

curl 'http://localhost:9090/echo/yeti.EchoService/Echo' \
-H 'Content-Type: application/json' \
-d '{
"message": "sumo"
}'



```

1. https://github.com/jrockway/jrock.us/blob/master/ingress/envoy.yaml
19 changes: 10 additions & 9 deletions docs/introduction/playbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ ng g lib admin --routing --lazy --parent-module=apps/webapp/src/app/ap
ng g lib NotFound --routing --lazy --parent-module=apps/webapp/src/app/app.module.ts --defaults --tags=entry-module
ng g lib experiments --routing --lazy --parent-module=libs/dashboard/src/lib/dashboard.module.ts --defaults --tags=child-module
ng g lib widgets --routing --lazy --parent-module=libs/dashboard/src/lib/dashboard.module.ts --defaults --tags=child-module
ng g lib grid --routing --lazy --parent-module=libs/dashboard/src/lib/dashboard.module.ts --defaults --tags=child-module
ng g lib accounts --routing --lazy --parent-module=libs/dashboard/src/lib/dashboard.module.ts --defaults --tags=child-module

# ng g worker app --project=webapp -d # TODO
```
Expand Down Expand Up @@ -602,13 +602,14 @@ ng g component containers/settings --project=dashboard
# generate containers, components for `widgets` Module
ng g component containers/wizdash --project=widgets -d

# generate containers, components for `grid` Module
ng g component containers/AccountsTable --project=grid -d
ng g component components/AccountDetail --project=grid -d
ng g component components/AccountEdit --project=grid -d
ng g class models/account --project=grid --type=model -d
ng g service services/account --project=grid -d
ng g component containers/AccountsGridList --project=grid -d
# generate containers, components for `accounts` Module
ng g component containers/AccountsGrid --project=accounts -d
ng g component containers/AccountsTable --project=accounts -d
ng g component components/AccountDetail --project=accounts -d
ng g component components/AccountEdit --project=accounts -d
ng g class models/account --project=accounts --type=model -d
ng g service services/account --project=accounts -d


# generate containers, components for `experiments` Module
ng g component containers/animations --project=experiments -d
Expand Down Expand Up @@ -656,7 +657,7 @@ ng g service services/subscription --project=admin -d
ng g workspace-schematic store
# run workspace-schematic `store`
# *** always delete ./dist folder when you change schematic implementation ***
yarn workspace-schematic store models/sumoDemo -- --project=grid -d
yarn workspace-schematic store models/sumoDemo -- --project=accounts -d
# build workspace tools
yarn workspace @ngx-starter-kit/tools build
```
Expand Down
68 changes: 68 additions & 0 deletions envoy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
admin:
access_log_path: /tmp/admin_access.log
address:
socket_address: { address: 0.0.0.0, port_value: 9901 }

static_resources:
listeners:
- name: listener_0
address:
socket_address: { address: 0.0.0.0, port_value: 9090 }
filter_chains:
- filters:
- name: envoy.http_connection_manager
config:
codec_type: auto
stat_prefix: ingress_http
route_config:
name: local_route
virtual_hosts:
- name: local_service
domains: ['*']
routes:
- match: { prefix: '/accountsrv' }
route:
cluster: account_service
max_grpc_timeout: 0s
- match: { prefix: '/greetersrv' }
route:
cluster: greeter_service
max_grpc_timeout: 0s
- match: { prefix: '/echo' }
route:
cluster: echo_service
max_grpc_timeout: 0s
cors:
allow_origin_string_match:
- safe_regex: { google_re2: {}, regex: '.*' }
allow_methods: GET, PUT, DELETE, POST, OPTIONS
allow_headers: keep-alive,user-agent,cache-control,content-type,content-transfer-encoding,custom-header-1,x-accept-content-transfer-encoding,x-accept-response-streaming,x-user-agent,x-grpc-web,grpc-timeout
# allow_headers: keep-alive,user-agent,cache-control,content-type,content-transfer-encoding,custom-header-1,x-accept-content-transfer-encoding,x-accept-response-streaming,x-user-agent,x-grpc-web,grpc-timeout,authorization
max_age: '1728000'
expose_headers: custom-header-1,grpc-status,grpc-message
http_filters:
- name: envoy.grpc_web
- name: envoy.cors
- name: envoy.router
clusters:
- name: account_service
connect_timeout: 0.25s
type: logical_dns
http2_protocol_options: {}
lb_policy: round_robin
# win/mac hosts: Use address: host.docker.internal instead of address: localhost in the line below
hosts: [{ socket_address: { address: host.docker.internal, port_value: 8080 } }]
- name: greeter_service
connect_timeout: 0.25s
type: logical_dns
http2_protocol_options: {}
lb_policy: round_robin
# win/mac hosts: Use address: host.docker.internal instead of address: localhost in the line below
hosts: [{ socket_address: { address: host.docker.internal, port_value: 8081 } }]
- name: echo_service
connect_timeout: 0.25s
type: logical_dns
http2_protocol_options: {}
lb_policy: round_robin
# win/mac hosts: Use address: host.docker.internal instead of address: localhost in the line below
hosts: [{ socket_address: { address: host.docker.internal, port_value: 5000 } }]

0 comments on commit 59c22ff

Please sign in to comment.