1、NFS服务端安装-master节点 192.168.177.133
# 安装nfs服务端
yum install nfs-utils -y
# 创建共享目录
mkdir /nfs
# 配置nfs共享
vim /etc/exports
# 添加以下一行
/nfs *(rw,sync,no_root_squash) # 指明共享目录和权限设置
# 启动nfs服务,并设置开机启动
systemctl start nfs-server
systemctl enable nfs-server
# 查看nfs服务器状态
systemctl status nfs-server
# 启动rpcbind服务,设置开机启动
systemctl start rpcbind
systemctl enable rpcbind
# 查看rpcbind服务状态
systemctl status rpcbind
# 需要保证nfs服务器能够访问,关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
2、NFS客户端安装-node01、node02节点 192.168.177.130 192.168.177.131
showmount -e 192.168.177.133
yum install nfs-utils -y
# 创建挂载点,挂载nfs共享
mkdir /mnt/nfs
mount -t nfs 192.168.177.133:/nfs /mnt/nfs
# 自动挂载
server_ip:/shared_directory /mnt/nfs nfs defaults 0 0
3、master导入相应的nfs的yaml配置
https://gitee.com/Aaron-23/external-storage/blob/master/nfs-client/deploy/deployment.yaml
下载yaml配置
wget https://gitee.com/Aaron-23/external-storage/blob/master/nfs-client/deploy/deployment.yaml
wget https://gitee.com/Aaron-23/external-storage/blob/master/nfs-client/deploy/class.yaml
wget https://gitee.com/Aaron-23/external-storage/blob/master/nfs-client/deploy/rbac.yaml
导入rbac与class
kubectl apply -f class.yaml kubectl apply -f rbac.yaml
修改deploymet.yaml文件
env: - name: PROVISIONER_NAME value: fuseim.pri/ifs - name: NFS_SERVER value: 192.168.177.133 #nfs服务器ip - name: NFS_PATH value: /nfs #nfs服务器的挂载目录 volumes: - name: nfs-client-root nfs: server: 192.168.177.133 #nfs服务器ip path: /nfs #nfs服务器的挂载目录
导入deploy
kubectl apply -f deployment.yaml
5、查看
参考 https://www.cnblogs.com/solicit/p/18471055
https://www.cnblogs.com/zhangb8042/p/14252294.html
标签:20241017,192.168,yaml,nfs,master,NFS,k8s,com From: https://www.cnblogs.com/smallfa/p/18473118