Files
Deploy-Laboratory/docs/03-06-k3s-使用nfs存储.md
2026-03-21 04:36:06 +08:00

55 lines
1.4 KiB
Markdown
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.
# 03-07-k3s 使用 NFS 存储
> 本文只讲 K3s 集群侧如何使用已安装好的 NFS。
## 前置条件
- 已完成 `01-06-armv7-nfs服务安装.md`
- 可从 K3s 节点访问 NFS 服务器与导出目录
## 操作步骤
1. 创建 NFS 类型 `PersistentVolume`
2. 创建 `PersistentVolumeClaim`
3. 在业务 Pod 中挂载 PVC
**唯一真源**[`ansible/files/nfs-demo/nfs-pv-pvc-demo.yaml`](../ansible/files/nfs-demo/nfs-pv-pvc-demo.yaml)(按你的 NFS `server` / `path` 修改)。
## 验证命令(若 YAML 在 manifests 目录,按实际路径选择其一复制执行)
```bash
# 仓库根直接应用
kubectl apply -f ansible/files/nfs-demo/nfs-pv-pvc-demo.yaml
```
```bash
# 或默认路径(已拷贝到 manifests 时)
kubectl apply -f /var/lib/rancher/k3s/server/manifests/nfs-pv-pvc.yaml
kubectl get pv,pvc -A
kubectl describe pv nfs-pv-demo
```
```bash
# 自定义 data-dir如 /storage
kubectl apply -f /storage/server/manifests/nfs-pv-pvc.yaml
kubectl get pv,pvc -A
kubectl describe pv nfs-pv-demo
```
## 预期
- PV/PVC 状态为 `Bound`
- 业务 Pod 可读写挂载目录
## 失败排查
- 检查 NFS 服务与导出目录权限
- 检查节点到 NFS 服务器网络
- 检查 `path``server` 配置是否正确
## 下一步
- `03-05-k3s-local-path-pvc.md`:单副本应用用 K3s 自带 local-path 即可,无需 NFS
- `05-06-openlist挂载网盘与自动备份.md`