From 59c22ff9f87b80743431e1da3931a9b52289fc70 Mon Sep 17 00:00:00 2001 From: Sumanth Chinthagunta Date: Sun, 2 Feb 2020 23:42:16 -0800 Subject: [PATCH] feat(envoy): adding envoy grpc-web proxy --- docker-compose.yaml | 14 ++++++++ docs/advanced/envoy.md | 19 +++++++++- docs/introduction/playbook.md | 19 +++++----- envoy.yaml | 68 +++++++++++++++++++++++++++++++++++ 4 files changed, 110 insertions(+), 10 deletions(-) create mode 100644 docker-compose.yaml create mode 100644 envoy.yaml diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 00000000..64a4e932 --- /dev/null +++ b/docker-compose.yaml @@ -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' diff --git a/docs/advanced/envoy.md b/docs/advanced/envoy.md index 3b6e22ae..0b95e333 100644 --- a/docs/advanced/envoy.md +++ b/docs/advanced/envoy.md @@ -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 @@ -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 diff --git a/docs/introduction/playbook.md b/docs/introduction/playbook.md index 8579106e..ee66205d 100644 --- a/docs/introduction/playbook.md +++ b/docs/introduction/playbook.md @@ -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 ``` @@ -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 @@ -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 ``` diff --git a/envoy.yaml b/envoy.yaml new file mode 100644 index 00000000..bed2520a --- /dev/null +++ b/envoy.yaml @@ -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 } }]