cloudnative-pg / cloudnative-pg/charts

[Feature Request] Optional support for Gateway API TCPRoute in the cluster chart

Open
#974 0 comments 0 reactions 0 assignees View on GitHub
chart( cluster )
Dominant language
Go Template
Stars
621
Forks
265
Avg merge
7d 12h
Merged PRs (30d)
7

Description

#### Context
When exposing a CloudNativePG database outside the Kubernetes cluster using a Gateway API controller (such as Envoy Gateway, Cilium, Istio, etc.), users currently need to deploy `TCPRoute` resources separately via raw manifests or an external chart.

Maybing adding optional support for Gateway API `TCPRoute` resources directly within the `cluster` Helm chart can be an option ?
with flexible targeting for:
- Direct cluster services (`rw`, `ro`, `r`)
- Connection Pooler services
- Both simultaneously

#### Prerequisites / CRDs Constraint
Since `TCPRoute` depends on Gateway API CRDs `gateway.networking.k8s.io`, this resource should remain **disabled by default** assuming the target cluster already has the CRDs installed.

I am opening this issue to gather feedback on whether this feature aligns with the scope of this chart, or if you prefer keeping external routing resources managed outside of it.

#### Potential Draft

**`templates/tcproute.yaml`**
```yaml
{{- if .Values.tcpRoute.create }}
{{- $fullName := include "cluster.fullname" . -}}
{{- $port := .Values.port | default 5432 -}}

{{/* 1. TCPRoute for Direct Cluster Access */}}
{{- if or (eq .Values.tcpRoute.target "cluster") (eq .Values.tcpRoute.target "both") }}
apiVersion: gateway.networking.k8s.io/v1alpha2
kind: TCPRoute
metadata:
name: {{ $fullName }}-cluster
labels:
{{- include "cluster.labels" . | nindent 4 }}
{{- with .Values.tcpRoute.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
parentRefs:
{{- toYaml .Values.tcpRoute.parentRefs | nindent 4 }}
rules:
- backendRefs:
- name: {{ $fullName }}-{{ .Values.tcpRoute.clusterServiceType | default "rw" }}
port: {{ $port }}
{{- end }}

{{- if eq .Values.tcpRoute.target "both" }}
---
{{- end }}

{{/* 2. TCPRoute for Pooler Access */}}
{{- if or (eq .Values.tcpRoute.target "pooler") (eq .Values.tcpRoute.target "both") }}
{{- $poolerTarget := .Values.tcpRoute.poolerName \vert{} default$fullName -}}
apiVersion: gateway.networking.k8s.io/v1alpha2
kind: TCPRoute
metadata:
name: {{ $fullName }}-pooler
labels:
{{- include "cluster.labels" . | nindent 4 }}
{{- with .Values.tcpRoute.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
parentRefs:
{{- toYaml .Values.tcpRoute.parentRefs | nindent 4 }}
rules:
- backendRefs:
- name: {{ $poolerTarget }}
port: {{ $port }}
{{- end }}
{{- end }}
```

**`values.yaml` additions**
```yaml
tcpRoute:
create: false
annotations: {}
parentRefs: []
# - name: my-gateway
# namespace: gateway-system
# sectionName: pg-port

# Target mode: "cluster", "pooler", or "both"
target: "cluster"

# When targeting cluster (or both)
clusterServiceType: "rw" # "rw", "ro", or "r"

# Optional pooler name override if target is "pooler" or "both"
poolerName: "" # Default to cluster name or dedicated pooler name if configured

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the proposed templates/tcproute.yaml and values.yaml additions, then inspect the existing cluster chart conventions for services and rendered resources. Verify the optional configuration covers cluster, pooler, and both targets while remaining disabled by default; done means the chart renders valid TCPRoute resources when enabled without requiring them otherwise.

Written by the indexing model from the issue text.

Assessment

Tech stack
helm, kubernetes
Domain
devops, infrastructure
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.