Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Kubernetes version string handling by stripping metadata #623

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading