本次实验使用最简单的方式NFS来配置一个通过挂载共享存储的WEB项目;
两台机器:
kubernetes:192,168.0.199
nfs: 192.168.0.218
由于kubernetes还是之前的实验机器,所以就直接弄好NFS服务器先;
nfs服务器操作:
- yum install rpcbind nfs-utils -y
- mkdir -p /data/www-data
添加共享目录配置:
- cat >/etc/exports<<-EOF
- /data/www-data 192.168.0.0/24(rw,sync)
- EOF
添加到开机启动:
- chkconfig rpcbind on
- chkconfig nfs on
- service nfs start
- service rpcbind start
检查一下配置:
- [root@nfs ~]# exportfs
- /data/www-data 192.168.0.0/24
再回到kubernetess机器上要安装一个包:
- yum install nfs-utils -y
完成后就可以用命令检查nfs目享的目录了;
- [root@node5 ~]# showmount -e 192.168.0.218
- Export list for 192.168.0.218:
- /data/www-data 192.168.0.0/24
尝试挂载一下;
- [root@node5 ~]# mount 192.168.0.218:/data/www-data /mnt
- [root@node5 ~]# ls /mnt
- index.html