首先在集群之外安装服务端
bashapt update apt upgrade apt install nfs-kernel-server mkdir -p /srv/nfs/share #创建共享目录 chmod 777 /srv/nfs/share #分配权限 echo "/srv/nfs/share 192.168.100.0/24(rw,sync,no_root_squash,no_subtree_check)" >> /etc/exports exportfs -rv //使配置生效 #验证挂载 showmount -e localhost #Export list for localhost: #/srv/nfs/share 192.168.100.0/22
所有节点安装nfs客户端!!⚠️
bashapt update apt upgrade apt-get install -y nfs-common showmount -e 192.168.100.193 #Export list for 192.168.100.0: #/srv/nfs/share 192.168.100.0/22
参考https://github.com/kubernetes-csi/csi-driver-nfs/blob/master/docs/install-csi-driver-master.md
bashcurl -skSL https://raw.githubusercontent.com/kubernetes-csi/csi-driver-nfs/master/deploy/install-driver.sh | bash -s master --
参考https://github.com/kubernetes-csi/csi-driver-nfs/blob/master/deploy/storageclass.yaml 博主直接使用
bashkubtctl apply -f https://git.ooxo.cc/k8s/yaml/raw/branch/main/storageclass-nfs.yaml