From ed7db0d44cc431585f73cc07f2168bafe3f6000c Mon Sep 17 00:00:00 2001 From: Rory Z <16801068+Rory-Z@users.noreply.github.com> Date: Thu, 9 Apr 2026 10:53:29 +0000 Subject: [PATCH 1/2] docs: add design spec for postgres/redis/prometheus protocol support --- ...4-09-datalayers-protocol-support-design.md | 165 ++++++++++++++++++ 1 file changed, 165 insertions(+) create mode 100644 docs/superpowers/specs/2026-04-09-datalayers-protocol-support-design.md diff --git a/docs/superpowers/specs/2026-04-09-datalayers-protocol-support-design.md b/docs/superpowers/specs/2026-04-09-datalayers-protocol-support-design.md new file mode 100644 index 0000000..0058c14 --- /dev/null +++ b/docs/superpowers/specs/2026-04-09-datalayers-protocol-support-design.md @@ -0,0 +1,165 @@ +# Design: PostgreSQL / Redis / Prometheus Protocol Support for datalayers-single + +**Date:** 2026-04-09 +**Chart:** datalayers-single (v0.0.1-alpha.9, appVersion v2.4.0) +**Reference:** https://docs.datalayers.cn/datalayers/latest/development-guide/connection.html + +## Summary + +Add optional PostgreSQL, Redis, and Prometheus protocol support to the datalayers-single Helm chart. Each protocol is toggled by an `enabled` flag under `service.*` in values.yaml. When enabled, the chart injects the appropriate Datalayers environment variable, exposes the container port, and adds a Service port. + +## Background + +Datalayers supports six protocols. Two are always on (gRPC/FlightSQL on 8360, HTTP/REST on 8361). Three are disabled by default and activated by setting their `addr` configuration: + +| Protocol | Default Port | Env Var to Enable | +|------------|-------------|------------------------------------------| +| PostgreSQL | 5432 | `DATALAYERS_SERVER__POSTGRES__ADDR` | +| Redis | 6379 | `DATALAYERS_SERVER__REDIS__ADDR` | +| Prometheus | 9090 | `DATALAYERS_SERVER__PROMETHEUS__ADDR` | + +Redis also requires `USERNAME` and `PASSWORD` env vars when enabled. +Prometheus has optional `memtable_size` and `ttl` params (kept at Datalayers defaults; configurable via `datalayersConfig` TOML if needed). + +## Design + +### values.yaml + +Add three blocks under `service`, all disabled by default: + +```yaml +service: + type: ClusterIP + grpc: + port: 8360 + http: + port: 8361 + postgres: + enabled: false + port: 5432 + redis: + enabled: false + port: 6379 + prometheus: + enabled: false + port: 9090 +``` + +### templates/statefulset.yaml + +#### Container ports + +Append conditional ports after the existing `grpc` and `http` ports: + +```yaml +{{- if .Values.service.postgres.enabled }} +- name: postgres + containerPort: 5432 + protocol: TCP +{{- end }} +{{- if .Values.service.redis.enabled }} +- name: redis + containerPort: 6379 + protocol: TCP +{{- end }} +{{- if .Values.service.prometheus.enabled }} +- name: prometheus + containerPort: 9090 + protocol: TCP +{{- end }} +``` + +#### Environment variables + +Inject `ADDR` env vars when each protocol is enabled. Place these after the existing auth env vars block: + +```yaml +{{- if $.Values.service.postgres.enabled }} +- name: DATALAYERS_SERVER__POSTGRES__ADDR + value: "0.0.0.0:5432" +{{- end }} +{{- if $.Values.service.redis.enabled }} +- name: DATALAYERS_SERVER__REDIS__ADDR + value: "0.0.0.0:6379" +- name: DATALAYERS_SERVER__REDIS__USERNAME + valueFrom: + secretKeyRef: + name: {{ include "datalayers-single.authSecretName" $ }} + key: {{ $.Values.auth.static.secretKeys.username }} +- name: DATALAYERS_SERVER__REDIS__PASSWORD + valueFrom: + secretKeyRef: + name: {{ include "datalayers-single.authSecretName" $ }} + key: {{ $.Values.auth.static.secretKeys.password }} +{{- end }} +{{- if $.Values.service.prometheus.enabled }} +- name: DATALAYERS_SERVER__PROMETHEUS__ADDR + value: "0.0.0.0:9090" +{{- end }} +``` + +Redis credentials reuse the existing auth secret (`datalayers-single.authSecretName`). + +### templates/service.yaml + +Append conditional ports after existing `grpc` and `http` ports: + +```yaml +{{- if .Values.service.postgres.enabled }} +- port: {{ .Values.service.postgres.port }} + targetPort: postgres + protocol: TCP + name: postgres +{{- end }} +{{- if .Values.service.redis.enabled }} +- port: {{ .Values.service.redis.port }} + targetPort: redis + protocol: TCP + name: redis +{{- end }} +{{- if .Values.service.prometheus.enabled }} +- port: {{ .Values.service.prometheus.port }} + targetPort: prometheus + protocol: TCP + name: prometheus +{{- end }} +``` + +### templates/NOTES.txt + +Add conditional lines showing enabled protocol ports and include them in the port-forward command: + +``` +{{- if .Values.service.postgres.enabled }} + - PostgreSQL: {{ .Values.service.postgres.port }} +{{- end }} +{{- if .Values.service.redis.enabled }} + - Redis: {{ .Values.service.redis.port }} +{{- end }} +{{- if .Values.service.prometheus.enabled }} + - Prometheus: {{ .Values.service.prometheus.port }} +{{- end }} +``` + +### Files changed + +| File | Change | +|------|--------| +| `values.yaml` | Add `service.postgres/redis/prometheus` blocks | +| `templates/statefulset.yaml` | Conditional containerPorts + env vars | +| `templates/service.yaml` | Conditional Service ports | +| `templates/NOTES.txt` | Conditional port info + port-forward args | + +### Files not changed + +- `_helpers.tpl` — no new helpers needed +- `secret.yaml` — Redis reuses existing auth secret +- `configmap.yaml` — no config changes +- `ingress.yaml` / `httproute.yaml` — TCP protocols, not HTTP routing + +## Testing + +- `helm template` with all protocols disabled (default) — output unchanged +- `helm template` with each protocol enabled individually — verify correct ports and env vars +- `helm template` with all three enabled — verify all ports and env vars present +- `helm lint` passes From 8e013fec5edac8675f7c945bddf9d05faa30a7ab Mon Sep 17 00:00:00 2001 From: Rory Z <16801068+Rory-Z@users.noreply.github.com> Date: Thu, 9 Apr 2026 11:02:59 +0000 Subject: [PATCH 2/2] feat(datalayers-single): add postgres, redis, prometheus protocol support Add optional protocol support toggled via service.{postgres,redis,prometheus}.enabled in values.yaml. When enabled, the chart injects the corresponding DATALAYERS_SERVER__*__ADDR env var, exposes the container port, and adds a Service port. - PostgreSQL (5432): enabled via DATALAYERS_SERVER__POSTGRES__ADDR - Redis (6379): enabled via DATALAYERS_SERVER__REDIS__ADDR, reuses auth secret for credentials - Prometheus (9090): enabled via DATALAYERS_SERVER__PROMETHEUS__ADDR All three are disabled by default, matching Datalayers upstream defaults. --- datalayers-single/templates/NOTES.txt | 20 ++++++++++- datalayers-single/templates/service.yaml | 18 ++++++++++ datalayers-single/templates/statefulset.yaml | 37 ++++++++++++++++++++ datalayers-single/values.yaml | 9 +++++ 4 files changed, 83 insertions(+), 1 deletion(-) diff --git a/datalayers-single/templates/NOTES.txt b/datalayers-single/templates/NOTES.txt index dede89e..1c2e5c9 100644 --- a/datalayers-single/templates/NOTES.txt +++ b/datalayers-single/templates/NOTES.txt @@ -3,10 +3,28 @@ Datalayers has been deployed in standalone mode. Service ports: - gRPC (FlightSQL): {{ .Values.service.grpc.port }} - HTTP API: {{ .Values.service.http.port }} +{{- if .Values.service.postgres.enabled }} + - PostgreSQL: {{ .Values.service.postgres.port }} +{{- end }} +{{- if .Values.service.redis.enabled }} + - Redis: {{ .Values.service.redis.port }} +{{- end }} +{{- if .Values.service.prometheus.enabled }} + - Prometheus: {{ .Values.service.prometheus.port }} +{{- end }} To connect from within the cluster: gRPC: {{ include "datalayers-single.fullname" . }}:{{ .Values.service.grpc.port }} HTTP: {{ include "datalayers-single.fullname" . }}:{{ .Values.service.http.port }} +{{- if .Values.service.postgres.enabled }} + PostgreSQL: {{ include "datalayers-single.fullname" . }}:{{ .Values.service.postgres.port }} +{{- end }} +{{- if .Values.service.redis.enabled }} + Redis: {{ include "datalayers-single.fullname" . }}:{{ .Values.service.redis.port }} +{{- end }} +{{- if .Values.service.prometheus.enabled }} + Prometheus: {{ include "datalayers-single.fullname" . }}:{{ .Values.service.prometheus.port }} +{{- end }} To port-forward for local access: - kubectl --namespace {{ .Release.Namespace }} port-forward svc/{{ include "datalayers-single.fullname" . }} {{ .Values.service.grpc.port }}:{{ .Values.service.grpc.port }} {{ .Values.service.http.port }}:{{ .Values.service.http.port }} + kubectl --namespace {{ .Release.Namespace }} port-forward svc/{{ include "datalayers-single.fullname" . }} {{ .Values.service.grpc.port }}:{{ .Values.service.grpc.port }} {{ .Values.service.http.port }}:{{ .Values.service.http.port }}{{ if .Values.service.postgres.enabled }} {{ .Values.service.postgres.port }}:{{ .Values.service.postgres.port }}{{ end }}{{ if .Values.service.redis.enabled }} {{ .Values.service.redis.port }}:{{ .Values.service.redis.port }}{{ end }}{{ if .Values.service.prometheus.enabled }} {{ .Values.service.prometheus.port }}:{{ .Values.service.prometheus.port }}{{ end }} diff --git a/datalayers-single/templates/service.yaml b/datalayers-single/templates/service.yaml index 51762b9..401d37b 100644 --- a/datalayers-single/templates/service.yaml +++ b/datalayers-single/templates/service.yaml @@ -15,5 +15,23 @@ spec: targetPort: http protocol: TCP name: http + {{- if .Values.service.postgres.enabled }} + - port: {{ .Values.service.postgres.port }} + targetPort: postgres + protocol: TCP + name: postgres + {{- end }} + {{- if .Values.service.redis.enabled }} + - port: {{ .Values.service.redis.port }} + targetPort: redis + protocol: TCP + name: redis + {{- end }} + {{- if .Values.service.prometheus.enabled }} + - port: {{ .Values.service.prometheus.port }} + targetPort: prometheus + protocol: TCP + name: prometheus + {{- end }} selector: {{- include "datalayers-single.selectorLabels" . | nindent 4 }} diff --git a/datalayers-single/templates/statefulset.yaml b/datalayers-single/templates/statefulset.yaml index 3014132..9a52166 100644 --- a/datalayers-single/templates/statefulset.yaml +++ b/datalayers-single/templates/statefulset.yaml @@ -68,6 +68,28 @@ spec: name: {{ include "datalayers-single.authSecretName" $ }} key: {{ $.Values.auth.static.secretKeys.password }} {{- end }} + {{- if $.Values.service.postgres.enabled }} + - name: DATALAYERS_SERVER__POSTGRES__ADDR + value: "0.0.0.0:5432" + {{- end }} + {{- if $.Values.service.redis.enabled }} + - name: DATALAYERS_SERVER__REDIS__ADDR + value: "0.0.0.0:6379" + - name: DATALAYERS_SERVER__REDIS__USERNAME + valueFrom: + secretKeyRef: + name: {{ include "datalayers-single.authSecretName" $ }} + key: {{ $.Values.auth.static.secretKeys.username }} + - name: DATALAYERS_SERVER__REDIS__PASSWORD + valueFrom: + secretKeyRef: + name: {{ include "datalayers-single.authSecretName" $ }} + key: {{ $.Values.auth.static.secretKeys.password }} + {{- end }} + {{- if $.Values.service.prometheus.enabled }} + - name: DATALAYERS_SERVER__PROMETHEUS__ADDR + value: "0.0.0.0:9090" + {{- end }} {{- end }} ports: - name: grpc @@ -76,6 +98,21 @@ spec: - name: http containerPort: 8361 protocol: TCP + {{- if .Values.service.postgres.enabled }} + - name: postgres + containerPort: 5432 + protocol: TCP + {{- end }} + {{- if .Values.service.redis.enabled }} + - name: redis + containerPort: 6379 + protocol: TCP + {{- end }} + {{- if .Values.service.prometheus.enabled }} + - name: prometheus + containerPort: 9090 + protocol: TCP + {{- end }} {{- with .Values.livenessProbe }} livenessProbe: {{- toYaml . | nindent 12 }} diff --git a/datalayers-single/values.yaml b/datalayers-single/values.yaml index 3e40049..8d9d732 100644 --- a/datalayers-single/values.yaml +++ b/datalayers-single/values.yaml @@ -53,6 +53,15 @@ service: port: 8360 http: port: 8361 + postgres: + enabled: false + port: 5432 + redis: + enabled: false + port: 6379 + prometheus: + enabled: false + port: 9090 ingress: enabled: false