k8s-deploy/gpu-worker-install.sh.j2
2025-11-21 15:21:45 +08:00

30 lines
704 B
Django/Jinja
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
set -e
OFFLINE=/opt/k8s-offline
mkdir -p $OFFLINE
tar xf k8s-offline.tgz -C $OFFLINE
echo "[1] 安装 nvidia driver离线"
bash ./install_nvidia_driver.sh
echo "[2] 安装 kubeadm/kubelet/kubectl"
install -m755 $OFFLINE/offline-cache/bin/* /usr/local/bin/
echo "[3] 导入镜像"
for img in $OFFLINE/offline-cache/images/*.tar; do
ctr -n=k8s.io images import "$img"
done
echo "[4] 加入集群"
kubeadm join {{ nodes.control_plane.ip }}:6443 \
--token {{ join.token }} \
--discovery-token-ca-cert-hash sha256:{{ join.hash }}
echo "[5] 自动部署 GPU Operator"
kubectl apply -f $OFFLINE/offline-cache/manifests/gpu-operator.yaml
echo "GPU 工作节点初始化完成"