kubernetes 使用NFS挂载共享存储的容器(一)

来源:互联网 发布:http的默认端口 编辑:程序博客网 时间:2024/06/08 10:25

本次实验使用最简单的方式NFS来配置一个通过挂载共享存储的WEB项目;

两台机器:

kubernetes:192,168.0.199

nfs: 192.168.0.218  

由于kubernetes还是之前的实验机器,所以就直接弄好NFS服务器先;

nfs服务器操作: 

  1. yum install rpcbind nfs-utils -y 
  2. mkdir -p /data/www-data 

添加共享目录配置: 

  1. cat >/etc/exports<<-EOF 
  2. /data/www-data  192.168.0.0/24(rw,sync) 
  3. EOF 

添加到开机启动: 

  1. chkconfig rpcbind on 
  2. chkconfig nfs on 
  3.  
  4. service nfs start  
  5. service rpcbind start 

 检查一下配置: 

  1. [root@nfs ~]# exportfs 
  2. /data/www-data  192.168.0.0/24 

 再回到kubernetess机器上要安装一个包: 

  1. yum install nfs-utils -y 
 完成后就可以用命令检查nfs目享的目录了;
 
  1. [root@node5 ~]# showmount -e 192.168.0.218 
  2. Export list for 192.168.0.218
  3. /data/www-data    192.168.0.0/24 
 尝试挂载一下;
 
  1. [root@node5 ~]# mount 192.168.0.218:/data/www-data /mnt 
  2. [root@node5 ~]# ls /mnt 
  3. index.html
  1. 注:做nfs实验的时候,从客户端访问服务器报错,提示:clnt_create: RPC: Program not registered

    解决办法: 按顺序重启

              /etc/init.d/rpcbind restart

              /etc/init.d/nfs restart