基于Kubernetes分布式部署DeepSeek-R1(在线快速版)

准备阶段

1. 硬件说明

  • 服务器:3台服务器(建议每台至少8核CPU, 16GB内存, 24G显存,500GB硬盘空间)
  • 网络:确保三台服务器之间可以互相通信
  • 显卡:NVIDIA A10

2. 软件说明

  • OS:CentOS 8.5
  • Sealos:v5.0.1 (用于快速部署k8s集群及gpu组件)
  • kubernetes:v1.30.5
  • lws(LeaderWorkerSet):v0.5.1(k8s官方推出的用于分布式部署大模型的API)
  • vLLM:用于进行大型语言模型的推理和部署
  • DeepSeek-R1 模型:由于资源有限,这里仅部署蒸馏版1.5B的作为演示

开始部署

安装Nvidia驱动

手动在集群每个节点上安装驱动

shell 复制代码
安装依赖
# yum install -y elfutils-libelf-devel

安装驱动,驱动文件可从NVIDIA官网下载
这里文件是A10版驱动,已分享到百度网盘,可在文章最下面获取链接
# bash nvidia-driver/NVIDIA-Linux-x86_64-550.144.03.run --silent --accept-license

NVIDIA官网:https://www.nvidia.cn/drivers/lookup/

安装sealos

shell 复制代码
文件已分享到百度网盘,可在文章最下面获取链接
# rpm -ivh sealos/sealos_5.0.1_linux_amd64.rpm

一键部署k8s集群

部署k8s集群及gpu组件:

shell 复制代码
sealos run registry.cn-shanghai.aliyuncs.com/labring/kubernetes-docker:v1.30.5 \
 registry.cn-shanghai.aliyuncs.com/labring/helm:v3.8.2 \
 registry.cn-shanghai.aliyuncs.com/labring/calico:v3.24.1 \
 registry.cn-shanghai.aliyuncs.com/labring/ingress-nginx:v1.11.3 \
 registry.cn-hangzhou.aliyuncs.com/lusyoe/gpu-operator:v24.9.2 \
 registry.cn-hangzhou.aliyuncs.com/lusyoe/lws:v0.5.1 \
--masters 192.168.32.1 \
--nodes 192.168.32.2,192.168.32.3 -p [your-ssh-passwd]

验证是否部署成功:

shell 复制代码
# 查看节点状态是否Ready
kubectl get nodes

# 查看gpu 组件是否运行成功,可以多等一会
kubectl get pods -n gpu-operator

验证gpu

验证k8s集群是否支持gpu:

shell 复制代码
sealos run registry.cn-hangzhou.aliyuncs.com/lusyoe/gpu-pod:v1.0

kubectl get pods
kubectl logs gpu-pod

# 出现以下字符表示测试成功
[Vector addition of 50000 elements]
Copy input data from the host memory to the CUDA device
CUDA kernel launch with 196 blocks of 256 threads
Copy output data from the CUDA device to the host memory
Test PASSED
Done

部署vLLM与DeepSeek-R1模型

通过hfd.sh 下载镜像:

shell 复制代码
# 修改文件的执行权限
文件已分享到百度网盘,可在文章最下面获取链接
chmod a+x huggingface/hfd.sh

# 设置国内的镜像地址,默认官网无法访问
export HF_ENDPOINT="https://hf-mirror.com"

# 使用aria2 下载更快
yum install -y aria2

cd huggingface

# 下载指定镜像,并存放到本地/mnt/DeepSeek-R1-Distill-Qwen-1.5B 目录下
./hfd.sh deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B --local-dir /mnt/DeepSeek-R1-Distill-Qwen-1.5B

模型下载完后,这里可以将模型文件复制到每个节点相同目录下,也可以通过NFS等形式共享一个文件,然后在其他节点上挂载即可。

部署vLLM和模型

shell 复制代码
部署文件已分享到百度网盘,可在文章最下面获取链接
kubectl apply -f vllm/vllm-manifest.yaml

验证部署

shell 复制代码
kubectl get pods
kubectl logs vllm-0

待日志出现如下打印时,则已经部署成功,后续可以通过ingress直接在本地访问了:

百度网盘链接

链接:https://pan.baidu.com/s/1Vi2_wKR2lUOAB28YnTq6pw

提取码:5ote

相关推荐
m0_7408596221 小时前
Docker安装常见数据库命令汇总(2026)
数据库·docker·容器
清风lsq21 小时前
大模型-vllm 自投机解码可行性分析
vllm·大模型推理
IT策士21 小时前
第16篇 实战:用 Docker Compose 编排 WordPress 与 MySQL
mysql·docker·容器
Cat_Rocky21 小时前
Jenkins通过kubernetes连接K8s集群
运维·kubernetes·jenkins
Plastic garden21 小时前
Docker(2)数据挂载
运维·docker·容器
大模型推理21 小时前
《Nano-vLLM 源码解读》第 12 篇 · ModelRunner:从 prompt 到 token(二)
vllm
Plastic garden21 小时前
Docker(4) Compose
运维·docker·容器
我叫张小白。21 小时前
基于Redis与FastAPI的分布式共享会话体系
数据库·redis·分布式·缓存·中间件·fastapi·依赖注入
IT策士1 天前
第17篇 Docker Compose 进阶实战:多 Compose 文件与环境覆盖
docker·容器·eureka
天河归来1 天前
国产数据库安全可靠测评产品观察:从集中式、分布式到 HTAP 的发展趋势
数据库·分布式