Skip to content

Commit

Permalink
fix(helm): handle Kubernetes version string by stripping metadata aft…
Browse files Browse the repository at this point in the history
…er `+`

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 <[email protected]>
  • Loading branch information
Nimbus authored and wawa0210 committed Nov 18, 2024
1 parent 69370a7 commit 5396897
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 5 deletions.
21 changes: 21 additions & 0 deletions charts/hami/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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.imageTag }}
{{- .Values.scheduler.kubeScheduler.imageTag | 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 -}}
2 changes: 1 addition & 1 deletion charts/hami/templates/scheduler/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions charts/hami/templates/scheduler/device-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
4 changes: 4 additions & 0 deletions charts/hami/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
imageTag: ""
imagePullPolicy: IfNotPresent
extraNewArgs:
- --config=/config/config.yaml
Expand Down Expand Up @@ -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"
Expand Down
12 changes: 11 additions & 1 deletion docs/config.md
Original file line number Diff line number Diff line change
@@ -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 <namespace>
```
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:`
Expand Down

0 comments on commit 5396897

Please sign in to comment.