Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add optional Gateway API resource definition to expose endpoints #280

Merged
merged 44 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
029df12
feat: add helper scripts to manage prometheus deployment
leninmehedy Aug 13, 2023
07fe722
fix: use network-node-svc label selector
leninmehedy Aug 13, 2023
cc4eac2
fix: install prometheus operator only if crds are not installed yet
leninmehedy Aug 14, 2023
36c9145
feat: deploy prometheus service monitor conditionally along with hede…
leninmehedy Aug 14, 2023
a59ab4b
style: add missing new lines
leninmehedy Aug 14, 2023
3fa482d
fix: allow prometheus service monitor endpoints to be set by user
leninmehedy Aug 14, 2023
29a7b8a
Merge branch 'main' into 227-prometheus-servicemonitor
leninmehedy Aug 14, 2023
77e427d
ci: setup prometheus operator in CI/CD pipeline
leninmehedy Aug 14, 2023
4a68fa2
fix: update dev script to deploy prometheus operator locally if not i…
leninmehedy Aug 14, 2023
3664f81
style: fix spotless lint issue
leninmehedy Aug 14, 2023
cfcd596
fix: function definition in bash script for consistency
leninmehedy Aug 14, 2023
ee18328
Merge branch 'main' into 227-prometheus-servicemonitor
leninmehedy Aug 16, 2023
54e5cb3
Update charts/hedera-network/templates/services/network-node-svc.yaml
leninmehedy Aug 21, 2023
f5d5fc9
fix: remove otel ports from value file
leninmehedy Aug 21, 2023
e68165a
Merge branch 'main' into 227-prometheus-servicemonitor
leninmehedy Aug 21, 2023
9cb82c2
fix: port name and updated README for manual tests
leninmehedy Aug 21, 2023
59248e6
fix: port name
leninmehedy Aug 21, 2023
bff50ba
fix: install minio operator if not installed already during network d…
leninmehedy Aug 21, 2023
00d9b9c
fix: increase timeout during example app deployment
leninmehedy Aug 21, 2023
2072ad3
fix: only expose OTel metrics port from node svc
leninmehedy Aug 22, 2023
5e57f43
fix: update health-check port name for otel collector
leninmehedy Aug 22, 2023
9ddc4b2
feat: initial gateway setup files
leninmehedy Aug 16, 2023
28df314
feat: add setup files for haproxy ingress controller
leninmehedy Aug 16, 2023
a000bae
feat: working copy of gateway with http-debug svc
leninmehedy Aug 16, 2023
0c6353c
feat: setup routes conditionally for envoy-proxy, haproxy and network…
leninmehedy Aug 17, 2023
088f6ba
feat: support templated hostname for routes
leninmehedy Aug 17, 2023
bd768ea
fix: envoy cluster name
leninmehedy Aug 17, 2023
5b0aabe
fix: working http route using envoy-gateway
leninmehedy Aug 21, 2023
f82e63a
fix: enable haproxy ingress controller
leninmehedy Aug 22, 2023
9af10e9
test: add http and grpc route test scripts
leninmehedy Aug 22, 2023
38a8849
feat: add tcp-route example
leninmehedy Aug 22, 2023
baf0cee
feat: add test scripts for tcp route
leninmehedy Aug 22, 2023
d33d9af
fix: fst-gateway template
leninmehedy Aug 22, 2023
ca8b78e
fix: working copy for gateway-api demo with helper scripts
leninmehedy Aug 23, 2023
fe304cb
fix check for tcp route test success
leninmehedy Aug 24, 2023
0a8aa3d
add tcp grpc route to node-svc
leninmehedy Aug 24, 2023
4b25584
add haproxy tcp route to port 50211
leninmehedy Aug 24, 2023
3a9eb7d
fix: add envoy-proxy httproute and remap ports
leninmehedy Aug 25, 2023
5342416
feat: add support for rendering an optional PrometheusOperator Servic…
leninmehedy Aug 22, 2023
f0f0b5f
feat: mirror node as a conditional subchart (#272)
deepak-swirlds Aug 22, 2023
c256e63
style: add missing newlines
leninmehedy Aug 25, 2023
ffa0cb5
Merge branch 'main' into gateway-api
leninmehedy Aug 25, 2023
c08e809
fix: cleanup
leninmehedy Aug 25, 2023
33c8f5e
style: add missing newline
leninmehedy Aug 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions charts/hedera-network/config-files/envoy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ static_resources:
- endpoint:
address:
socket_address:
address: network-{{ .nodeConfig.name }}-service
port_value: 50211
address: network-{{ .nodeConfig.name }}-svc
port_value: 50211
12 changes: 5 additions & 7 deletions charts/hedera-network/config-files/haproxy.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,16 @@ defaults
timeout client 30s
timeout server 30s
frontend fe_proxy
mode http
option httplog
option http-use-htx
mode tcp
option tcplog
option logasap
# Read the blacklist of OFAC Sanctioned Country IP List
# Log & Reject the Traffic
acl ofac_ip src -f /var/opt/ofac/ofacBlock.acl
tcp-request connection reject if ofac_ip
acl ofac_ip_xff hdr_ip(x-forwarded-for) -f /var/opt/ofac/ofacBlock.acl
http-request deny if ofac_ip_xff
bind *:50211 proto h2
bind *:50211
default_backend be_servers
frontend fe_proxy_tls
mode tcp
Expand All @@ -33,13 +32,12 @@ frontend fe_proxy_tls
bind *:50212
default_backend be_servers_tls
backend be_servers
mode http
option http-use-htx
mode tcp
# Health Checks: Poll the server with regular health checks every 10 seconds
# Health Checks: Observe all Layer 4 TCP connections for problems.
# Health Checks: 5 connections must fail before on-error parameter is invoked and marks server down.
# Health Checks: Revive the server with regular health checks by polling the server every 10 seconds.
server server1 network-{{ .nodeConfig.name }}-svc:50211 proto h2 check inter 10s downinter 10s observe layer4 error-limit 5 on-error mark-down
server server1 network-{{ .nodeConfig.name }}-svc:50211 check inter 10s downinter 10s observe layer4 error-limit 5 on-error mark-down
backend be_servers_tls
mode tcp
option ssl-hello-chk
Expand Down
24 changes: 24 additions & 0 deletions charts/hedera-network/templates/gateway-api/envoy-routes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{- range $index, $node := ($.Values.hedera.nodes) }}
{{- $envoyProxy := $node.envoyProxy | default dict -}}
{{- $defaults := $.Values.defaults.envoyProxy }}
{{- if default $defaults.enable $envoyProxy.enable | eq "true" }}
---
apiVersion: gateway.networking.k8s.io/v1beta1
kind: HTTPRoute
metadata:
name: envoy-routes-{{ $node.name }}
namespace: default
labels:
fullstack.hedera.com/type: http-route
spec:
parentRefs:
- name: fst
sectionName: http-{{ $node.name }}
hostnames:
- {{ tpl $.Values.gatewayApi.route.hostname (dict "node" $node "Template" $.Template) }}
rules:
- backendRefs:
- name: envoy-proxy-{{ $node.name }}-svc
port: 8080
{{- end }}
{{- end }}
52 changes: 52 additions & 0 deletions charts/hedera-network/templates/gateway-api/gateway.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{{- if $.Values.gatewayApi.gatewayClass.enable | eq "true" }}
apiVersion: gateway.networking.k8s.io/v1beta1
kind: GatewayClass
metadata:
name: {{ $.Values.gatewayApi.gatewayClass.name }}
namespace: default
labels:
fullstack.hedera.com/type: gateway-class
spec:
controllerName: {{ $.Values.gatewayApi.gatewayClass.controllerName }}
{{- end }}
{{- if $.Values.gatewayApi.gateway.enable | eq "true" }}
---
apiVersion: gateway.networking.k8s.io/v1beta1
kind: Gateway
metadata:
name: {{ $.Values.gatewayApi.gateway.name }}
namespace: default
labels:
fullstack.hedera.com/type: gateway
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 }}
{{- $tcp_port := mul $index 1000 | add 50211 }}
{{- $http_port := mul $index 100 | add 8080 }}
- name: tcp-{{ $node.name }} # for haproxy or network-node TCPRoute
protocol: TCP
port: {{ $tcp_port }}
allowedRoutes:
kinds:
- kind: TCPRoute
- name: http-{{ $node.name }} # for envoy-proxy HTTPRoute
protocol: HTTP
port: {{ $http_port }}
{{- end }}
{{- end }}
23 changes: 23 additions & 0 deletions charts/hedera-network/templates/gateway-api/haproxy-routes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{{- range $index, $node := ($.Values.hedera.nodes) }}
{{- $haproxy := $node.haproxy | default dict -}}
{{- $defaults := $.Values.defaults.haproxy }}
{{- if default $defaults.enable $haproxy.enable | eq "true" }}
---
apiVersion: gateway.networking.k8s.io/v1alpha2
kind: TCPRoute
metadata:
name: haproxy-grpc-route-{{ $node.name }}
namespace: default
labels:
fullstack.hedera.com/type: tcp-route
fullstack.hedera.com/nodeName: {{ $node.name }}
spec:
parentRefs:
- name: fst
sectionName: tcp-{{ $node.name }}
rules:
- backendRefs:
- name: haproxy-{{ $node.name }}-svc
port: 50211
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{{- range $index, $node := ($.Values.hedera.nodes) }}
{{- $haproxy := $node.haproxy | default dict -}}
{{- $defaults := $.Values.defaults.haproxy }}
{{- if default $defaults.enable $haproxy.enable | eq "false" }}
---
apiVersion: gateway.networking.k8s.io/v1alpha2
kind: TCPRoute
metadata:
name: node-grpc-route-{{ $node.name }}
namespace: default
labels:
fullstack.hedera.com/type: tcp-route
fullstack.hedera.com/nodeName: {{ $node.name }}
spec:
parentRefs:
- name: fst
sectionName: tcp-{{ $node.name }}
rules:
- backendRefs:
- name: network-{{ $node.name }}-svc
port: 50211
{{- end }}
{{- end }}
2 changes: 1 addition & 1 deletion charts/hedera-network/templates/services/envoy-svc.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{ range $index, $node := ($.Values.hedera.nodes) }}
{{- $envoyProxy := $node.envoyProxy | default dict -}}
{{- $defaults := $.Values.defaults.haproxy }}
{{- $defaults := $.Values.defaults.envoyProxy }}
{{- if default $defaults.enable $envoyProxy.enable | eq "true" }}
---
apiVersion: v1
Expand Down
13 changes: 13 additions & 0 deletions charts/hedera-network/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ tester:
pullPolicy: "IfNotPresent"
resources: {}

# gateway-api configuration
gatewayApi:
gatewayClass:
name: "fst"
enable: "true"
controllerName: "gateway.envoyproxy.io/gatewayclass-controller"
# controllerName: "haproxy-ingress.github.io/controller"
gateway:
name: "fst"
enable: "true"
route:
hostname: "{{ .node.name }}.fst.local"

# default settings for a single node
# This default configurations can be overridden for each node in the hedera.nodes section.
defaults:
Expand Down
16 changes: 15 additions & 1 deletion dev/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ SCRIPTS_DIR=$(PWD)/scripts
CHART_DIR=$(PWD)/../charts/hedera-network
SCRIPT_NAME=direct-install.sh
TMP_DIR=${SCRIPTS_DIR}/../temp

# scripts
TELEMETRY_SCRIPT="telemetry.sh"
GATEWAY_API_SCRIPT="gateway.sh"

.PHONY: all
all: setup setup-cluster reset
Expand All @@ -42,7 +45,7 @@ update-helm-dependencies:
helm dependency update ../charts/hedera-network

.PHONY: deploy-chart
deploy-chart: deploy-minio-operator-if-required deploy-prometheus-operator
deploy-chart: deploy-minio-operator-if-required deploy-prometheus-operator deploy-gateway-api
echo ">> Deploying helm chart..." && \
echo "" && \
if [ "${SCRIPT_NAME}" = "nmt-install.sh" ]; then \
Expand Down Expand Up @@ -143,6 +146,17 @@ restart: stop-nodes start-nodes
.PHONY: reset
reset: destroy-network start

######################################### Gateway API #################################
.PHONY: deploy-gateway-api
deploy-gateway-api:
#source "${SCRIPTS_DIR}/${GATEWAY_API_SCRIPT}" && deploy_haproxy_ingress
source "${SCRIPTS_DIR}/${GATEWAY_API_SCRIPT}" && deploy_envoy_gateway_api

.PHONY: destroy-gateway-api
destroy-gateway-api:
#source "${SCRIPTS_DIR}/${GATEWAY_API_SCRIPT}" && destroy_haproxy_ingress
source "${SCRIPTS_DIR}/${GATEWAY_API_SCRIPT}" && destroy_envoy_gateway_api

######################################### Prometheus #################################
.PHONY: fetch-prometheus-operator-bundle
fetch-prometheus-operator-bundle:
Expand Down
43 changes: 43 additions & 0 deletions dev/gateway-api/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
SHELLOPTS:=$(if $(SHELLOPTS),$(SHELLOPTS):)pipefail:errexit
.ONESHELL:

SCRIPTS_DIR=$(PWD)/../scripts
GATEWAY_API_SCRIPT="gateway.sh"

.PHONY: deploy-gateway-api
deploy-gateway-api:
#source "${SCRIPTS_DIR}/${GATEWAY_API_SCRIPT}" && deploy_haproxy_ingress
source "${SCRIPTS_DIR}/${GATEWAY_API_SCRIPT}" && deploy_envoy_gateway_api

.PHONY: destroy-gateway-api
destroy-gateway-api:
#source "${SCRIPTS_DIR}/${GATEWAY_API_SCRIPT}" && destroy_haproxy_ingress
source "${SCRIPTS_DIR}/${GATEWAY_API_SCRIPT}" && destroy_envoy_gateway_api

.PHONY: deploy-fst-gateway
deploy-fst-gateway: deploy-gateway-api
kubectl apply -f ./fst-gateway.yaml

.PHONY: destroy-fst-gateway
destroy-fst-gateway:
kubectl delete -f fst-gateway.yaml

.PHONY: expose-envoy-gateway-svc
expose-envoy-gateway-svc:
source "${SCRIPTS_DIR}/${GATEWAY_API_SCRIPT}" && expose_envoy_gateway_svc ${PORT} ${GATEWAY_PORT}

.PHONY: unexpose-envoy-gateway-svc
unexpose-envoy-gateway-svc:
source "${SCRIPTS_DIR}/${GATEWAY_API_SCRIPT}" && unexpose_envoy_gateway_svc

.PHONY: test-gateway-http-route
test-gateway-http-route:
source "${SCRIPTS_DIR}/${GATEWAY_API_SCRIPT}" && test_http_route

.PHONY: test-gateway-grpc-route
test-gateway-grpc-route:
source "${SCRIPTS_DIR}/${GATEWAY_API_SCRIPT}" && test_grpc_route

.PHONY: test-gateway-tcp-route
test-gateway-tcp-route:
source "${SCRIPTS_DIR}/${GATEWAY_API_SCRIPT}" && test_tcp_route
29 changes: 29 additions & 0 deletions dev/gateway-api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Gateway API
This folder includes scripts and files to debug Gateway API.

## Manual Test
- Deploy `fst` Gateway
- `make deploy-fst-gateway`
- Test HTTPRoute
- ` make test-gateway-http-route` and check for below line
```
********************************************************
SUCCESS: HTTPRoute debug.fst.local:8080
********************************************************
```
- Test TCPRoute
- ` make test-gateway-tcp-route` and check for below line
```
********************************************************
SUCCESS: TCPRoute localhost:9000
********************************************************
```
- Test GRPCRoute
- ` make test-gateway-grpc-route` and check for below line
```
********************************************************
SUCCESS: GRPCRoute debug.fst.local:9090
********************************************************
```
- Delete `fst` Gateway
- `make destroy-fst-gateway`
31 changes: 31 additions & 0 deletions dev/gateway-api/fst-gateway.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apiVersion: gateway.networking.k8s.io/v1beta1
kind: GatewayClass
metadata:
name: fst
spec:
controllerName: gateway.envoyproxy.io/gatewayclass-controller
# controllerName: haproxy-ingress.github.io/controller
---
apiVersion: gateway.networking.k8s.io/v1beta1
kind: Gateway
metadata:
name: fst
spec:
gatewayClassName: fst
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
---
Loading