创建共享存储目录
yum install -y rpcbind nfs-utils
创建共享目录
mkdir -p /home/sharedir/www
修改目录权限
chmod 755 sharedir
修改NFS配置文件
vi /etc/exports
/home/sharedir 192.168.2.0(rw,no_root_squash,no_all_squash,sync)
[目录(全目录)] [IP(可填范围,*代表全部)] ([OPTION])
启动NFS
systemctl start nfs
创建pv.yaml
cat > /root/httpd-pv.yaml <
apiVersion: v1
kind: PersistentVolume
metadata:
name: httpd-pv
spec:
capacity:
storage: 1Gi
accessModes:
- ReadWriteOnce
storageClassName: nfs #和pvc.yaml文件保持一致
nfs:
path: /home/sharedir/www
server: 192.168.2.120
EOF
创建pvc.yaml
cat > /root/httpd-pvc.yaml <
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: httpd-pvc
spec:
acce