Skip to content

Commit

Permalink
feat: add Gateway API route for Hedera Explorer (#466)
Browse files Browse the repository at this point in the history
Signed-off-by: Quan Nguyen <[email protected]>
  • Loading branch information
qnswirlds authored Oct 27, 2023
1 parent 70fd199 commit c53943c
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ spec:
protocol: HTTP
port: {{ $grpc_web_port }}
{{- end }}
{{- end }}
{{- end }}
{{- if $.Values.gatewayApi.gateway.listeners.hederaExplorer.enable | eq "true" }}
- name: hedera-explorer # for exposing fst-hedera-explorer port 80
protocol: HTTP
port: {{ $.Values.gatewayApi.gateway.listeners.hederaExplorer.port }}
{{- end }}
# Debug ports
{{- if $.Values.gatewayApi.gateway.listeners.httpDebug.enable | eq "true" }}
- name: http-debug # this helps debugging gateway if needed
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: gateway.networking.k8s.io/v1beta1
kind: HTTPRoute
metadata:
name: hedera-explorer-route
namespace: {{ default $.Release.Namespace $.Values.global.namespaceOverride }}
labels:
fullstack.hedera.com/type: http-route
spec:
parentRefs:
- name: fst
sectionName: hedera-explorer
rules:
- backendRefs:
- name: fst-hedera-explorer
port: 80
3 changes: 3 additions & 0 deletions charts/fullstack-deployment/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ gatewayApi:
tcpDebug: # this helps debugging gateway if needed by provisioning a mock grpc app
port: 3101
enable: "true"
hederaExplorer:
port: 8888 # points to 80 port on fst-hedera-explorer
enable: "true"
route:
hostname: "{{ .node.name }}.fst.local"

Expand Down
4 changes: 4 additions & 0 deletions dev/gateway-api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,7 @@ test-gateway-grpc-route:
.PHONY: test-gateway-tcp-route
test-gateway-tcp-route:
source "${SCRIPTS_DIR}/${GATEWAY_API_SCRIPT}" && test_tcp_route

.PHONY: test-gateway-hedera-explorer-route
test-gateway-hedera-explorer-route:
source "${SCRIPTS_DIR}/${GATEWAY_API_SCRIPT}" && test_hedera_explorer_route
34 changes: 34 additions & 0 deletions dev/scripts/gateway.sh
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,37 @@ function test_tcp_route() {

log_time "test_tcp_route"
}

function test_hedera_explorer_route() {
local local_port=8888
local gateway_port=8888 # needs to match the port specified at: $.Values.gatewayApi.gateway.listeners.hederaExplorer
expose_envoy_gateway_svc ${local_port} ${gateway_port} || return 1

local route_host="fst.local"

sleep 1

echo "Checking ${route_host}"
echo "-----------------------------------------------------------------------------------------------------"
echo ""

local status=$(curl --header "Host: ${route_host}" -o /dev/null -s -w "%{http_code}\n" localhost:${local_port})

echo ""
echo "********************************************************"
if [[ $status -eq 200 ]]; then
echo "SUCCESS: HederaExplorerRoute ${route_host}:${gateway_port}"
else
curl --header "Host: ${route_host}" -vvv localhost:${local_port}
echo ""
echo "FAIL: HederaExplorerRoute ${route_host}:${gateway_port}"
fi
echo "********************************************************"
echo ""

echo "Cleanup"
echo "-----------------------------------------------------------------------------------------------------"
unexpose_envoy_gateway_svc || true

log_time "test_hedera_explorer_route"
}

0 comments on commit c53943c

Please sign in to comment.