From 5dd224c5f66632347489e4bc641fe3265d7c7754 Mon Sep 17 00:00:00 2001 From: Daniel Garcia Rico Date: Mon, 9 Nov 2026 16:02:11 +0000 Subject: [PATCH] AITRAX-2881: codetogether-collab chart 1.3.0 - optional Gateway API HTTPRoute and ListenerSet Live Collab can now be routed through a Gateway (for example NGINX Gateway Fabric) instead of an Ingress controller, like the codetogether-ai chart: - gateway.enabled renders an HTTPRoute for the codetogether.url host, attached to gateway.parentRefs. - gateway.listenerSet.enabled renders a ListenerSet with this release's HTTPS listener on a shared Gateway; the HTTPRoute attaches to it. - Off by default; the default render is unchanged. - NOTES, README and the helm template CI checks cover both modes. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/helm-template-check.yml | 28 +++++++ charts/collab/Chart.yaml | 2 +- charts/collab/README.md | 96 +++++++++++++++++++++++ charts/collab/templates/NOTES.txt | 29 +++++++ charts/collab/templates/_helpers.tpl | 40 +++++++++- charts/collab/templates/httproute.yaml | 36 +++++++++ charts/collab/templates/listenerset.yaml | 42 ++++++++++ charts/collab/values.yaml | 43 ++++++++++ 8 files changed, 314 insertions(+), 2 deletions(-) create mode 100644 charts/collab/templates/httproute.yaml create mode 100644 charts/collab/templates/listenerset.yaml diff --git a/.github/workflows/helm-template-check.yml b/.github/workflows/helm-template-check.yml index f1e6b86..04d4928 100644 --- a/.github/workflows/helm-template-check.yml +++ b/.github/workflows/helm-template-check.yml @@ -23,6 +23,34 @@ jobs: - name: Validate Collab Chart run: | helm template collab ./charts/collab --values ./charts/collab/values.yaml + # Gateway API: HTTPRoute on an existing Gateway listener + helm template collab ./charts/collab --values ./charts/collab/values.yaml \ + --set ingress.enabled=false \ + --set gateway.enabled=true \ + --set 'gateway.parentRefs[0].name=shared-gateway' \ + --set 'gateway.parentRefs[0].namespace=gateway-system' \ + --api-versions gateway.networking.k8s.io/v1/HTTPRoute + # ListenerSet on a shared Gateway; the HTTPRoute attaches to it + helm template collab ./charts/collab --values ./charts/collab/values.yaml \ + --set ingress.enabled=false \ + --set gateway.enabled=true \ + --set gateway.listenerSet.enabled=true \ + --set gateway.listenerSet.parentRef.name=shared-gateway \ + --set gateway.listenerSet.parentRef.namespace=gateway-system \ + --api-versions gateway.networking.k8s.io/v1/HTTPRoute \ + --api-versions gateway.networking.k8s.io/v1/ListenerSet \ + > /tmp/collab-listenerset.yaml + grep -q '^kind: ListenerSet$' /tmp/collab-listenerset.yaml + grep -q 'kind: ListenerSet$' <(sed -n '/^kind: HTTPRoute$/,/^---/p' /tmp/collab-listenerset.yaml) + # listenerSet without gateway.enabled must fail instead of rendering nothing + if helm template collab ./charts/collab --values ./charts/collab/values.yaml \ + --set gateway.listenerSet.enabled=true \ + --set gateway.listenerSet.parentRef.name=shared-gateway > /tmp/collab-ls-no-gw.out 2>&1; then + echo "listenerSet without gateway.enabled rendered" >&2; exit 1 + fi + grep -q 'requires gateway.enabled=true' /tmp/collab-ls-no-gw.out + # helm upgrade --reuse-values from a chart without `gateway` drops the key + helm template collab ./charts/collab --values ./charts/collab/values.yaml --set gateway=null - name: Validate HQ Chart run: | diff --git a/charts/collab/Chart.yaml b/charts/collab/Chart.yaml index a4e3bb8..a78ba9e 100644 --- a/charts/collab/Chart.yaml +++ b/charts/collab/Chart.yaml @@ -3,7 +3,7 @@ name: codetogether-collab description: CodeTogether Collab type: application -version: 1.2.9 +version: 1.3.0 appVersion: "2026.1.2" icon: https://www.codetogether.com/wp-content/uploads/2020/02/codetogether-circle-128.png diff --git a/charts/collab/README.md b/charts/collab/README.md index f235f45..80b639a 100644 --- a/charts/collab/README.md +++ b/charts/collab/README.md @@ -11,6 +11,10 @@ This chart has been created with Helm v3 and tested with: - Kubernetes v1.18+ - Helm v3.5+ +With `gateway.enabled=true` (see [Gateway API](#gateway-api-nginx-gateway-fabric)), +the cluster also needs the Gateway API CRDs (v1.5+ for the ListenerSet) and a +`Gateway`, for example from NGINX Gateway Fabric. + ## Configuration The following table lists configurable parameters of the CodeTogether Collab chart and their default values: @@ -47,6 +51,14 @@ The following table lists configurable parameters of the CodeTogether Collab cha | `locatorEdge.region` | Region for the edge server | `default` | | `ingress.enabled` | Enables ingress controller resource | `true` | | `ingress.tls.secretName` | TLS secret name for ingress | `codetogether-tls` | +| `gateway.enabled` | Creates a Gateway API `HTTPRoute` for the `codetogether.url` host | `false` | +| `gateway.parentRefs` | Gateway(s) the `HTTPRoute` attaches to; required when enabled unless `gateway.listenerSet.enabled` | `[]` | +| `gateway.annotations` / `gateway.labels` | Extra `HTTPRoute` metadata (`labels` also go on the `ListenerSet`) | `{}` | +| `gateway.listenerSet.enabled` | Creates a `ListenerSet` with this release's HTTPS listener; requires `gateway.enabled=true` | `false` | +| `gateway.listenerSet.parentRef` | The shared Gateway (`name`, `namespace`); required when enabled | `{}` | +| `gateway.listenerSet.listenerName` / `port` | Listener name (the route's `sectionName`) and port | `https` / `443` | +| `gateway.listenerSet.tlsSecretName` | TLS Secret for the listener | `-tls` | +| `gateway.listenerSet.annotations` | `ListenerSet` annotations (e.g. the cert-manager issuer) | `{}` | | `dashboard.enabled` | Enables the dashboard and allows configuration of credentials | `false` | | `dashboard.username` | Dashboard username | `my-dashboard-username` | | `dashboard.password` | Dashboard password | `my-dashboard-password` | @@ -78,6 +90,90 @@ To secure CodeTogether, you can add a `secret` that contains your TLS (Transport $ kubectl create secret tls codetogether-tls --key --cert ``` +## Gateway API (NGINX Gateway Fabric) + +Clusters that route with Gateway API instead of an Ingress controller (for +example NGINX Gateway Fabric, which replaces the retired ingress-nginx) can have +the chart attach an `HTTPRoute` to an existing `Gateway`: + +```yaml +ingress: + enabled: false +gateway: + enabled: true + parentRefs: + - name: shared-gateway # your Gateway + namespace: gateway-system # omit if it is in the release namespace + sectionName: https # the HTTPS listener with the certificate +``` + +The chart renders an `HTTPRoute` for the `codetogether.url` host that sends `/` +to the chart Service. WebSocket connections need no extra setting: NGINX Gateway +Fabric passes the upgrade through. Settings you added as Ingress annotations +(`ingress.annotations`, `ingress.config`) don't carry over; set the equivalent on +your Gateway. + +### ListenerSet: your own listener on a shared Gateway + +Instead of adding a listener to the shared `Gateway` for this host, the chart +can create a `ListenerSet` (`gateway.networking.k8s.io/v1`, Gateway API v1.5+) +that adds the HTTPS listener for the `codetogether.url` host, with its +certificate, from the release namespace. The `HTTPRoute` then attaches to that +ListenerSet, so leave `gateway.parentRefs` empty: + +```yaml +ingress: + enabled: false +gateway: + enabled: true + listenerSet: + enabled: true + parentRef: + name: gateway-ngf # the shared Gateway + namespace: kube-system + # The certificate Secret defaults to -tls. Set + # tlsSecretName: codetogether-tls to keep the certificate from the TLS step. + annotations: + cert-manager.io/cluster-issuer: cert-manager-clusterissuer +``` + +The shared Gateway has to accept ListenerSets from the release namespace +(`spec.allowedListeners.namespaces`). With a cert-manager version that supports +ListenerSets, the issuer annotation on the ListenerSet issues the certificate +into that Secret; otherwise create the Secret yourself. On cert-manager v1.21 +that support is off by default; enable it in the cert-manager chart values: + +```yaml +config: + apiVersion: controller.config.cert-manager.io/v1alpha1 + kind: ControllerConfiguration + enableGatewayAPI: true + enableGatewayAPIListenerSet: true +featureGates: ListenerSets=true +``` + +If you already applied a ListenerSet with the same name by hand, Helm refuses to +take it over. Let Helm adopt it before the upgrade: + +```bash +kubectl -n label listenerset app.kubernetes.io/managed-by=Helm +kubectl -n annotate listenerset \ + meta.helm.sh/release-name= meta.helm.sh/release-namespace= +``` + +A `helm rollback` to a chart version without `gateway`, or a `helm uninstall`, +deletes the ListenerSet and with it this host's listener. + +The chart doesn't create the `Gateway`. On the Gateway side, check that: + +- the listener allows routes from the release namespace + (`allowedRoutes.namespaces`); +- the listener can read its certificate Secret. A Secret in another namespace + needs a `ReferenceGrant` there; +- the route is accepted: + `kubectl get httproute -o jsonpath='{.status.parents[*].conditions}'` + (the install notes print the exact command). + ## Installing the Chart To install the chart with the release name `codetogether-collab`: diff --git a/charts/collab/templates/NOTES.txt b/charts/collab/templates/NOTES.txt index 7944fec..df07709 100644 --- a/charts/collab/templates/NOTES.txt +++ b/charts/collab/templates/NOTES.txt @@ -1,7 +1,36 @@ Application URL: +{{- $gw := .Values.gateway | default dict }} {{- if .Values.ingress.enabled }} {{- $host := (urlParse .Values.codetogether.url).host }} http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host }}{{ .path }} +{{- else if $gw.enabled }} + https://{{ (urlParse .Values.codetogether.url).host }}/ +{{- end }} + +{{- if $gw.enabled }} + +Gateway API: + {{- $parents := list }} + {{- range $gw.parentRefs }} + {{- $p := .name }} + {{- with .namespace }}{{ $p = printf "%s (namespace %s)" $p . }}{{ end }} + {{- with .sectionName }}{{ $p = printf "%s listener %s" $p . }}{{ end }} + {{- $parents = append $parents $p }} + {{- end }} + {{- if eq (include "codetogether.listenerSetEnabled" .) "true" }} + {{- $lsParent := $gw.listenerSet.parentRef }} + ListenerSet {{ include "codetogether.fullname" . }} adds an HTTPS listener to Gateway {{ $lsParent.name }}{{ with $lsParent.namespace }} (namespace {{ . }}){{ end }}. + Check it was accepted: kubectl get listenerset {{ include "codetogether.fullname" . }} -n {{ .Release.Namespace }} -o jsonpath='{.status.conditions}' + {{- if not $parents }} + {{- $parents = list (printf "ListenerSet %s listener %s" (include "codetogether.fullname" .) ($gw.listenerSet.listenerName | default "https")) }} + {{- end }} + {{- end }} + HTTPRoute {{ include "codetogether.fullname" . }} attaches to: {{ join ", " $parents }} + Check it was accepted: kubectl get httproute {{ include "codetogether.fullname" . }} -n {{ .Release.Namespace }} -o jsonpath='{.status.parents[*].conditions}' +{{- if .Values.ingress.enabled }} + WARNING: ingress.enabled is also true, so both an Ingress and an HTTPRoute + serve this host. Set ingress.enabled=false once the Gateway path works. +{{- end }} {{- end }} {{- if or .Values.av.enabled .Values.av.serverIP .Values.av.stunServers.enabled .Values.av.jitsiUrl }} diff --git a/charts/collab/templates/_helpers.tpl b/charts/collab/templates/_helpers.tpl index d257964..c6f017e 100644 --- a/charts/collab/templates/_helpers.tpl +++ b/charts/collab/templates/_helpers.tpl @@ -94,4 +94,42 @@ Get Proxy secret name {{- printf "%s-proxy-secret" $fullName }} {{- end }} {{- end }} -{{- end }} \ No newline at end of file +{{- end }} + +{{/* +Gateway API hostname: the codetogether.url host without a port (Gateway API +hostnames can't carry one). +*/}} +{{- define "codetogether.routeHostname" -}} +{{- $host := regexReplaceAll ":[0-9]+$" (urlParse (toString .Values.codetogether.url)).host "" -}} +{{- if not $host -}} +{{- fail "gateway.enabled=true requires codetogether.url to be a full URL with a host, for example https://codetogether.example.com." -}} +{{- end -}} +{{- $host -}} +{{- end }} + +{{/* +"true" when the chart renders a ListenerSet. Read `gateway` defensively: a +`helm upgrade --reuse-values` from a chart without it keeps the old values and +skips the new defaults. +*/}} +{{- define "codetogether.listenerSetEnabled" -}} +{{- $gw := .Values.gateway | default dict -}} +{{- if and $gw.enabled ($gw.listenerSet | default dict).enabled -}}true{{- end -}} +{{- end }} + +{{/* +HTTPRoute parentRefs: gateway.parentRefs when set; otherwise the chart's +ListenerSet and its listener. +*/}} +{{- define "codetogether.routeParentRefs" -}} +{{- $gw := .Values.gateway | default dict -}} +{{- if $gw.parentRefs -}} +{{- toYaml $gw.parentRefs -}} +{{- else if eq (include "codetogether.listenerSetEnabled" .) "true" -}} +- group: gateway.networking.k8s.io + kind: ListenerSet + name: {{ include "codetogether.fullname" . }} + sectionName: {{ ($gw.listenerSet | default dict).listenerName | default "https" }} +{{- end -}} +{{- end }} diff --git a/charts/collab/templates/httproute.yaml b/charts/collab/templates/httproute.yaml new file mode 100644 index 0000000..ccfdee0 --- /dev/null +++ b/charts/collab/templates/httproute.yaml @@ -0,0 +1,36 @@ +{{- $gw := .Values.gateway | default dict }} +{{- if $gw.enabled }} +{{- if not (include "codetogether.routeParentRefs" .) }} +{{- fail "gateway.enabled=true requires gateway.parentRefs (the Gateway, and namespace/sectionName if needed, the HTTPRoute attaches to) or gateway.listenerSet.enabled=true." }} +{{- end }} +{{- if not (.Capabilities.APIVersions.Has "gateway.networking.k8s.io/v1/HTTPRoute") }} +{{- fail "gateway.enabled=true but the cluster does not serve gateway.networking.k8s.io/v1 HTTPRoute. Install the Gateway API CRDs (or pass --api-versions gateway.networking.k8s.io/v1/HTTPRoute to helm template)." }} +{{- end }} +{{- $fullName := include "codetogether.fullname" . }} +apiVersion: gateway.networking.k8s.io/v1 +kind: HTTPRoute +metadata: + name: {{ $fullName }} + labels: + {{- include "codetogether.labels" . | nindent 4 }} + {{- with $gw.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with $gw.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + parentRefs: + {{- include "codetogether.routeParentRefs" . | nindent 4 }} + hostnames: + - {{ include "codetogether.routeHostname" . | quote }} + rules: + - matches: + - path: + type: PathPrefix + value: / + backendRefs: + - name: {{ $fullName }} + port: {{ .Values.service.port }} +{{- end }} diff --git a/charts/collab/templates/listenerset.yaml b/charts/collab/templates/listenerset.yaml new file mode 100644 index 0000000..c944857 --- /dev/null +++ b/charts/collab/templates/listenerset.yaml @@ -0,0 +1,42 @@ +{{- $gwValues := .Values.gateway | default dict }} +{{- if and ($gwValues.listenerSet | default dict).enabled (not $gwValues.enabled) }} +{{- fail "gateway.listenerSet.enabled=true requires gateway.enabled=true: the ListenerSet carries the HTTPRoute's listener, and without the HTTPRoute nothing is rendered." }} +{{- end }} +{{- if eq (include "codetogether.listenerSetEnabled" .) "true" }} +{{- $ls := .Values.gateway.listenerSet }} +{{- $parent := $ls.parentRef | default dict }} +{{- if not $parent.name }} +{{- fail "gateway.listenerSet.enabled=true requires gateway.listenerSet.parentRef.name: the Gateway the ListenerSet adds a listener to." }} +{{- end }} +{{- if not (.Capabilities.APIVersions.Has "gateway.networking.k8s.io/v1/ListenerSet") }} +{{- fail "gateway.listenerSet.enabled=true but the cluster does not serve gateway.networking.k8s.io/v1 ListenerSet. Install Gateway API v1.5+ standard CRDs (or pass --api-versions gateway.networking.k8s.io/v1/ListenerSet to helm template)." }} +{{- end }} +# HTTPS listener for this release on the shared Gateway {{ $parent.name }}. With a +# cert-manager.io/(cluster-)issuer annotation, cert-manager issues the +# certificate into the Secret named below. +apiVersion: gateway.networking.k8s.io/v1 +kind: ListenerSet +metadata: + name: {{ include "codetogether.fullname" . }} + labels: + {{- include "codetogether.labels" . | nindent 4 }} + {{- with $gwValues.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with $ls.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + parentRef: + {{- toYaml $parent | nindent 4 }} + listeners: + - name: {{ $ls.listenerName | default "https" }} + hostname: {{ include "codetogether.routeHostname" . | quote }} + port: {{ $ls.port | default 443 }} + protocol: HTTPS + tls: + mode: Terminate + certificateRefs: + - name: {{ $ls.tlsSecretName | default (printf "%s-tls" (include "codetogether.fullname" .)) }} +{{- end }} diff --git a/charts/collab/values.yaml b/charts/collab/values.yaml index 6b514a0..b0ee29a 100644 --- a/charts/collab/values.yaml +++ b/charts/collab/values.yaml @@ -163,6 +163,49 @@ ingress: tls: - secretName: codetogether-tls # +# Gateway API (gateway.networking.k8s.io/v1), for clusters that route with a +# Gateway instead of an Ingress controller (for example NGINX Gateway Fabric, +# replacing the retired ingress-nginx). Off by default. +# +# The chart attaches an HTTPRoute for the codetogether.url host to a Gateway you +# already run. It does not create the Gateway. Set ingress.enabled=false when you +# switch, unless you deliberately run both during a migration. +# +gateway: + enabled: false + # Gateway(s) the HTTPRoute attaches to. Required when enabled, unless + # listenerSet.enabled is true. Example: + # parentRefs: + # - name: shared-gateway + # namespace: gateway-system + # sectionName: https # the HTTPS listener that holds the certificate + parentRefs: [] + annotations: {} + labels: {} + # Optional ListenerSet (gateway.networking.k8s.io/v1, Gateway API v1.5+): adds + # this release's HTTPS listener (the codetogether.url host and its certificate) + # to a shared Gateway, so the shared Gateway doesn't need a listener edited for + # each application. The Gateway must allow it (spec.allowedListeners). When + # enabled and parentRefs is empty, the HTTPRoute attaches to this ListenerSet; + # if parentRefs is set, the HTTPRoute attaches only to those parents. + listenerSet: + enabled: false + # The Gateway this ListenerSet adds a listener to. Required when enabled. + # Example: + # parentRef: + # name: gateway-ngf + # namespace: kube-system + parentRef: {} + listenerName: https + port: 443 + # cert-manager reads these (cert-manager.io/cluster-issuer or + # cert-manager.io/issuer) and issues the certificate into tlsSecretName. + annotations: {} + # TLS Secret in the release namespace. Defaults to -tls. + # Set it to codetogether-tls to keep the certificate the Ingress used. + tlsSecretName: "" + +# # CodeTogether has a dashboard to view metrics, and for the locator, update # configuration on the fly. If a custom username and password is not enabled, # one will be dynamically generated and shared in the log when the server