Rancher对接NFS

简介

在rancher部署的k8s集群上,使用NFS存储对接k8s storage class

环境

  • Rancher: v2.4.5
  • Kubernetes: v1.18.6

安装

在NFS节点安装nfs相关软件包

1
2
3
4
5
## CentOS7/8
yum install -y nfs-utils

## ubuntu
apt install -y nfs-kernel-server

设置NFS挂载配置

1
echo '/nfs/   172.16.0.0/16(rw,sync,no_subtree_check,no_root_squash)' >> /etc/exports

创建NFS目录

1
mkdir /nfs

启动NFS

1
2
systemctl start rpcbind
systemctl start nfs-server

验证

其他节点下载客户端工具包

1
2
3
4
5
## CentOS7/8
yum install nfs-utils

## ubuntu
apt install -y nfs-common

查看挂载路径

1
2
3
# showmount -e 172.16.0.195
Export list for 172.16.0.195:
/nfs 172.16.0.0/16

挂载NFS

1
2
3
4
## 挂载
mount -t nfs 172.16.0.195:/nfs /mnt
## 写入数据,查看nfs是否有写入成功
touch /mnt/test

Rancher对接NFS

前提

  • 已安装好kubernetes环境
  • 所有worker节点已安装nfs客户端工具

配置应用商店

全局->工具->商店设置,开启“Helm”应用商店

catalog-1

启动nfs-client-provisioner

添加两个应答:

选项 参数· 说明
nfs.server 172.16.0.195 NFS服务器IP地址
nfs.path /path NFS挂载路径

catalog-2

设置好之后点击启动,查看应用状态

catalog-3

查看存储类

sc-1

验证NFS

创建工作负载,添加PVC

pvc-1

选择nfs存储类

pvc-2

设置挂载路径

pvc-3

进入pod,touch一个文件

cli-1

nfs服务器上查看该文件

cli-2