Kubernetes使用NFS作为StorageClass
文章目录
官方文档: https://github.com/kubernetes-incubator/external-storage
NFS端配置
-
安装服务
1 2 3 4 5 6 7 8 9# 安装NFS服务 yum -y install nfs-utils rpcbind # 设置共享目录参数 echo "/data/nfs 128.0.255.0/16(rw, no_root_squash)" > /etc/exports # 启动服务 systemctl enable rpcbind && systemctl start rpcbind systemctl enable nfs && systemctl start nfs
K8S宿主机
注意,所有主机都需要执行这一步
-
安装
nfs-utils1yum -y install nfs-utils rpcbind -
测试挂载
1 2 3showmount -e 128.0.255.10:/data/nfs mount 128.0.255.10:/data/nfs /mnt umount /mnt
K8S配置
注意: 官方文档示例是在default的namespace
-
创建
RBAChttps://github.com/kubernetes-incubator/external-storage/blob/master/nfs-client/deploy/test-pod.yaml
|
|
-
创建
Deployment
|
|
-
创建
StorageClasshttps://github.com/kubernetes-incubator/external-storage/blob/master/nfs-client/deploy/class.yaml
|
|
Pod使用
- 创建
PVC
|
|
-
在
Deployment中通过PVC使用https://github.com/kubernetes-incubator/external-storage/blob/master/nfs-client/deploy/test-pod.yaml
|
|
文章作者 UnknowName
上次更新 2021-03-19