k8s报错Error: template: nvidia-device-plugin/templates/gfd.yml:22:19: executing "nvidia-device-plugin/templates/gfd.yml" at <.Subcharts.gfd>: nil pointer evaluating interface {}.gfd

前言

在安装 kubernetes 插件 k8s-device-plugin时,报错:

Error: template: nvidia-device-plugin/templates/gfd.yml:22:19: executing "nvidia-device-plugin/templates/gfd.yml" at <.Subcharts.gfd>: nil pointer evaluating interface {}.gfd

解决

通过查看 helm 发行文档,发现 helm 版本,至少需要 3.7.0 才能使用定义的子图。

https://github.com/helm/helm/releases/tag/v3.7.0

所以需要升级 helm,https://helm.sh/zh/docs/intro/install/

curl https://baltocdn.com/helm/signing.asc | gpg --dearmor | sudo tee /usr/share/keyrings/helm.gpg > /dev/null
sudo apt-get install apt-transport-https --yes
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/helm.gpg] https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list
sudo apt-get update
sudo apt-get install helm

打印 helm 版本

# helm version
version.BuildInfo{Version:"v3.14.0", GitCommit:"3fc9f4b2638e76f26739cd77c7017139be81d0ea", GitTreeState:"clean", GoVersion:"go1.21.5"}

helm 安装 nvidia-device-plugin

helm upgrade -i nvdp nvdp/nvidia-device-plugin \
    --version=0.13.0 \
    --namespace kube-system \
    --set gfd.enabled=true \
    --set-file config.map.config=timesharing.yaml

又遇到以下问题:

Error: unable to continue with install: CustomResourceDefinition "nodefeaturerules.nfd.k8s-sigs.io" in namespace an exists a nd cannot be imported into the current release : invalid ownership metadata; label validation error: missing key "app.kube rne tes.io/managed-by":must be set to "Helm" ; annotation validation error: missing key "meta.helm.sh/ release-name " :must be set to "nvdp";annotation validation error: missing key "meta.helm. sh/ release-namespace": must be set to "kube-system"

这是因为 CustomResourceDefinition "nodefeaturerules.nfd.k8s-sigs.io" in namespace "an" exists and cannot be imported into the current release: 此错误表示在当前发布中无法导入已存在的自定义资源定义(CustomResourceDefinition)。可能是由于之前未正确删除该自定义资源定义而导致的冲突。

需要手动删除,已存在的自定义资源定义

kubectl delete crd nodefeaturerules.nfd.k8s-sigs.io

重新安装nvidia-device-plugin

helm upgrade -i nvdp nvdp/nvidia-device-plugin \
    --version=0.13.0 \
    --namespace kube-system \
    --set gfd.enabled=true \
    --set-file config.map.config=timesharing.yaml

安装成功

Release "nvdp" does not exist. Installing it now.

NAME: nvdp
LAST DEPLOYED: Tue Jan 30 14:52:17 2024
NAMESPACE: kube-system
STATUS: deployed
REVISION: 1
TEST SUITE: None

通过命令kubectl get pod -n kube-system查看,如果pod状态为ImagePullBackOff,这时还需要 docker 手动下载下来,docker load 导入

posted @ 2024-01-30 15:23  牛奔  阅读(31)  评论(0编辑  收藏  举报