From aa3100357322995b201d5348c5490596a7bd70a9 Mon Sep 17 00:00:00 2001 From: iwannagotobed Date: Fri, 14 Aug 2026 18:47:42 +0900 Subject: [PATCH] [Bugfix][Helm] Fix chart resource references (#51664) Signed-off-by: iwannagotobed Co-authored-by: Chauncey --- examples/deployment/chart-helm/Chart.yaml | 2 +- .../chart-helm/templates/_helpers.tpl | 11 ++++++-- .../chart-helm/templates/deployment.yaml | 12 ++++----- .../deployment/chart-helm/templates/hpa.yaml | 4 +-- .../chart-helm/templates/service.yaml | 4 +-- .../chart-helm/tests/deployment_test.yaml | 19 +++++++++++++- .../deployment/chart-helm/tests/hpa_test.yaml | 17 +++++++++++++ .../chart-helm/tests/service_test.yaml | 25 +++++++++++++++++++ .../deployment/chart-helm/values.schema.json | 7 ++++-- 9 files changed, 84 insertions(+), 17 deletions(-) create mode 100644 examples/deployment/chart-helm/tests/hpa_test.yaml create mode 100644 examples/deployment/chart-helm/tests/service_test.yaml diff --git a/examples/deployment/chart-helm/Chart.yaml b/examples/deployment/chart-helm/Chart.yaml index fb0f06f6d2..5270fe40b8 100644 --- a/examples/deployment/chart-helm/Chart.yaml +++ b/examples/deployment/chart-helm/Chart.yaml @@ -15,7 +15,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.0.1 +version: 0.0.2 maintainers: - name: mfournioux diff --git a/examples/deployment/chart-helm/templates/_helpers.tpl b/examples/deployment/chart-helm/templates/_helpers.tpl index 3226c1d79c..7ddb23c686 100644 --- a/examples/deployment/chart-helm/templates/_helpers.tpl +++ b/examples/deployment/chart-helm/templates/_helpers.tpl @@ -12,10 +12,17 @@ Define service name {{- if .Values.serviceName }} {{- .Values.serviceName | lower | trim }} {{- else }} -"{{ .Release.Name }}-service" +{{- printf "%s-service" .Release.Name }} {{- end }} {{- end }} +{{/* +Define deployment name +*/}} +{{- define "chart.deployment-name" -}} +{{- printf "%s-deployment-vllm" .Release.Name }} +{{- end }} + {{/* Define service port */}} @@ -162,4 +169,4 @@ runAsUser: {{- with .Values.labels -}} {{ toYaml . }} {{- end }} -{{- end }} \ No newline at end of file +{{- end }} diff --git a/examples/deployment/chart-helm/templates/deployment.yaml b/examples/deployment/chart-helm/templates/deployment.yaml index a0a3c4b9ee..2eada91b9a 100644 --- a/examples/deployment/chart-helm/templates/deployment.yaml +++ b/examples/deployment/chart-helm/templates/deployment.yaml @@ -1,23 +1,21 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: "{{ .Release.Name }}-deployment-vllm" + name: {{ include "chart.deployment-name" . | quote }} namespace: {{ .Release.Namespace }} labels: {{- include "chart.labels" . | nindent 4 }} spec: replicas: {{ .Values.replicaCount }} {{- include "chart.strategy" . | nindent 2 }} - selector: + selector: matchLabels: - environment: "test" - release: "test" + {{- include "chart.labels" . | nindent 6 }} progressDeadlineSeconds: 1200 template: metadata: labels: - environment: "test" - release: "test" + {{- include "chart.labels" . | nindent 8 }} spec: containers: - name: "vllm" @@ -128,4 +126,4 @@ spec: values: {{- toYaml . | nindent 20 }} {{- end }} - {{- end }} \ No newline at end of file + {{- end }} diff --git a/examples/deployment/chart-helm/templates/hpa.yaml b/examples/deployment/chart-helm/templates/hpa.yaml index 5ca94c8213..fa1f862a1b 100644 --- a/examples/deployment/chart-helm/templates/hpa.yaml +++ b/examples/deployment/chart-helm/templates/hpa.yaml @@ -8,7 +8,7 @@ spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment - name: vllm + name: {{ include "chart.deployment-name" . | quote }} minReplicas: {{ .Values.autoscaling.minReplicas }} maxReplicas: {{ .Values.autoscaling.maxReplicas }} metrics: @@ -28,4 +28,4 @@ spec: type: Utilization averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} {{- end }} -{{- end }} \ No newline at end of file +{{- end }} diff --git a/examples/deployment/chart-helm/templates/service.yaml b/examples/deployment/chart-helm/templates/service.yaml index 12d0f68b03..a2ee8e2887 100644 --- a/examples/deployment/chart-helm/templates/service.yaml +++ b/examples/deployment/chart-helm/templates/service.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: Service metadata: - name: "{{ .Release.Name }}-service" + name: {{ include "chart.service-name" . | quote }} namespace: {{ .Release.Namespace }} spec: type: ClusterIP @@ -11,4 +11,4 @@ spec: targetPort: {{ include "chart.container-port-name" . }} protocol: TCP selector: - {{- include "chart.labels" . | nindent 4 }} \ No newline at end of file + {{- include "chart.labels" . | nindent 4 }} diff --git a/examples/deployment/chart-helm/tests/deployment_test.yaml b/examples/deployment/chart-helm/tests/deployment_test.yaml index 9b7472cf0f..90583d54c0 100644 --- a/examples/deployment/chart-helm/tests/deployment_test.yaml +++ b/examples/deployment/chart-helm/tests/deployment_test.yaml @@ -2,6 +2,23 @@ suite: test deployment templates: - deployment.yaml tests: + - it: should use configured labels for the deployment selector and pods + set: + labels: + environment: production + release: qwen-serving + asserts: + - equal: + path: spec.selector.matchLabels + value: + environment: production + release: qwen-serving + - equal: + path: spec.template.metadata.labels + value: + environment: production + release: qwen-serving + - it: should create wait-download-model init container when modelDownload is enabled set: extraInit: @@ -132,4 +149,4 @@ tests: value: ghcr.io/llm-d/llm-d-routing-sidecar:v0.2.0 - equal: path: spec.template.spec.initContainers[1].ports[0].containerPort - value: 8080 \ No newline at end of file + value: 8080 diff --git a/examples/deployment/chart-helm/tests/hpa_test.yaml b/examples/deployment/chart-helm/tests/hpa_test.yaml new file mode 100644 index 0000000000..49e664bc7b --- /dev/null +++ b/examples/deployment/chart-helm/tests/hpa_test.yaml @@ -0,0 +1,17 @@ +suite: test horizontal pod autoscaler +templates: + - hpa.yaml +release: + name: demo +tests: + - it: should target the deployment created by this release + set: + autoscaling: + enabled: true + minReplicas: 1 + maxReplicas: 3 + targetCPUUtilizationPercentage: 80 + asserts: + - equal: + path: spec.scaleTargetRef.name + value: demo-deployment-vllm diff --git a/examples/deployment/chart-helm/tests/service_test.yaml b/examples/deployment/chart-helm/tests/service_test.yaml new file mode 100644 index 0000000000..67ddc4f894 --- /dev/null +++ b/examples/deployment/chart-helm/tests/service_test.yaml @@ -0,0 +1,25 @@ +suite: test service +templates: + - service.yaml +release: + name: demo +tests: + - it: should honor the configured service name + set: + serviceName: vllm-api + asserts: + - equal: + path: metadata.name + value: vllm-api + + - it: should select pods using the configured labels + set: + labels: + environment: production + release: qwen-serving + asserts: + - equal: + path: spec.selector + value: + environment: production + release: qwen-serving diff --git a/examples/deployment/chart-helm/values.schema.json b/examples/deployment/chart-helm/values.schema.json index 0d0e0098bc..f0276ff051 100644 --- a/examples/deployment/chart-helm/values.schema.json +++ b/examples/deployment/chart-helm/values.schema.json @@ -28,7 +28,10 @@ "type": "integer" }, "serviceName": { - "type": "null" + "type": [ + "null", + "string" + ] }, "servicePort": { "type": "integer" @@ -326,4 +329,4 @@ "secrets", "servicePort" ] -} \ No newline at end of file +}