- 假设已部署 nfs 服务器,truenas 如何部署 nfs 存储可见相关文章
- NFS provisioner 已知缺陷
- 预配的存储空间无法保证,分配的存储空间可能超过 NFS 共享的总大小
- 预置的存储限制不强制执行
- 目前不支持任何形式的存储调整/扩展操作
测试裸机是否能挂载
showmount -e <nfs_server_ip>
mkdir -p /mnt/nfs-test && mount -t nfs <nfs_server_ip>:/nfs/path /mnt/nfs-test- truenas 的情况下
nfs.path一般为/mnt/<root_dataset>/<nfs_dataset>
touch /mnt/nfs-test/.test && ls -al /mnt/nfs-test/.test
umount /mnt/nfs-test
添加 nfs-subdir-external-provisioner 实例
helm repo add nfs-subdir-external-provisioner https://kubernetes-sigs.github.io/nfs-subdir-external-provisioner/
vim ~/.config/helm/value/nfs-subdir-external-provisioner.yaml
- affinity 可选:LXC 等没有特权的容器里 mount 会报错,需要限制部署
kubectl label node node-1 node-2 node.kubernetes.io/nfs=true- 添加标签
kubectl label nodes node-1 node-2 node.kubernetes.io/nfs-- 删除标签
kubectl get nodes --show-labels | grep nfs
helm upgrade --install nfs-subdir-external-provisioner nfs-subdir-external-provisioner/nfs-subdir-external-provisioner \ -f ~/.config/helm/value/nfs-subdir-external-provisioner.yaml
kubectl describe pod nfs-subdir-external-provisioner
查看是否有对应存储类 nfs-client
kubectl get storageclass | grep nfs-client- 这是默认的名称,可以修改
- 如果需要配置多个则需要手动修改
storageClass.name和storageClass.provisionerName
添加 PVC 和 busybox pod 进行测试
vim ~/.config/k3s/test-nfs-client.yaml
- affinity 可选:LXC 等没有特权的容器里 mount 会报错,需要限制部署
kubectl label node <node-name> node-type=vmkubectl get nodes --show-labels | grep node-type
kubectl apply -f ~/.config/k3s/test-nfs-client.yaml
kubectl get pod test-pod -o wide- status 为
Completed即无误
kubectl describe pod test-pod
kubectl delete -f ~/.config/k3s/test-nfs-client.yaml
- Author:白鸟3
- URL:https://blog.kun2peng.top/operation/k8s_nfs_stroage
- Copyright:All articles in this blog, except for special statements, adopt BY-NC-SA agreement. Please indicate the source!
