From 2ae96221b756d9732db15fbab7a44957fa6c4279 Mon Sep 17 00:00:00 2001 From: "V. Aretakis" Date: Sun, 9 Aug 2026 18:13:35 +0300 Subject: [PATCH] Add aPI Gateway support Signed-off-by: V. Aretakis --- charts/node-red/README.md | 30 ++++++++++-- charts/node-red/README.md.gotmpl | 18 ++++++++ charts/node-red/templates/NOTES.txt | 8 ++++ charts/node-red/templates/httproute.yaml | 42 +++++++++++++++++ charts/node-red/tests/httproute_test.yaml | 46 +++++++++++++++++++ .../tests/values/httproute_values.yaml | 15 ++++++ charts/node-red/values.yaml | 17 +++++++ 7 files changed, 173 insertions(+), 3 deletions(-) create mode 100644 charts/node-red/templates/httproute.yaml create mode 100644 charts/node-red/tests/httproute_test.yaml create mode 100644 charts/node-red/tests/values/httproute_values.yaml diff --git a/charts/node-red/README.md b/charts/node-red/README.md index 94ada8b8..062fea46 100644 --- a/charts/node-red/README.md +++ b/charts/node-red/README.md @@ -1,6 +1,6 @@ # node-red ⚙ -![Version: 0.40.1](https://img.shields.io/badge/Version-0.40.1-informational?style=for-the-badge) +![Version: 0.40.2](https://img.shields.io/badge/Version-0.40.2-informational?style=for-the-badge) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=for-the-badge) ![AppVersion: 4.1.2](https://img.shields.io/badge/AppVersion-4.1.2-informational?style=for-the-badge) @@ -18,7 +18,7 @@ A Helm chart for Node-Red, a low-code programming for event-driven applications To install the chart using the OCI artifact, run: ```bash -helm install node-red oci://ghcr.io/schwarzit/charts/node-red --version 0.40.1 +helm install node-red oci://ghcr.io/schwarzit/charts/node-red --version 0.40.2 ``` ## Usage @@ -34,7 +34,7 @@ helm repo update To install the chart with the release name node-red run: ```bash -helm install node-red node-red/node-red --version 0.40.1 +helm install node-red node-red/node-red --version 0.40.2 ``` After a few seconds, node-red should be running. @@ -73,6 +73,11 @@ The command removes all the Kubernetes components associated with the chart and | extraVolumeMounts | string | `nil` | Extra Volume Mounts for the node-red pod | | extraVolumes | string | `nil` | Extra Volumes for the pod | | fullnameOverride | string | `""` | String to fully override "node-red.fullname" | +| httpRoute.annotations | object | `{}` | Additional HTTPRoute annotations | +| httpRoute.enabled | bool | `false` | Enable an HTTPRoute resource for the server | +| httpRoute.hostnames | list | `[]` | Hostnames exposed by the HTTPRoute | +| httpRoute.parentRefs | list | `[]` | Parent references for Gateway API attachment | +| httpRoute.rules | list | `[{"backendRefs":[],"matches":[{"path":{"type":"PathPrefix","value":"/"}}]}]` | HTTPRoute rules. If backendRefs is empty, traffic is forwarded to this chart's service. | | image.pullPolicy | string | `"IfNotPresent"` | The image pull policy | | image.registry | string | `"docker.io"` | The image registry to pull from | | image.repository | string | `"nodered/node-red"` | The image repository to pull from | @@ -134,6 +139,7 @@ The command removes all the Kubernetes components associated with the chart and | sidecar.env.script | string | `"flow_refresh.py"` | Absolute path to shell script to execute after a configmap got reloaded. | | sidecar.env.skip_init | bool | `false` | Skip the initial request to REQ_URL when using watch mode (v2.1.0+) | | sidecar.env.sleep_time_sidecar | string | `"5s"` | Set the sleep time for refresh script | +| sidecar.env.url | string | `""` | Optional: Custom target URL for the sidecar. If left empty, the internal service cluster URL is used automatically. | | sidecar.env.username | string | `""` | | | sidecar.extraEnv | list | `[]` | Extra Environments for the sidecar | | sidecar.extraNodeModules | list | `[]` | Extra Node-Modules that will be installed from the sidecar script | @@ -164,6 +170,24 @@ helm install node-red node-red/node-red -f values.yaml > **Tip**: You can use the default [values.yaml](values.yaml) +## Gateway API HTTPRoute + +This chart can expose Node-RED via Gateway API using `HTTPRoute`. + +Example: + +```yaml +httpRoute: + enabled: true + parentRefs: + - name: edge-gateway + sectionName: web + hostnames: + - nodered.example.com +``` + +If a rule does not define `backendRefs`, the chart routes traffic to the default Node-RED service and `service.port`. + ## Monitoring 🌡️ To enable the node-red prometheus monitoring capability, you need to install the node `node-red-contrib-prometheus-exporter`. For more details see [official documentation](https://flows.nodered.org/node/node-red-contrib-prometheus-exporter) diff --git a/charts/node-red/README.md.gotmpl b/charts/node-red/README.md.gotmpl index f394c29e..2a15b5b8 100644 --- a/charts/node-red/README.md.gotmpl +++ b/charts/node-red/README.md.gotmpl @@ -78,6 +78,24 @@ helm install node-red node-red/node-red -f values.yaml > **Tip**: You can use the default [values.yaml](values.yaml) +## Gateway API HTTPRoute + +This chart can expose Node-RED via Gateway API using `HTTPRoute`. + +Example: + +```yaml +httpRoute: + enabled: true + parentRefs: + - name: edge-gateway + sectionName: web + hostnames: + - nodered.example.com +``` + +If a rule does not define `backendRefs`, the chart routes traffic to the default Node-RED service and `service.port`. + ## Monitoring 🌡️ To enable the node-red prometheus monitoring capability, you need to install the node `node-red-contrib-prometheus-exporter`. For more details see [official documentation](https://flows.nodered.org/node/node-red-contrib-prometheus-exporter) diff --git a/charts/node-red/templates/NOTES.txt b/charts/node-red/templates/NOTES.txt index fab9c003..787672da 100644 --- a/charts/node-red/templates/NOTES.txt +++ b/charts/node-red/templates/NOTES.txt @@ -5,6 +5,14 @@ http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} {{- end }} {{- end }} + {{- else if .Values.httpRoute.enabled }} + {{- if .Values.httpRoute.hostnames }} + {{- range $host := .Values.httpRoute.hostnames }} + http://{{ $host }} + {{- end }} + {{- else }} + HTTPRoute {{ include "node-red.fullname" . }} has no hostnames configured. Check your Gateway listener and route rules. + {{- end }} {{- else if contains "NodePort" .Values.service.type }} export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "node-red.fullname" . }}) export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") diff --git a/charts/node-red/templates/httproute.yaml b/charts/node-red/templates/httproute.yaml new file mode 100644 index 00000000..c7c39b6e --- /dev/null +++ b/charts/node-red/templates/httproute.yaml @@ -0,0 +1,42 @@ +{{- if .Values.httpRoute.enabled -}} +{{- $fullName := include "node-red.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +apiVersion: gateway.networking.k8s.io/v1 +kind: HTTPRoute +metadata: + name: {{ $fullName }} + namespace: {{ .Release.Namespace | quote }} + labels: + {{- include "node-red.labels" . | nindent 4 }} + {{- with .Values.httpRoute.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- with .Values.httpRoute.parentRefs }} + parentRefs: + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with .Values.httpRoute.hostnames }} + hostnames: + {{- toYaml . | nindent 4 }} + {{- end }} + rules: + {{- range .Values.httpRoute.rules }} + - {{- with .matches }} + matches: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .filters }} + filters: + {{- toYaml . | nindent 8 }} + {{- end }} + backendRefs: + {{- if .backendRefs }} + {{- toYaml .backendRefs | nindent 8 }} + {{- else }} + - name: {{ $fullName }} + port: {{ $svcPort }} + {{- end }} + {{- end }} +{{- end }} diff --git a/charts/node-red/tests/httproute_test.yaml b/charts/node-red/tests/httproute_test.yaml new file mode 100644 index 00000000..a5ff5bc2 --- /dev/null +++ b/charts/node-red/tests/httproute_test.yaml @@ -0,0 +1,46 @@ +suite: test httproute template +templates: + - httproute.yaml +tests: + - it: should not render, when httpRoute.enabled=false + asserts: + - hasDocuments: + count: 0 + + - it: should render defaults, when httpRoute.enabled=true + set: + httpRoute.enabled: true + asserts: + - hasDocuments: + count: 1 + - isKind: + of: HTTPRoute + - equal: + path: spec.rules[0].backendRefs[0].name + value: RELEASE-NAME-node-red + - equal: + path: spec.rules[0].backendRefs[0].port + value: 1880 + + - it: should render custom parentRefs, hostnames and backendRefs + values: + - ./values/httproute_values.yaml + asserts: + - equal: + path: spec.parentRefs[0].name + value: edge-gateway + - equal: + path: spec.parentRefs[0].sectionName + value: web + - equal: + path: spec.hostnames[0] + value: nodered.example.com + - equal: + path: spec.rules[0].matches[0].path.value + value: /flows + - equal: + path: spec.rules[0].backendRefs[0].name + value: custom-backend + - equal: + path: spec.rules[0].backendRefs[0].port + value: 8080 diff --git a/charts/node-red/tests/values/httproute_values.yaml b/charts/node-red/tests/values/httproute_values.yaml new file mode 100644 index 00000000..0e7c39ac --- /dev/null +++ b/charts/node-red/tests/values/httproute_values.yaml @@ -0,0 +1,15 @@ +httpRoute: + enabled: true + parentRefs: + - name: edge-gateway + sectionName: web + hostnames: + - nodered.example.com + rules: + - matches: + - path: + type: PathPrefix + value: /flows + backendRefs: + - name: custom-backend + port: 8080 diff --git a/charts/node-red/values.yaml b/charts/node-red/values.yaml index 130cda5c..6f995a8c 100644 --- a/charts/node-red/values.yaml +++ b/charts/node-red/values.yaml @@ -199,6 +199,23 @@ ingress: # -- Name of the Issuer # name: "test" +httpRoute: + # -- Enable an HTTPRoute resource for the server + enabled: false + # -- Additional HTTPRoute annotations + annotations: {} + # -- Parent references for Gateway API attachment + parentRefs: [] + # -- Hostnames exposed by the HTTPRoute + hostnames: [] + # -- HTTPRoute rules. If backendRefs is empty, traffic is forwarded to this chart's service. + rules: + - matches: + - path: + type: PathPrefix + value: / + backendRefs: [] + # -- Startup probe for the Deployment startupProbe: httpGet: