准备NFS服务192.168.1.244
$ yum -y install nfs-utils rpcbind
$ systemctl start nfs-server rpcbind
$ systemctl enable nfs-server rpcbind
$ mkdir -p /data/k8s
$ cd /data/k8s
$ echo 11111111 > index.html
$ vim /etc/exports
/data/k8s *(rw,async,no_root_squash)
$ systemctl restart nfs-server
$ exportfs -arv
客户端测试,所有k8s节点都要安装nfs客户端
$ yum -y install nfs-utils rpcbind
$ systemctl start nfs rpcbind
$ systemctl enable nfs rpcbind
$ showmount -e 192.168.1.244
创建pod直接挂载nfs服务器
apiVersion: v1 kind: Pod metadata: labels: run: nginx name: podxx spec: volumes: - name: nfs nfs: server: 192.168.1.244 path: /data/k8s containers: - image: nginx name: nginx volumeMounts: - mountPath: /usr/share/nginx/html name: nfs