kubesphere 添加nfs 存储支持

添加Helm存储库

helm repo add azure http://mirror.azure.cn/kubernetes/charts
helm search repo nfs-client-provisioner

helm install nfs-storage azure/nfs-client-provisioner --set nfs.server=172.22.0.12 --set nfs.path=/data/nfs --set storageClass.name=nfs-storage --set storageClass.defaultClass=true --kubeconfig=/root/.kube/admin.conf

ING: This chart is deprecated
NAME: nfs-storage
LAST DEPLOYED: Wed Jan 11 16:06:36 2023
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None

[root@node01 ~]# cat pvc-hbtest.yaml

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
namespace: hb-test
name: pvc-hbtest
spec:
storageClassName: "nfs-storage"
accessModes:
- ReadWriteMany
resources:
requests:
storage: 100Mi

kubectl  apply  -f    pvc-hbtest.yaml     --kubeconfig=/root/.kube/admin.conf

[root@node01 ~]# kubectl get pv --kubeconfig=/root/.kube/admin.conf
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
pvc-18cfde21-f4b5-4bc7-b9ff-e92a273b88c9 100Mi RWX Delete Bound hb-test/pvc-hbtest nfs-storage 13m
pvc-574e4524-a8a9-46c2-8ad0-a2e838c47e4e 20Gi RWO Delete Bound kubesphere-monitoring-system/prometheus-k8s-db-prometheus-k8s-0 local 110d
pvc-7b35cdd3-aa92-47ac-a126-76d0dbe621c8 2Gi RWO Delete Bound rich-cq/minio local 104d
pvc-814bf3b8-5512-4bc5-b758-d2fb52a2d803 10Mi RWX Delete Bound default/pvc-test nfs-storage 59m

nginx的静态文件目录,映射到nfs的 pvc目录。

报错处理:

问题:在k8s 1.21.0版本使用NFS作为StorageClass,实现PV动态供给。但PVC一直是pending状态,Pod也无法运行

错误: Normal ExternalProvisioning 13s (x24 over 5m43s) persistentvolume-controller waiting for a volume to be created,
either by external provisioner "cluster.local/nfs-clife-pr-nfs-client-provisioner" or manually created by system administrator

原因:selfLink was empty 在k8s集群 v1.20之前都存在,在v1.20之后被删除
解决:需要在/etc/kubernetes/manifests/kube-apiserver.yaml 添加参数

[root@k8s-matser01 nfs.rbac]# cat /etc/kubernetes/manifests/kube-apiserver.yaml
apiVersion: v1
···
- --tls-private-key-file=/etc/kubernetes/pki/apiserver.key
- --feature-gates=RemoveSelfLink=false # 添加这个配置
然后再次查看deploy,pod,pvc,都会部署成功
kubectl get deploy,pod,pvc,sc,pv

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值