From 7a830e6c7258d98e5c893e2123a1c4501ac80bf1 Mon Sep 17 00:00:00 2001 From: Lenin Mehedy Date: Thu, 14 Sep 2023 07:07:27 +1000 Subject: [PATCH] feat: support higher number of nodes with consistent gateway port mapping (#337) Signed-off-by: Lenin Mehedy Signed-off-by: Jeromy Cannon --- ...routes.yaml => envoy-grpc-web-routes.yaml} | 4 +-- .../templates/gateway-api/gateway.yaml | 28 ++++++++++++++----- ...y-routes.yaml => haproxy-grpc-routes.yaml} | 2 +- ...tes.yaml => network-node-grpc-routes.yaml} | 2 +- 4 files changed, 25 insertions(+), 11 deletions(-) rename charts/hedera-network/templates/gateway-api/{envoy-routes.yaml => envoy-grpc-web-routes.yaml} (87%) rename charts/hedera-network/templates/gateway-api/{haproxy-routes.yaml => haproxy-grpc-routes.yaml} (93%) rename charts/hedera-network/templates/gateway-api/{network-node-routes.yaml => network-node-grpc-routes.yaml} (93%) diff --git a/charts/hedera-network/templates/gateway-api/envoy-routes.yaml b/charts/hedera-network/templates/gateway-api/envoy-grpc-web-routes.yaml similarity index 87% rename from charts/hedera-network/templates/gateway-api/envoy-routes.yaml rename to charts/hedera-network/templates/gateway-api/envoy-grpc-web-routes.yaml index 98b408ab1..844ba5c71 100644 --- a/charts/hedera-network/templates/gateway-api/envoy-routes.yaml +++ b/charts/hedera-network/templates/gateway-api/envoy-grpc-web-routes.yaml @@ -6,14 +6,14 @@ apiVersion: gateway.networking.k8s.io/v1beta1 kind: HTTPRoute metadata: - name: envoy-routes-{{ $node.name }} + name: envoy-grpc-web-route-{{ $node.name }} namespace: default labels: fullstack.hedera.com/type: http-route spec: parentRefs: - name: fst - sectionName: http-{{ $node.name }} + sectionName: grpc-web-{{ $node.name }} hostnames: - {{ tpl $.Values.gatewayApi.route.hostname (dict "node" $node "Template" $.Template) }} rules: diff --git a/charts/hedera-network/templates/gateway-api/gateway.yaml b/charts/hedera-network/templates/gateway-api/gateway.yaml index 769ec881c..ca6ed372f 100644 --- a/charts/hedera-network/templates/gateway-api/gateway.yaml +++ b/charts/hedera-network/templates/gateway-api/gateway.yaml @@ -36,17 +36,31 @@ spec: allowedRoutes: kinds: - kind: TCPRoute # we use TCPRoute to for GRPC - {{- range $index, $node := $.Values.hedera.nodes }} - {{- $tcp_port := mul $index 1000 | add 50211 }} - {{- $http_port := mul $index 100 | add 8080 }} - - name: tcp-{{ $node.name }} # for haproxy or network-node TCPRoute + {{- range $index, $node := $.Values.hedera.nodes }} # we assume to have at most 999 nodes in a single cluster + {{- $gossip_port := add $index 51000 }} # node0:51000 ... node999: 51999, points to 50111 port in haproxy or network-node + {{- $grpc_port := add $index 52000 }} # node0:52000 ... node999: 52999, points to 50211 port in haproxy or network-node + {{- $grpcs_port := add $index 53000 }} # node0:53000 ... node999: 53999, points to 50212 port in haproxy or network-node + {{- $grpc_web_port := add $index 18000 }} # node0:18000 ... node999: 18999, points to 8080 port in envoy proxy + - name: gossip-{{ $node.name }} # for exposing gossip port 50111 from network-node protocol: TCP - port: {{ $tcp_port }} + port: {{ $gossip_port }} allowedRoutes: kinds: - kind: TCPRoute - - name: http-{{ $node.name }} # for envoy-proxy HTTPRoute + - name: grpc-{{ $node.name }} # for exposing grpc port 50211 from haproxy or network-node + protocol: TCP + port: {{ $grpc_port }} + allowedRoutes: + kinds: + - kind: TCPRoute + - name: grpcs-{{ $node.name }} # for exposing grpc port 50212 from haproxy or network-node + protocol: TCP + port: {{ $grpcs_port }} + allowedRoutes: + kinds: + - kind: TCPRoute + - name: grpc-web-{{ $node.name }} # for exposing grpc-web port 8080 from envoy-proxy protocol: HTTP - port: {{ $http_port }} + port: {{ $grpc_web_port }} {{- end }} {{- end }} \ No newline at end of file diff --git a/charts/hedera-network/templates/gateway-api/haproxy-routes.yaml b/charts/hedera-network/templates/gateway-api/haproxy-grpc-routes.yaml similarity index 93% rename from charts/hedera-network/templates/gateway-api/haproxy-routes.yaml rename to charts/hedera-network/templates/gateway-api/haproxy-grpc-routes.yaml index 6f7c4abe6..59ec2fc56 100644 --- a/charts/hedera-network/templates/gateway-api/haproxy-routes.yaml +++ b/charts/hedera-network/templates/gateway-api/haproxy-grpc-routes.yaml @@ -14,7 +14,7 @@ metadata: spec: parentRefs: - name: fst - sectionName: tcp-{{ $node.name }} + sectionName: grpc-{{ $node.name }} rules: - backendRefs: - name: haproxy-{{ $node.name }}-svc diff --git a/charts/hedera-network/templates/gateway-api/network-node-routes.yaml b/charts/hedera-network/templates/gateway-api/network-node-grpc-routes.yaml similarity index 93% rename from charts/hedera-network/templates/gateway-api/network-node-routes.yaml rename to charts/hedera-network/templates/gateway-api/network-node-grpc-routes.yaml index 29e3f647e..de55cdc2e 100644 --- a/charts/hedera-network/templates/gateway-api/network-node-routes.yaml +++ b/charts/hedera-network/templates/gateway-api/network-node-grpc-routes.yaml @@ -14,7 +14,7 @@ metadata: spec: parentRefs: - name: fst - sectionName: tcp-{{ $node.name }} + sectionName: grpc-{{ $node.name }} rules: - backendRefs: - name: network-{{ $node.name }}-svc