Skip to content

Commit

Permalink
feat: parameterize gateway port mapping using values file (#339)
Browse files Browse the repository at this point in the history
Signed-off-by: Lenin Mehedy <[email protected]>
  • Loading branch information
leninmehedy authored Sep 13, 2023
1 parent 8b44410 commit 0c16855
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 30 deletions.
53 changes: 32 additions & 21 deletions charts/hedera-network/templates/gateway-api/gateway.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
{{- 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 }}
19 changes: 19 additions & 0 deletions charts/hedera-network/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
4 changes: 2 additions & 2 deletions dev/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 #################################
Expand Down
2 changes: 1 addition & 1 deletion dev/gateway-api/grpc-debug.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ metadata:
spec:
parentRefs:
- name: fst
sectionName: grpc-debug
sectionName: tcp-debug
rules:
- backendRefs:
- group: ""
Expand Down
12 changes: 6 additions & 6 deletions dev/scripts/gateway.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 0c16855

Please sign in to comment.