From c644130d12dad553d894cb3503a9abd25597868a Mon Sep 17 00:00:00 2001 From: Nimbus <7684280+nimbus318@user.noreply.gitee.com> Date: Sat, 16 Nov 2024 12:59:00 +0800 Subject: [PATCH 1/2] fix(helm): handle Kubernetes version string by stripping metadata after `+` This fix ensures that Kubernetes version strings with additional metadata (e.g., `+k3s1`) are properly handled. The function `strippedKubeVersion` is introduced to remove the part after the `+`, resolving issues with version compatibility in dynamically generated image tags. Signed-off-by: Nimbus <7684280+nimbus318@user.noreply.gitee.com> --- charts/hami/templates/_helpers.tpl | 21 +++++++++++++++++++ .../hami/templates/scheduler/deployment.yaml | 2 +- .../templates/scheduler/device-configmap.yaml | 6 +++--- charts/hami/values.yaml | 4 ++++ docs/config.md | 12 ++++++++++- 5 files changed, 40 insertions(+), 5 deletions(-) diff --git a/charts/hami/templates/_helpers.tpl b/charts/hami/templates/_helpers.tpl index fc7944c98..4f1ea8e33 100644 --- a/charts/hami/templates/_helpers.tpl +++ b/charts/hami/templates/_helpers.tpl @@ -85,3 +85,24 @@ Image registry secret name imagePullSecrets: {{ toYaml .Values.imagePullSecrets | nindent 2 }} {{- end }} +{{/* + Resolve the tag for kubeScheduler. +*/}} +{{- define "resolvedKubeSchedulerTag" -}} +{{- if .Values.scheduler.kubeScheduler.tag }} +{{- .Values.scheduler.kubeScheduler.tag | trim -}} +{{- else }} +{{- include "strippedKubeVersion" . | trim -}} +{{- end }} +{{- end }} + + +{{/* + Remove the part after the `+` in the Kubernetes version string. + v1.31.1+k3s1 -> v1.31.1 + v1.31.1 -> v1.31.1 +*/}} +{{- define "strippedKubeVersion" -}} +{{- $parts := split "+" .Capabilities.KubeVersion.Version -}} +{{- print $parts._0 -}} +{{- end -}} diff --git a/charts/hami/templates/scheduler/deployment.yaml b/charts/hami/templates/scheduler/deployment.yaml index 0e0246d68..82b47f160 100644 --- a/charts/hami/templates/scheduler/deployment.yaml +++ b/charts/hami/templates/scheduler/deployment.yaml @@ -33,7 +33,7 @@ spec: containers: {{- if .Values.scheduler.kubeScheduler.enabled }} - name: kube-scheduler - image: {{ .Values.scheduler.kubeScheduler.image }}:{{ .Capabilities.KubeVersion.Version }} + image: "{{ .Values.scheduler.kubeScheduler.image }}:{{ include "resolvedKubeSchedulerTag" . }}" imagePullPolicy: {{ .Values.scheduler.kubeScheduler.imagePullPolicy | quote }} command: - kube-scheduler diff --git a/charts/hami/templates/scheduler/device-configmap.yaml b/charts/hami/templates/scheduler/device-configmap.yaml index 7e132e152..412a60496 100644 --- a/charts/hami/templates/scheduler/device-configmap.yaml +++ b/charts/hami/templates/scheduler/device-configmap.yaml @@ -20,9 +20,9 @@ data: defaultMemory: 0 defaultCores: 0 defaultGPUNum: 1 - deviceSplitCount: 10 - deviceMemoryScaling: 1 - deviceCoreScaling: 1 + deviceSplitCount: {{ .Values.devicePlugin.deviceSplitCount }} + deviceMemoryScaling: {{ .Values.devicePlugin.deviceMemoryScaling }} + deviceCoreScaling: {{ .Values.devicePlugin.deviceCoreScaling }} cambricon: resourceCountName: {{ .Values.mluResourceName }} resourceMemoryName: {{ .Values.mluResourceMem }} diff --git a/charts/hami/values.yaml b/charts/hami/values.yaml index d8636d32e..bc485f588 100644 --- a/charts/hami/values.yaml +++ b/charts/hami/values.yaml @@ -59,6 +59,7 @@ scheduler: # @param enabled indicate whether to run kube-scheduler container in the scheduler pod, it's true by default. enabled: true image: registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler + tag: "" imagePullPolicy: IfNotPresent extraNewArgs: - --config=/config/config.yaml @@ -111,6 +112,9 @@ devicePlugin: monitorimage: "projecthami/hami" monitorctrPath: /usr/local/vgpu/containers imagePullPolicy: IfNotPresent + deviceSplitCount: 10 + deviceMemoryScaling: 1 + deviceCoreScaling: 1 runtimeClassName: "" migStrategy: "none" disablecorelimit: "false" diff --git a/docs/config.md b/docs/config.md index 494489aab..80db448c0 100644 --- a/docs/config.md +++ b/docs/config.md @@ -1,9 +1,19 @@ # Global Config +**Note:** +All the configurations listed below are managed within the hami-scheduler-device ConfigMap. +You can update these configurations using one of the following methods: + +1. Directly edit the ConfigMap: If HAMi has already been successfully installed, you can manually update the hami-scheduler-device ConfigMap using the kubectl edit command to manually update the hami-scheduler-device ConfigMap. + ```bash + kubectl edit configmap hami-scheduler-device -n + ``` + After making changes, restart the related HAMi components to apply the updated configurations. +2. Modify Helm Chart: Update the corresponding values in the [ConfigMap](../charts/hami/templates/scheduler/device-configmap.yaml), then reapply the Helm Chart to regenerate the ConfigMap. you can customize your vGPU support by setting the following parameters using `-set`, for example ``` -helm install vgpu-charts/vgpu vgpu --set devicePlugin.deviceMemoryScaling=5 ... +helm install hami hami-charts/hami --set devicePlugin.deviceMemoryScaling=5 ... ``` * `devicePlugin.service.schedulerPort:` From db167c4d008df456e09090b9be2678d8a4fec695 Mon Sep 17 00:00:00 2001 From: Nimbus <7684280+nimbus318@user.noreply.gitee.com> Date: Sat, 16 Nov 2024 13:34:46 +0800 Subject: [PATCH 2/2] fix(helm): replace tag with imageTag for compatibility Signed-off-by: Nimbus <7684280+nimbus318@user.noreply.gitee.com> --- charts/hami/templates/_helpers.tpl | 4 ++-- charts/hami/values.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/charts/hami/templates/_helpers.tpl b/charts/hami/templates/_helpers.tpl index 4f1ea8e33..2e2366adf 100644 --- a/charts/hami/templates/_helpers.tpl +++ b/charts/hami/templates/_helpers.tpl @@ -89,8 +89,8 @@ imagePullSecrets: {{ toYaml .Values.imagePullSecrets | nindent 2 }} Resolve the tag for kubeScheduler. */}} {{- define "resolvedKubeSchedulerTag" -}} -{{- if .Values.scheduler.kubeScheduler.tag }} -{{- .Values.scheduler.kubeScheduler.tag | trim -}} +{{- if .Values.scheduler.kubeScheduler.imageTag }} +{{- .Values.scheduler.kubeScheduler.imageTag | trim -}} {{- else }} {{- include "strippedKubeVersion" . | trim -}} {{- end }} diff --git a/charts/hami/values.yaml b/charts/hami/values.yaml index bc485f588..7026f25c1 100644 --- a/charts/hami/values.yaml +++ b/charts/hami/values.yaml @@ -59,7 +59,7 @@ scheduler: # @param enabled indicate whether to run kube-scheduler container in the scheduler pod, it's true by default. enabled: true image: registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler - tag: "" + imageTag: "" imagePullPolicy: IfNotPresent extraNewArgs: - --config=/config/config.yaml