From c6bfe81894be411c910ad573bd1c80d88452414b Mon Sep 17 00:00:00 2001 From: Perfecto Date: Mon, 12 Oct 2026 11:53:32 +0800 Subject: [PATCH] feat(helm): allow Service name overrides with matching consumer references (#4109) * feat(helm): support compatible service name overrides * refactor(helm): keep verification within existing chart workflow * docs(helm): focus service naming guidance on configuration and upgrades --- helm/README.md | 37 +++++++++++++++++++++++++++++++++++ helm/templates/NOTES.txt | 4 ++-- helm/templates/_helpers.tpl | 13 ++++++++++++ helm/templates/app.yaml | 11 +++++------ helm/templates/docreader.yaml | 3 +-- helm/templates/frontend.yaml | 5 ++--- helm/templates/ingress.yaml | 4 ++-- helm/templates/neo4j.yaml | 3 +-- helm/templates/postgres.yaml | 3 +-- helm/templates/redis.yaml | 3 +-- helm/values.yaml | 18 +++++++++++++++++ 11 files changed, 83 insertions(+), 21 deletions(-) diff --git a/helm/README.md b/helm/README.md index 16b17f14..035ffcdf 100644 --- a/helm/README.md +++ b/helm/README.md @@ -142,6 +142,43 @@ helm install weknora ./helm \ ## Configuration +### Service names + +Optional Service name overrides preserve the following defaults: + +| Parameter | Default when omitted or empty | +|-----------|-------------------------------| +| `app.service.name` | `app` | +| `frontend.service.name` | `frontend` | +| `postgresql.service.name` | `postgres` | +| `redis.service.name` | `redis` | +| `docreader.service.name` | `docreader` | +| `neo4j.service.name` | `neo4j` (when enabled) | + +For example, save this as `service-names.yaml`: + +```yaml +app: {service: {name: weknora-app}} +frontend: {service: {name: weknora-frontend}} +postgresql: {service: {name: weknora-postgres}} +redis: {service: {name: weknora-redis}} +docreader: {service: {name: weknora-docreader}} +neo4j: {service: {name: weknora-neo4j}} +``` + +Pass `-f service-names.yaml` alongside your other values. Names must be valid +Kubernetes Service names. Services, backend addresses, Ingress and installation +notes use these names consistently. Frontend's `APP_HOST` follows the App Service +unless `frontend.appHost` is explicitly set. + +For multiple releases in one namespace, use distinct names for every enabled +Service (for example, `alpha-app` and `beta-app`). Defaults are not release-prefixed +and still collide. Configure separate Ingress hosts when needed. + +Omitted or empty overrides preserve Service names on upgrade. Changing a name on +an existing installation requires a DNS/consumer cutover plan; matching a +pre-existing Service name does not automatically transfer its ownership to Helm. + ### Global Parameters | Parameter | Description | Default | diff --git a/helm/templates/NOTES.txt b/helm/templates/NOTES.txt index dfbab9ad..e4e16db2 100644 --- a/helm/templates/NOTES.txt +++ b/helm/templates/NOTES.txt @@ -28,7 +28,7 @@ WeKnora is accessible via Ingress: To access WeKnora, use port-forwarding: # Frontend (Web UI) - kubectl port-forward svc/frontend -n {{ .Release.Namespace }} 8080:80 + kubectl port-forward svc/{{ include "weknora.serviceName" (dict "component" "frontend" "context" .) }} -n {{ .Release.Namespace }} 8080:80 # Then open: http://localhost:8080 @@ -113,7 +113,7 @@ which is deprecated and no longer read by the app): --set neo4j.password= Access Neo4j Browser: - kubectl port-forward svc/neo4j -n {{ .Release.Namespace }} 7474:7474 7687:7687 + kubectl port-forward svc/{{ include "weknora.serviceName" (dict "component" "neo4j" "context" .) }} -n {{ .Release.Namespace }} 7474:7474 7687:7687 # Open: http://localhost:7474 {{- end }} diff --git a/helm/templates/_helpers.tpl b/helm/templates/_helpers.tpl index 9ed75eae..8973b154 100644 --- a/helm/templates/_helpers.tpl +++ b/helm/templates/_helpers.tpl @@ -32,6 +32,19 @@ Create a default fully qualified app name. {{- end }} {{- end }} +{{/* +Resolve a component Service name while preserving names used by existing releases. +Usage: include "weknora.serviceName" (dict "component" "postgresql" "context" .) +*/}} +{{- define "weknora.serviceName" -}} +{{- $service := (index .context.Values .component).service | default dict -}} +{{- $legacyName := .component -}} +{{- if eq .component "postgresql" -}} +{{- $legacyName = "postgres" -}} +{{- end -}} +{{- default $legacyName $service.name -}} +{{- end -}} + {{/* Create chart name and version as used by the chart label. Ref: https://helm.sh/docs/chart_best_practices/labels/ diff --git a/helm/templates/app.yaml b/helm/templates/app.yaml index 9b79ca83..b7b705bc 100644 --- a/helm/templates/app.yaml +++ b/helm/templates/app.yaml @@ -57,7 +57,7 @@ spec: - name: DB_DRIVER value: "postgres" - name: DB_HOST - value: "postgres" + value: {{ include "weknora.serviceName" (dict "component" "postgresql" "context" .) | quote }} - name: DB_PORT value: "5432" - name: DB_USER @@ -77,7 +77,7 @@ spec: key: DB_NAME # Redis configuration - name: REDIS_ADDR - value: "redis:6379" + value: {{ printf "%s:6379" (include "weknora.serviceName" (dict "component" "redis" "context" .)) | quote }} - name: REDIS_USERNAME valueFrom: secretKeyRef: @@ -115,7 +115,7 @@ spec: value: {{ .Values.app.env.LOCAL_STORAGE_BASE_DIR | quote }} # Document reader - name: DOCREADER_ADDR - value: "docreader:50051" + value: {{ printf "%s:50051" (include "weknora.serviceName" (dict "component" "docreader" "context" .)) | quote }} # Processing - name: AUTO_RECOVER_DIRTY value: {{ .Values.app.env.AUTO_RECOVER_DIRTY | quote }} @@ -133,7 +133,7 @@ spec: - name: NEO4J_ENABLE value: "true" - name: NEO4J_URI - value: "bolt://neo4j:7687" + value: {{ printf "bolt://%s:7687" (include "weknora.serviceName" (dict "component" "neo4j" "context" .)) | quote }} - name: NEO4J_USERNAME valueFrom: secretKeyRef: @@ -186,8 +186,7 @@ spec: apiVersion: v1 kind: Service metadata: - # Service name must be "app" - frontend nginx config hardcodes this - name: app + name: {{ include "weknora.serviceName" (dict "component" "app" "context" .) | quote }} namespace: {{ .Release.Namespace }} labels: {{- include "weknora.componentLabels" (dict "component" "app" "context" .) | nindent 4 }} diff --git a/helm/templates/docreader.yaml b/helm/templates/docreader.yaml index 7d2385ca..1029fd65 100644 --- a/helm/templates/docreader.yaml +++ b/helm/templates/docreader.yaml @@ -87,8 +87,7 @@ spec: apiVersion: v1 kind: Service metadata: - # Service name must be "docreader" - app references this - name: docreader + name: {{ include "weknora.serviceName" (dict "component" "docreader" "context" .) | quote }} namespace: {{ .Release.Namespace }} labels: {{- include "weknora.componentLabels" (dict "component" "docreader" "context" .) | nindent 4 }} diff --git a/helm/templates/frontend.yaml b/helm/templates/frontend.yaml index dd43be08..77f52d2f 100644 --- a/helm/templates/frontend.yaml +++ b/helm/templates/frontend.yaml @@ -43,7 +43,7 @@ spec: {{- end }} env: - name: APP_HOST - value: {{ .Values.frontend.appHost | default "app" | quote }} + value: {{ .Values.frontend.appHost | default (include "weknora.serviceName" (dict "component" "app" "context" .)) | quote }} - name: APP_PORT value: {{ .Values.frontend.appPort | default .Values.app.service.port | quote }} - name: MAX_FILE_SIZE_MB @@ -97,8 +97,7 @@ spec: apiVersion: v1 kind: Service metadata: - # Service name must be "frontend" - ingress references this - name: frontend + name: {{ include "weknora.serviceName" (dict "component" "frontend" "context" .) | quote }} namespace: {{ .Release.Namespace }} labels: {{- include "weknora.componentLabels" (dict "component" "frontend" "context" .) | nindent 4 }} diff --git a/helm/templates/ingress.yaml b/helm/templates/ingress.yaml index 7b491a3e..a22a3267 100644 --- a/helm/templates/ingress.yaml +++ b/helm/templates/ingress.yaml @@ -38,7 +38,7 @@ spec: pathType: Prefix backend: service: - name: app + name: {{ include "weknora.serviceName" (dict "component" "app" "context" .) | quote }} port: name: http # Frontend routes - catch-all @@ -46,7 +46,7 @@ spec: pathType: Prefix backend: service: - name: frontend + name: {{ include "weknora.serviceName" (dict "component" "frontend" "context" .) | quote }} port: name: http {{- end }} diff --git a/helm/templates/neo4j.yaml b/helm/templates/neo4j.yaml index 935b6769..cb5efef5 100644 --- a/helm/templates/neo4j.yaml +++ b/helm/templates/neo4j.yaml @@ -115,8 +115,7 @@ spec: apiVersion: v1 kind: Service metadata: - # Service name must be "neo4j" - app references this - name: neo4j + name: {{ include "weknora.serviceName" (dict "component" "neo4j" "context" .) | quote }} namespace: {{ .Release.Namespace }} labels: {{- include "weknora.componentLabels" (dict "component" "graph" "context" .) | nindent 4 }} diff --git a/helm/templates/postgres.yaml b/helm/templates/postgres.yaml index fbc3674f..f8c04fd7 100644 --- a/helm/templates/postgres.yaml +++ b/helm/templates/postgres.yaml @@ -111,8 +111,7 @@ spec: apiVersion: v1 kind: Service metadata: - # Service name must be "postgres" - app references this - name: postgres + name: {{ include "weknora.serviceName" (dict "component" "postgresql" "context" .) | quote }} namespace: {{ .Release.Namespace }} labels: {{- include "weknora.componentLabels" (dict "component" "database" "context" .) | nindent 4 }} diff --git a/helm/templates/redis.yaml b/helm/templates/redis.yaml index e64f243e..b5a00345 100644 --- a/helm/templates/redis.yaml +++ b/helm/templates/redis.yaml @@ -107,8 +107,7 @@ spec: apiVersion: v1 kind: Service metadata: - # Service name must be "redis" - app references this - name: redis + name: {{ include "weknora.serviceName" (dict "component" "redis" "context" .) | quote }} namespace: {{ .Release.Namespace }} labels: {{- include "weknora.componentLabels" (dict "component" "cache" "context" .) | nindent 4 }} diff --git a/helm/values.yaml b/helm/values.yaml index 71583ecc..7f1cae7c 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -114,6 +114,8 @@ app: # -- Service configuration service: + # -- Service name override (empty keeps "app") + name: "" type: ClusterIP port: 8080 @@ -181,6 +183,8 @@ frontend: # -- Service configuration service: + # -- Service name override (empty keeps "frontend") + name: "" type: ClusterIP port: 80 @@ -231,6 +235,8 @@ docreader: # -- Service configuration service: + # -- Service name override (empty keeps "docreader") + name: "" type: ClusterIP port: 50051 @@ -250,6 +256,10 @@ postgresql: # -- Enable PostgreSQL enabled: true + service: + # -- Service name override (empty keeps "postgres") + name: "" + image: # -- Image repository (ParadeDB for vector search) repository: paradedb/paradedb @@ -296,6 +306,10 @@ redis: # -- Enable Redis enabled: true + service: + # -- Service name override (empty keeps "redis") + name: "" + image: # -- Image repository repository: redis @@ -446,6 +460,10 @@ neo4j: # -- Enable Neo4j for GraphRAG enabled: false + service: + # -- Service name override (empty keeps "neo4j") + name: "" + image: # -- Image repository repository: neo4j