## nfs ### 配置 ```bash ## 安装依赖 $ yum install -y nfs-utils rpcbind ## 修改配置 $ cat /etc/exports /opt/data/nfs 66.94.121.23/32(ro,sync,no_root_squash) 66.94.125.0/24(ro,sync,no_root_squash) ## 启动服务 $ systemctl enable rpcbind && systemctl enable nfs $ systemctl restart rpcbind && systemctl restart nfs ## 查看nfs $ systemctl status nfs $ showmount -e Export list for test-opsbase-k8s-66-94-121-23: /opt/data/nfs 66.94.125.0/24,66.94.121.23/32 ## 挂载nfs $ mount -t nfs -o rw,async 66.94.121.23:/opt/data/nfs /data/nfs/ ``` ### nfs.yml ```bash ## 管理员创建资源 $ kubectl create -f nfs-pv.yml ## 用户申请pv资源 $ kubectl create -f nfs-pvc.yml ## 查看pv/pvc $ kubectl get pv,pvc -n test ## pod 挂载pvc资源 $ kubectl apply -f storage/nginx-nfs.yml $ kubectl -n test exec -it nginx-nfs-test-xxx -- df|grep -A 1 nfs 66.94.121.23:/opt/data/nfs 411706368 58967040 331802624 15% /usr/share/nginx/html ## 测试 $ echo 'ok' > /opt/data/nfs/index.html $ curl 10.244.2.227 # nginx pod ```