Helm在Kubernetes上部署RustFS生产环境指南
以下是深入学习 RustFS 的推荐资源:RustFS
官方文档: RustFS 官方文档- 提供架构、安装指南和 API 参考。
GitHub 仓库: GitHub 仓库 - 获取源代码、提交问题或贡献代码。
社区支持: GitHub Discussions- 与开发者交流经验和解决方案。
我们 AI 平台原来的存储是单机 NFS,挂了就全挂。后来试过 Ceph,太复杂。最后选了 RustFS,因为部署简单、性能还行。这里记录一下用 Helm 部署的过程和一些踩坑经验。
1. 准备工作
K8s 版本 1.28+,Helm 3.12+。存储节点最好用 NVMe SSD,万兆网络起步。
我们环境:
- 3 个 master,6 个 worker(存储专用)
- 每个 worker 挂 4 块 3.84TB NVMe
- 网络:RoCE + RDMA(可选,没有也能跑)
节点简单优化了一下(内核参数、磁盘调度),贴个脚本:
bash
cat <<EOF >> /etc/sysctl.conf
net.core.rmem_max = 134217728
net.core.wmem_max = 134217728
vm.swappiness = 10
EOF
sysctl -p
# NVMe 调度改成 none
for d in /dev/nvme*n1; do echo none > /sys/block/$(basename $d)/queue/scheduler; done
2. 添加 Helm 仓库
官方 Helm Chart 仓库地址是 https://rustfs.github.io/helm/。
bash
helm repo add rustfs https://rustfs.github.io/helm/
helm repo update
搜一下看看有什么:
bash
helm search repo rustfs
3. 了解官方支持的部署模式
RustFS 的 Helm Chart 支持两种模式:
| 模式 | 说明 | Pod 数量 | PVC 配置 |
|---|---|---|---|
| Standalone | 单节点单磁盘,适合开发测试 | 1 | 1 个 PVC(数据)+ 1 个 PVC(日志) |
| Distributed(默认) | 多节点多磁盘,生产环境高可用 | 4 或 16 | 每个 Pod 4 个 PVC,或每个 Pod 1 个 PVC |
官方原文:
"For standalone mode, there is only one pod and one pvc; for distributed mode, there are two styles, 4 pods and 16 pvcs(each pod has 4 pvcs), 16 pods and 16 pvcs(each pod has 1 pvc)."
4. 准备 values 文件
生产环境我用的是 Distributed 模式,4 个 Pod,每个 Pod 挂 4 块盘。values-prod.yaml:
yaml
# 部署模式:分布式(默认就是,但显式写一下)
mode:
distributed:
enabled: true
standalone:
enabled: false
# 节点数量(官方支持 4 或 16)
replicaCount: 4
# 资源配置
resources:
requests:
cpu: "2"
memory: "8Gi"
limits:
cpu: "4"
memory: "16Gi"
# 存储配置
persistence:
enabled: true
size: "3Ti" # 根据实际磁盘大小调整
# 服务暴露
service:
type: LoadBalancer
port: 9000
# 认证凭证(生产环境必须改)
secret:
rustfs:
access_key: "your-access-key"
secret_key: "your-secret-key"
注意:如果不设置
secret.rustfs.access_key 和secret.rustfs.secret_key,默认是rustfsadmin/rustfsadmin。生产环境务必改掉。
5. 安装
创建一个命名空间,然后安装:
bash
kubectl create ns rustfs
helm install my-rustfs rustfs/rustfs \
--namespace rustfs \
--values values-prod.yaml
等几分钟,看 Pod 状态:
bash
kubectl get pods -n rustfs -w
正常应该看到 4 个 rustfs-* Pod 变成 Running。
如果要装 16 节点分布式模式:
bash
helm install my-rustfs rustfs/rustfs --namespace rustfs --create-namespace --set replicaCount=16
如果要装 Standalone 模式(开发测试):
bash
helm install my-rustfs rustfs/rustfs --namespace rustfs --create-namespace \
--set mode.standalone.enabled=true \
--set mode.distributed.enabled=false
6. 验证
暴露的服务如果是 LoadBalancer,拿外部 IP:
bash
kubectl get svc -n rustfs
然后用 mc 客户端连一下试试:
bash
mc alias set myrustfs http://<EXTERNAL-IP>:9000 <access-key> <secret-key>
mc ls myrustfs
能列出来就是好了。
7. 踩过的坑
7.1 副本数必须与存储节点匹配
Distributed 模式下,每个 Pod 会挂载 PVC。如果 replicaCount 设置得比可用节点还多,多余的 Pod 会 Pending,因为 PVC 无法调度到没有剩余存储的节点上。
7.2 默认没有监控
官方 Chart 不带 Prometheus exporter,要监控的话得自己用 sidecar 或者装个单独的 metrics 容器。我们懒得弄,就接了个 node exporter 看磁盘和网络。
8. 日常运维
升级
bash
helm repo update
helm upgrade my-rustfs rustfs/rustfs --namespace rustfs -f values-prod.yaml
扩容
改 values-prod.yaml 里的 replicaCount(只能从 4 改成 16,不能改成其他数字),然后 helm upgrade。注意新加的节点要有相同的存储能力。
备份
RustFS 本身没有内置备份工具,我们用的 velero 定期备份 PVC 快照:
bash
velero backup create rustfs-backup --include-namespaces rustfs
9. 性能怎么样?
我们实测单客户端读 1.2GB/s,写 800MB/s 左右(10Gb 网络,NVMe 盘)。P99 延迟大约 8-12ms,够用了。
10. 总结
RustFS + Helm 部署确实比 Ceph 省心不少。主要优点:
- 一条
helm install就起来,不用手工调一堆配置 - 分布式模式自带多副本,节点挂了一个不影响读写
- 升级回滚方便
缺点也有:
- 文档有点散,仓库地址容易搞错
- 监控、告警需要自己补
如果你们也是小团队,不想折腾 Ceph,可以试试这个。
参考链接
- 官方 Helm 仓库:https://rustfs.github.io/helm/
- 官方 GitHub:https://github.com/rustfs/rustfs/tree/main/helm