1. node節(jié)點(diǎn)label管理
1.1 給節(jié)點(diǎn)加label
- 語法:
# kubectl label node Node_Name Key=Value - 示例
# kubectl label node gpu3 gpu-use=true
1.2 查看label
- 語法
Kubectl get node gpu3 --show-labels

image.png
1.3 修改label
-
語法
kubectl label node Node_Name Key=Value --overwrite
說明:添加label命令加上 --overwrite參數(shù)
- 示例
kubectl label node gpu3 gpu-use=true --overwrite
1.4 刪除lable
-
語法
kubectl label node Node_Name Key-
說明:刪除一個key,只需把key的后邊加一個減號即可
- 示例
# kubectl label node gpu3 gpu_use-
2 pod選擇node節(jié)點(diǎn)
說明:pod根據(jù)node的label選擇節(jié)點(diǎn)
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: nvidia-device-plugin-daemonset
namespace: kube-system
spec:
template:
metadata:
annotations:
scheduler.alpha.kubernetes.io/critical-pod: ""
labels:
name: nvidia-device-plugin-ds
spec:
tolerations:
- key: CriticalAddonsOnly
operator: Exists
#添加如下兩行
nodeSelector:
gpu-use: "true"
containers:
- image: nvidia/k8s-device-plugin:1.11
name: nvidia-device-plugin-ctr
securityContext:
capabilities:
drop: ["ALL"]
volumeMounts:
- name: device-plugin
mountPath: /var/lib/kubelet/device-plugins
volumes:
- name: device-plugin
hostPath:
path: /var/lib/kubelet/device-plugins
