Rancher 2:添加 NFS client provisioner 动态提供 Kubernetes 后端存储卷

一、前提说明

1、说明:

NFS client provisioner 利用 NFS Server 给 Kubernetes 作为持久存储的后端,并且动态提供PV。

默认 rancher 2 的存储类中的提供者不包含NFS,需要手动添加。

 

2、前提:

1)安装好 nfs server(172.31.49.9 ),并分享目录(k8snfs_test)

2)安装有 helm 的 master 主机上安装 git

yum install -y git

3)安装rpcbind

yum install -y rpcbind
systemctl enable rpcbind
systemctl start rpcbind

 

二、安装 nfs-client-provisioner

参考:https://github.com/helm/charts/tree/master/stable/nfs-client-provisioner

在安装 helm 的主机上操作:

git clone https://github.com/helm/charts.git
cd charts/
helm install stable/nfs-client-provisioner --set nfs.server=172.31.49.9 --set nfs.path=/k8snfs_test

执行结果如下:

nfs client 会以容器的形式运行。同时在集群的存储类中创建了 nfs-client 类

 

三、验证

1、启动一个 pod,添加存储卷(创建新的 PV,存储类选择 nfs-client,保存)。

2、然后填写PVC卷名,容器路径。

3、进入容器,创建一个测试文件

4、进入 NFS server 中查看分享的 k8snfs_test 目录可看到自动创建了持久卷目录。

[root@DL-Dev4-49-9 k8snfs_test]# ll
total 4
drwxrwxrwx 2 root root 4096 Jun 21 15:42 default-pvc-g55h2-pvc-a002261e-93f7-11e9-a843-025f44ec7002
[root@DL-Dev4-49-9 k8snfs_test]# 
[root@DL-Dev4-49-9 k8snfs_test]# ll default-pvc-g55h2-pvc-a002261e-93f7-11e9-a843-025f44ec7002/
total 0
-rw-r--r-- 1 root root 0 Jun 21 15:42 111.txt

5、在rancher的持久卷中也可以看到该持久卷

 

四、NFS性能调整

Linux nfs客户端对于同时发起的NFS请求数量进行了控制,若该参数配置较小会导致IO性能较差,请查看该参数:

cat /proc/sys/sunrpc/tcp_slot_table_entries

默认编译的内核该参数最大值为256,可适当提高该参数的值来取得较好的性能,请以root身份执行以下命令:

echo "options sunrpc tcp_slot_table_entries=128" > /etc/modprobe.d/sunrpc.conf
echo "options sunrpc tcp_max_slot_table_entries=128" > /etc/modprobe.d/sunrpc.conf
sysctl -w sunrpc.tcp_slot_table_entries=128

修改完成后,您需要重新挂载文件系统或重启机器。

 

参考:

https://yq.aliyun.com/articles/501417
https://github.com/helm/charts/tree/master/stable/nfs-client-provisioner

 

转载于:https://www.cnblogs.com/weavepub/p/11065040.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值