基于helm部署并配置StorageClass

此类方法适用于测试环境或者小型的集群环境,因为nfs是网络文件系统,在io性能上并不能有所保证。

前置条件:

  • 已部署k8s集群
  • 已安装helm 工具

step1: 安装nfs服务

yum install nfs-utils -y

step2: 配置nfs

# 编辑/etc/exports
/data/nfs *(rw,sync,no_subtree_check,no_root_squash)

step3: 重启nfs-server

# 启动服务
systemctl start nfs-server
# 开启自启
systemctl enable nfs-server

step4: 所有节点安装nfs客户端

yum install nfs-utils -y

step:5 部署nfs-sc

# 添加nfs的helm源
helm repo add nfs-provisioner https://kubernetes-sigs.github.io/nfs-subdir-external-provisioner
# 创建nfs的命名空间
kubectl create ns nfs
# 部署nfs服务
helm install nfs-subdir-external-provisioner nfs-provisioner/nfs-subdir-external-provisioner \
--set nfs.server=172.22.100.16  \
--set nfs.path=/data/nfs \
-n nfs 

step6: 指定默认sc

kubectl patch storageclass nfs-client -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'

接下来就可以愉快的使用啦…

你可能感兴趣的:(k8s,helm,nfs,storageclass,sc)