首发:编码如写诗。

前言

  • DeepSeek-R1 春节期间引爆AI市场,现在各大公司也都在部署本地私有化大模型。而昨日 KubeSphere 社区交出了一份新答卷,无需复杂步骤,一个可视化界面,几分钟完成大模型服务部署!
  • K3s 是一个轻量级的 K8s 发行版,它希望在内存占用方面是 K8s的一半大小,所以简写为 K3s。由于K3s部署简单,且兼容 K8s 核心接口。很适合小业务量和信创服务器体验上云。

涉及软件版本信息

  • CPU架构: x86_64
  • 操作系统:Ubuntu24.04.1
  • Docker: 26.1.3
  • KubeSphere:v4.1.2
  • K3s:v1.32.1
  • ks-core-helm-chart:1.1.3

服务器配置:

<font style="color:rgb(66, 75, 93);">主机名</font><font style="color:rgb(66, 75, 93);">IP</font><font style="color:rgb(66, 75, 93);">CPU</font><font style="color:rgb(66, 75, 93);">内存</font><font style="color:rgb(66, 75, 93);">架构</font><font style="color:rgb(66, 75, 93);">OS</font><font style="color:rgb(66, 75, 93);">用途</font>
<font style="color:rgb(66, 75, 93);">node1</font><font style="color:rgb(66, 75, 93);">192.168.85.131</font><font style="color:rgb(66, 75, 93);">4</font><font style="color:rgb(66, 75, 93);">8</font><font style="color:rgb(66, 75, 93);">x86_64</font><font style="color:rgb(66, 75, 93);">Ubuntu24.04.1</font><font style="color:rgb(66, 75, 93);">slaver+worker</font>
<font style="color:rgb(66, 75, 93);">node2</font><font style="color:rgb(66, 75, 93);">192.168.85.132</font><font style="color:rgb(66, 75, 93);">4</font><font style="color:rgb(66, 75, 93);">8</font><font style="color:rgb(66, 75, 93);">x86_64</font><font style="color:rgb(66, 75, 93);">Ubuntu24.04.1</font><font style="color:rgb(66, 75, 93);">slaver+worker</font>
<font style="color:rgb(66, 75, 93);">node3</font><font style="color:rgb(66, 75, 93);">192.168.85.133</font><font style="color:rgb(66, 75, 93);">4</font><font style="color:rgb(66, 75, 93);">16</font><font style="color:rgb(66, 75, 93);">x86_64</font><font style="color:rgb(66, 75, 93);">Ubuntu24.04.1</font><font style="color:rgb(66, 75, 93);">deepseek节点+slaver+worker</font>

安装K3s

相关链接

下载K3s相关软件

上传至服务器 chmod +x k3s

K3s二进制文件和镜像放到对应目录

mkdir -p /var/lib/rancher/k3s/agent/images/
cp ./k3s-airgap-images-amd64.tar.gz /var/lib/rancher/k3s/agent/images/
cp k3s /usr/local/bin/k3s

获取install.sh

curl -o install.sh https://get.k3s.io/

安装 Docker (若需要以Docker运行)

apt install docker.io

导入 K3s 镜像

docker load < k3s-airgap-images-amd64.tar.gz

安装K3s

修改主机名

hostnamectl set-hostname node1

使用嵌入式etcd作为数据存储

node1,IP:131上安装

  • 在线安装
curl -sfL https://get.k3s.io | K3S_TOKEN=K10aeb8b45ed54244b009a7f2fa021c62e4638652bf545837170d46a182dd5015f2::server:54326ba453a7ad0d25b9766b08ec7d15 sh -s - server --cluster-init
  • 离线安装
INSTALL_K3S_SKIP_DOWNLOAD=true INSTALL_K3S_EXEC='server --write-kubeconfig ~/.kube/config --write-kubeconfig-mode 644 --cluster-init --docker'  ./install.sh

node2 和 node3 增加 server 节点

cat /var/lib/rancher/k3s/server/node-token 查看上一个server的token值,替换下面的K3S_TOKEN中的值

INSTALL_K3S_SKIP_DOWNLOAD=true INSTALL_K3S_EXEC='server --write-kubeconfig ~/.kube/config --write-kubeconfig-mode 644 --server https://192.168.85.131:6443 --docker' \
K3S_TOKEN=K101c02bd0da39df081e78ed999285cf5e0f18b32a32677265378e94c43df0b624b::server:c427b16dda099a1ee6ab98bf623f3570  ./install.sh

安装KubeSphere

下载 KubeSphere Core Helm Chart

  • 安装 Helm
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash

访问 <font style="color:rgb(46,161,33);">https://get-images.kubesphere.io</font><font style="color:rgb(46,161,33);">KubeSphere GitHub 仓库</font>查看最新 chart 版本。

安装 KubeSphere

helm upgrade --install -n kubesphere-system --create-namespace ks-core https://charts.kubesphere.io/main/ks-core-1.1.3.tgz --debug --wait --set global.imageRegistry=swr.cn-southwest-2.myhuaweicloud.com/ks

等待大概2分钟。

NOTES:
Thank you for choosing KubeSphere Helm Chart.

Please be patient and wait for several seconds for the KubeSphere deployment to complete.

1. Wait for Deployment Completion

    Confirm that all KubeSphere components are running by executing the following command:

    kubectl get pods -n kubesphere-system
2. Access the KubeSphere Console

    Once the deployment is complete, you can access the KubeSphere console using the following URL:  

    http://192.168.85.131:30880

3. Login to KubeSphere Console

    Use the following credentials to log in:

    Account: admin
    Password: P@88w0rd

NOTE: It is highly recommended to change the default password immediately after the first login.
For additional information and details, please visit https://kubesphere.io.
root@node1:~#

验证

  • 登录

  • 集群管理 支持集群联邦,此处可以展示多集群

  • 集群概览

  • 集群节点

安装DeepSeek

进入扩展市场

点击右上角“扩展市场”

安装 NVIDIA GPU Operator(可选)

由于笔者电脑显卡为亮屏卡,这里就不安装了

安装DeepSeek

在搜索中输入deepseek后回车

点击管理后点击安装

点击下一步安装后,到后台查看 pod,可以看到多了一个ns:extension-deepseek

由于墙的原因,导致镜像拉取失败,这时候我们需要先科学上网将镜像下载后再导入到服务器。

具体用到的镜像有:

ollama/ollama:0.5.7
yidadaa/chatgpt-next-web:v2.16.0

若访问docker受限,可直接使用这里已经下载好的:https://pan.quark.cn/s/14b90df443b0

将上述两个镜像上传到服务器,并且load加载

此时可以看到 ollama 正在下载 deepseek-r1:1.5b 模型

点击日志,查看下载过程

等待100%,此时模型已下载完毕,并且已运行起来。

开启chat外部访问

可以看到nodePort端口为31648

访问 DeepSeek Chat

浏览器访问IP:nodePort,这里是:http://192.168.85.131:31648

总结

本文演示了离线 K3s 的部署和在线部署 KubeSphere 。部署DeepSeek 大模型时,需要 ollama 和 chatgpt-next-eweb 镜像,这两个镜像需要准备好。而 Deepseek-r1 模型,ollama 会自动在线下载无需魔法黑科技。通过本文学习你不单拥有了本地部署 Ds 的能力,更拥有了云原生和 Ds 上云的能力。

本文由博客一文多发平台 OpenWrite 发布!

KubeSphere
124 声望59 粉丝

KubeSphere 是一个开源的以应用为中心的容器管理平台,支持部署在任何基础设施之上,并提供简单易用的 UI,极大减轻日常开发、测试、运维的复杂度,旨在解决 Kubernetes 本身存在的存储、网络、安全和易用性等痛...