From 9bf83e0e87752396019ba29ac4d397f36d7627ec Mon Sep 17 00:00:00 2001 From: Danny5487401 <64348131+Danny5487401@users.noreply.github.com> Date: Sun, 11 Oct 2026 22:30:27 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix(helm):=20=E4=BD=BF=E7=94=A8=E5=AE=8C?= =?UTF-8?q?=E6=95=B4=E6=9C=8D=E5=8A=A1=E5=9F=9F=E5=90=8D=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=20Web=20=E4=B8=8A=E6=B8=B8=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Danny5487401 <64348131+Danny5487401@users.noreply.github.com> --- charts/skillhub/templates/web-deployment.yaml | 2 +- .../skillhub/tests/configuration-contracts.sh | 39 +++++++++++++++++++ charts/skillhub/values.schema.json | 6 +++ charts/skillhub/values.yaml | 3 ++ 4 files changed, 49 insertions(+), 1 deletion(-) diff --git a/charts/skillhub/templates/web-deployment.yaml b/charts/skillhub/templates/web-deployment.yaml index 7ad2e403..88366122 100644 --- a/charts/skillhub/templates/web-deployment.yaml +++ b/charts/skillhub/templates/web-deployment.yaml @@ -32,7 +32,7 @@ spec: imagePullPolicy: {{ .Values.images.pullPolicy }} env: - name: SKILLHUB_API_UPSTREAM - value: http://{{ include "skillhub.fullname" . }}-server:{{ .Values.server.service.port }} + value: {{ printf "http://%s-server.%s.svc.%s:%v" (include "skillhub.fullname" .) .Release.Namespace .Values.web.clusterDomain .Values.server.service.port | quote }} - name: SKILLHUB_PUBLIC_BASE_URL valueFrom: configMapKeyRef: diff --git a/charts/skillhub/tests/configuration-contracts.sh b/charts/skillhub/tests/configuration-contracts.sh index b1dfbbd3..c026eb93 100755 --- a/charts/skillhub/tests/configuration-contracts.sh +++ b/charts/skillhub/tests/configuration-contracts.sh @@ -23,6 +23,45 @@ assert_rejected() { fi } +assert_web_upstream() { + local manifest=$1 + local expected=$2 + [[ $(grep -Fc 'name: SKILLHUB_API_UPSTREAM' "$manifest") -eq 1 ]] \ + || fail "Web must render exactly one built-in API upstream" + grep -A1 -F 'name: SKILLHUB_API_UPSTREAM' "$manifest" \ + | grep -Fq "value: \"$expected\"" \ + || fail "Web runtime DNS upstream must be $expected" +} + +# Nginx runtime DNS resolution does not expand the pod's search suffixes. +render web-dns "$CHART_DIR" --namespace default \ + --show-only templates/web-deployment.yaml >"$TMP_DIR/web-dns.yaml" +assert_web_upstream "$TMP_DIR/web-dns.yaml" \ + 'http://web-dns-skillhub-server.default.svc.cluster.local:8080' + +render skillhub "$CHART_DIR" --namespace team-skills \ + --show-only templates/web-deployment.yaml >"$TMP_DIR/web-dns-namespace.yaml" +assert_web_upstream "$TMP_DIR/web-dns-namespace.yaml" \ + 'http://skillhub-server.team-skills.svc.cluster.local:8080' + +render web-dns "$CHART_DIR" --namespace team-skills \ + --set nameOverride=registry \ + --show-only templates/web-deployment.yaml >"$TMP_DIR/web-dns-name.yaml" +assert_web_upstream "$TMP_DIR/web-dns-name.yaml" \ + 'http://web-dns-registry-server.team-skills.svc.cluster.local:8080' + +render web-dns "$CHART_DIR" --namespace team-skills \ + --set fullnameOverride=custom-hub --set server.service.port=9080 \ + --set web.clusterDomain=k8s.example.internal \ + --show-only templates/web-deployment.yaml >"$TMP_DIR/web-dns-custom.yaml" +assert_web_upstream "$TMP_DIR/web-dns-custom.yaml" \ + 'http://custom-hub-server.team-skills.svc.k8s.example.internal:9080' + +assert_rejected web-dns-empty-domain --set-string web.clusterDomain= +assert_rejected web-dns-url-domain --set-string web.clusterDomain=https://cluster.local +assert_rejected web-dns-empty-label --set-string web.clusterDomain=cluster..local +assert_rejected web-dns-invalid-label --set-string web.clusterDomain=-cluster.local + render verify "$CHART_DIR" >"$TMP_DIR/default.yaml" grep -Fq 'name: POSTGRESQL_MAX_CONNECTIONS' "$TMP_DIR/default.yaml" grep -Fq 'value: "verify-postgresql"' "$TMP_DIR/default.yaml" diff --git a/charts/skillhub/values.schema.json b/charts/skillhub/values.schema.json index f6856dbc..24431eb6 100644 --- a/charts/skillhub/values.schema.json +++ b/charts/skillhub/values.schema.json @@ -482,6 +482,12 @@ "required": ["replicaCount", "image", "service", "resources", "extraEnv", "podAnnotations", "imagePullSecrets", "nodeSelector", "tolerations", "affinity", "probes", "autoscaling", "podDisruptionBudget"], "properties": { "replicaCount": { "type": "integer", "minimum": 1 }, + "clusterDomain": { + "type": "string", + "minLength": 1, + "maxLength": 253, + "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?(\\.[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$" + }, "image": { "$ref": "#/definitions/image" }, "service": { "$ref": "#/definitions/service" }, "basePath": { "type": "string", "pattern": "^$|^/$|^(/[A-Za-z0-9_~-][A-Za-z0-9._~-]*)+/$" }, diff --git a/charts/skillhub/values.yaml b/charts/skillhub/values.yaml index e3efdf1e..6137a439 100644 --- a/charts/skillhub/values.yaml +++ b/charts/skillhub/values.yaml @@ -391,6 +391,9 @@ server: # ============================================================================ web: replicaCount: 1 + # Nginx resolves the API upstream at runtime without pod DNS search suffixes. + # Set the cluster DNS domain here instead of duplicating SKILLHUB_API_UPSTREAM in extraEnv. + clusterDomain: cluster.local image: registry: "" tag: "" From 15332a98499cadebbcfcdbfa1ae0f8d9addea8d1 Mon Sep 17 00:00:00 2001 From: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com> Date: Thu, 15 Oct 2026 11:07:50 +0800 Subject: [PATCH 2/2] fix(deploy): default cluster domain for reused Helm values Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com> --- charts/skillhub/templates/web-deployment.yaml | 2 +- charts/skillhub/tests/configuration-contracts.sh | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/charts/skillhub/templates/web-deployment.yaml b/charts/skillhub/templates/web-deployment.yaml index 88366122..b92a5ef4 100644 --- a/charts/skillhub/templates/web-deployment.yaml +++ b/charts/skillhub/templates/web-deployment.yaml @@ -32,7 +32,7 @@ spec: imagePullPolicy: {{ .Values.images.pullPolicy }} env: - name: SKILLHUB_API_UPSTREAM - value: {{ printf "http://%s-server.%s.svc.%s:%v" (include "skillhub.fullname" .) .Release.Namespace .Values.web.clusterDomain .Values.server.service.port | quote }} + value: {{ printf "http://%s-server.%s.svc.%s:%v" (include "skillhub.fullname" .) .Release.Namespace (.Values.web.clusterDomain | default "cluster.local") .Values.server.service.port | quote }} - name: SKILLHUB_PUBLIC_BASE_URL valueFrom: configMapKeyRef: diff --git a/charts/skillhub/tests/configuration-contracts.sh b/charts/skillhub/tests/configuration-contracts.sh index c026eb93..4297cf66 100755 --- a/charts/skillhub/tests/configuration-contracts.sh +++ b/charts/skillhub/tests/configuration-contracts.sh @@ -57,6 +57,18 @@ render web-dns "$CHART_DIR" --namespace team-skills \ assert_web_upstream "$TMP_DIR/web-dns-custom.yaml" \ 'http://custom-hub-server.team-skills.svc.k8s.example.internal:9080' +# --reuse-values can supply old chart defaults without this newly added key. +# Model that effective values shape here; a real cross-version upgrade is a +# separate integration check, not a second render of this chart's new defaults. +LEGACY_VALUES_CHART="$TMP_DIR/legacy-values-chart" +cp -R "$CHART_DIR" "$LEGACY_VALUES_CHART" +sed '/^ clusterDomain:/d' "$CHART_DIR/values.yaml" >"$LEGACY_VALUES_CHART/values.yaml" +render web-dns "$LEGACY_VALUES_CHART" --namespace team-skills \ + --set fullnameOverride=custom-hub --set server.service.port=9080 \ + --show-only templates/web-deployment.yaml >"$TMP_DIR/web-dns-legacy-values.yaml" +assert_web_upstream "$TMP_DIR/web-dns-legacy-values.yaml" \ + 'http://custom-hub-server.team-skills.svc.cluster.local:9080' + assert_rejected web-dns-empty-domain --set-string web.clusterDomain= assert_rejected web-dns-url-domain --set-string web.clusterDomain=https://cluster.local assert_rejected web-dns-empty-label --set-string web.clusterDomain=cluster..local