-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add validator nvidia driver whether install success
Signed-off-by: lengrongfu <lenronfu@gmail.com>
- Loading branch information
1 parent
59f1afc
commit ca232fa
Showing
9 changed files
with
143 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
charts/hami/templates/device-plugin/daemonsetvalidator-configmap.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{{- if .Values.devicePlugin.autoValidatorDriver }} | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: driver-validator-configmap | ||
labels: | ||
app.kubernetes.io/component: 4pd-driver-validator | ||
data: | ||
validator.sh: | | ||
#!/bin/zsh | ||
if [ -f "/host/usr/bin/nvidia-smi" ]; then | ||
driverRoot="/host" | ||
isHostDriver="true" | ||
else | ||
driverRoot="/run/nvidia/driver" | ||
isHostDriver="false" | ||
fi | ||
# check this directory /run/nvidia/driver does exist? | ||
if [ "$isHostDriver" = "false" ]; then | ||
while [ ! -d "/run/nvidia/driver" ]; do | ||
echo current node $NODE_NAME not GPU device; | ||
sleep 10 | ||
done | ||
fi | ||
sleep_interval=5 | ||
if [ "$isHostDriver" = "false" ]; then | ||
while true; do | ||
stat /run/nvidia/validations/.driver-ctr-ready | ||
if [ $? -ne 0 ]; then | ||
kubectl label node $NODE_NAME hami.io/nvidia-selector="off" --overwrite | ||
sleep $sleep_interval | ||
else | ||
break | ||
fi | ||
done | ||
fi | ||
while true; do | ||
chroot "$driverRoot" nvidia-smi | ||
if [ $? -eq 0 ]; then | ||
sleep 30 | ||
kubectl label node $NODE_NAME hami.io/nvidia-selector="on" --overwrite | ||
break | ||
else | ||
sleep $sleep_interval | ||
fi | ||
done | ||
echo validations are successful; sleep infinity | ||
{{- end }} |
70 changes: 70 additions & 0 deletions
70
charts/hami/templates/device-plugin/daemonsetvalidator.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
{{- if .Values.devicePlugin.autoValidatorDriver }} | ||
apiVersion: apps/v1 | ||
kind: DaemonSet | ||
metadata: | ||
name: driver-validator | ||
labels: | ||
app.kubernetes.io/component: 4pd-driver-validator | ||
{{- with .Values.global.labels }} | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
{{- if .Values.global.annotations }} | ||
annotations: {{ toYaml .Values.global.annotations | nindent 4}} | ||
{{- end }} | ||
spec: | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/component: 4pd-driver-validator | ||
template: | ||
metadata: | ||
labels: | ||
app.kubernetes.io/component: 4pd-driver-validator | ||
4pd.io/webhook: ignore | ||
spec: | ||
serviceAccountName: {{ include "4pd-vgpu.device-plugin" . }} | ||
priorityClassName: system-node-critical | ||
containers: | ||
- name: driver-validator | ||
image: '{{ .Values.devicePlugin.image }}:{{ .Values.version }}' | ||
command: | ||
- /bin/sh | ||
- -c | ||
- /scripts/validator.sh | ||
env: | ||
- name: NODE_NAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: spec.nodeName | ||
volumeMounts: | ||
- mountPath: /host | ||
mountPropagation: HostToContainer | ||
name: host-root | ||
readOnly: true | ||
- mountPath: /run/nvidia/driver | ||
mountPropagation: HostToContainer | ||
name: driver-install-path | ||
readOnly: true | ||
- mountPath: /run/nvidia/validations | ||
mountPropagation: Bidirectional | ||
name: run-nvidia-validations | ||
- name: validator-configmap | ||
mountPath: /scripts | ||
resources: | ||
limits: | ||
cpu: 10m | ||
memory: 50Mb | ||
volumes: | ||
- hostPath: | ||
path: /run/nvidia/driver | ||
name: driver-install-path | ||
- hostPath: | ||
path: / | ||
name: host-root | ||
- name: validator-configmap | ||
configMap: | ||
name: driver-validator-configmap | ||
- hostPath: | ||
path: /run/nvidia/validations | ||
type: DirectoryOrCreate | ||
name: run-nvidia-validations | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters