From 0c1685569e067eac2f6f64054d5f58b6124e7989 Mon Sep 17 00:00:00 2001 From: Lenin Mehedy Date: Thu, 14 Sep 2023 09:31:39 +1000 Subject: [PATCH] feat: parameterize gateway port mapping using values file (#339) Signed-off-by: Lenin Mehedy --- .../templates/gateway-api/gateway.yaml | 53 +++++++++++-------- charts/hedera-network/values.yaml | 19 +++++++ dev/Makefile | 4 +- dev/gateway-api/grpc-debug.yaml | 2 +- dev/scripts/gateway.sh | 12 ++--- 5 files changed, 60 insertions(+), 30 deletions(-) diff --git a/charts/hedera-network/templates/gateway-api/gateway.yaml b/charts/hedera-network/templates/gateway-api/gateway.yaml index ca6ed372f..b8225d4ab 100644 --- a/charts/hedera-network/templates/gateway-api/gateway.yaml +++ b/charts/hedera-network/templates/gateway-api/gateway.yaml @@ -21,46 +21,57 @@ metadata: spec: gatewayClassName: {{ $.Values.gatewayApi.gatewayClass.name }} listeners: - - name: http-debug - protocol: HTTP - port: 80 - - name: tcp-debug - protocol: TCP - port: 9000 - allowedRoutes: - kinds: - - kind: TCPRoute - - name: grpc-debug - protocol: TCP - port: 9090 - allowedRoutes: - kinds: - - kind: TCPRoute # we use TCPRoute to for GRPC - {{- 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 + {{- $gossip_start_port := $.Values.gatewayApi.gateway.listeners.gossip.port }} # i.e. node0:51000 ... node999: 51999, points to 50111 port in haproxy or network-node + {{- $grpc_start_port := $.Values.gatewayApi.gateway.listeners.grpc.port }} # i.e. node0:52000 ... node999: 52999, points to 50211 port in haproxy or network-node + {{- $grpcs_start_port := $.Values.gatewayApi.gateway.listeners.grpcs.port }} # i.e. node0:53000 ... node999: 53999, points to 50212 port in haproxy or network-node + {{- $grpc_web_start_port := $.Values.gatewayApi.gateway.listeners.grpcWeb.port }} # i.e. node0:18000 ... node999: 18999, points to 8080 port in envoy proxy + {{- range $index, $node := $.Values.hedera.nodes }} # we assume to have at most 999 nodes in a single cluster + {{- if $.Values.gatewayApi.gateway.listeners.gossip.enable | eq "true" }} + {{- $gossip_port := add $index $gossip_start_port }} - name: gossip-{{ $node.name }} # for exposing gossip port 50111 from network-node protocol: TCP port: {{ $gossip_port }} allowedRoutes: kinds: - kind: TCPRoute + {{- end }} + {{- if $.Values.gatewayApi.gateway.listeners.grpc.enable | eq "true" }} + {{- $grpc_port := add $index $grpc_start_port }} - name: grpc-{{ $node.name }} # for exposing grpc port 50211 from haproxy or network-node protocol: TCP port: {{ $grpc_port }} allowedRoutes: kinds: - kind: TCPRoute + {{- end }} + {{- if $.Values.gatewayApi.gateway.listeners.grpcs.enable | eq "true" }} + {{- $grpcs_port := add $index $grpcs_start_port }} - name: grpcs-{{ $node.name }} # for exposing grpc port 50212 from haproxy or network-node protocol: TCP port: {{ $grpcs_port }} allowedRoutes: kinds: - kind: TCPRoute + {{- end }} + {{- if $.Values.gatewayApi.gateway.listeners.grpcWeb.enable | eq "true" }} + {{- $grpc_web_port := add $index $grpc_web_start_port }} - name: grpc-web-{{ $node.name }} # for exposing grpc-web port 8080 from envoy-proxy protocol: HTTP port: {{ $grpc_web_port }} {{- end }} -{{- end }} \ No newline at end of file + {{- end }} + # Debug ports + {{- if $.Values.gatewayApi.gateway.listeners.httpDebug.enable | eq "true" }} + - name: http-debug # this helps debugging gateway if needed + protocol: HTTP + port: {{ $.Values.gatewayApi.gateway.listeners.httpDebug.port }} + {{- end }} + {{- if $.Values.gatewayApi.gateway.listeners.tcpDebug.enable | eq "true" }} + - name: tcp-debug # this helps debugging gateway if needed + protocol: TCP + port: {{ $.Values.gatewayApi.gateway.listeners.tcpDebug.port }} + allowedRoutes: + kinds: + - kind: TCPRoute + {{- end }} +{{- end }} diff --git a/charts/hedera-network/values.yaml b/charts/hedera-network/values.yaml index 242d2d9fa..7ce335e55 100644 --- a/charts/hedera-network/values.yaml +++ b/charts/hedera-network/values.yaml @@ -40,6 +40,25 @@ gatewayApi: gateway: name: "fst" enable: "true" + listeners: + gossip: + port: 51000 # i.e. node0:51000 ... node999: 51999, points to 50111 port in haproxy or network-node + enable: "false" # by default, we don't need to expose the gossip ports + grpc: # non-tls-grpc-port + port: 52000 # i.e. node0:52000 ... node999: 52999, points to 50211 port in haproxy or network-node + enable: "true" + grpcs: # tls-grpc-port + port: 53000 # i.e. node0:53000 ... node999: 53999, points to 50212 port in haproxy or network-node + enable: "true" + grpcWeb: + port: 18000 # i.e. node0:18000 ... node999: 18999, points to 8080 port in envoy proxy + enable: "true" + httpDebug: # this helps debugging gateway if needed by provisioning a mock http app + port: 3100 + enable: "true" + tcpDebug: # this helps debugging gateway if needed by provisioning a mock grpc app + port: 3101 + enable: "true" route: hostname: "{{ .node.name }}.fst.local" diff --git a/dev/Makefile b/dev/Makefile index 42645deee..e1a933896 100644 --- a/dev/Makefile +++ b/dev/Makefile @@ -214,8 +214,8 @@ deploy-minio-operator-if-required: .PHONY: undeploy-minio-operator undeploy-minio-operator: - echo ">> Deploying minio operator..." && \ - helm delete --namespace=minio-operator minio-operator + echo ">> Deleting minio operator..." && \ + helm delete --namespace=minio-operator minio-operator ######################################### Helm Chart Test ################################# diff --git a/dev/gateway-api/grpc-debug.yaml b/dev/gateway-api/grpc-debug.yaml index 49f0d2003..3330bb5b5 100644 --- a/dev/gateway-api/grpc-debug.yaml +++ b/dev/gateway-api/grpc-debug.yaml @@ -48,7 +48,7 @@ metadata: spec: parentRefs: - name: fst - sectionName: grpc-debug + sectionName: tcp-debug rules: - backendRefs: - group: "" diff --git a/dev/scripts/gateway.sh b/dev/scripts/gateway.sh index a1fcbc161..a125f1dae 100644 --- a/dev/scripts/gateway.sh +++ b/dev/scripts/gateway.sh @@ -165,8 +165,8 @@ function test_http_route() { kubectl apply -f "${GATEWAY_API_DIR}/http-debug.yaml" kubectl wait --for=condition=Ready pods -l app=http-debug -n default - local local_port=8080 - local gateway_port=80 + local local_port=3100 + local gateway_port=3100 # needs to match the port specified at: $.Values.gatewayApi.gateway.listeners.httpDebug expose_envoy_gateway_svc ${local_port} ${gateway_port} || return 1 local route_host="debug.fst.local" @@ -203,8 +203,8 @@ function test_grpc_route() { kubectl apply -f "${GATEWAY_API_DIR}/grpc-debug.yaml" kubectl wait --for=condition=Ready pods -l app=grpc-debug -n default - local local_port=9090 - local gateway_port=9090 + local local_port=3101 + local gateway_port=3101 # needs to match the port specified at: $.Values.gatewayApi.gateway.listeners.tcpDebug expose_envoy_gateway_svc ${local_port} ${gateway_port} || return 1 local route_host="debug.fst.local" @@ -240,8 +240,8 @@ function test_tcp_route() { kubectl apply -f "${GATEWAY_API_DIR}/tcp-debug.yaml" kubectl wait --for=condition=Ready pods -l app=tcp-debug -n default - local local_port=9000 - local gateway_port=9000 + local local_port=3101 + local gateway_port=3101 # needs to match the port specified at: $.Values.gatewayApi.gateway.listeners.tcpDebug expose_envoy_gateway_svc ${local_port} ${gateway_port} || return 1 sleep 1