k8s默认StorageClass,解决pvc一直处于“Pending”
K8S 中动态(StorageClass)创建 PVC 时 SelfLink 问题解决
报错详情
排查思路
查看 pvc 详细属性
[root@k8s-master01 /opt/zadig]# kubectl describe pvc pvc-sc
Name: pvc-sc
Namespace: default
StorageClass: nfs-yinwu
Status: Pending
Volume:
Labels: <none>
Annotations: control-plane.alpha.kubernetes.io/leader:
{"holderIdentity":"2fc2f72f-aac9-11ed-ba5e-6a561503df2c","leaseDurationSeconds":15,"acquireTime":"2023-02-12T11:35:01Z","renewTime":"2023-...
volume.beta.kubernetes.io/storage-provisioner: nfs-provisioner-01
volume.kubernetes.io/storage-provisioner: nfs-provisioner-01
Finalizers: [kubernetes.io/pvc-protection]
Capacity:
Access Modes:
VolumeMode: Filesystem
Used By: <none>
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal ExternalProvisioning 3m5s (x25 over 4m11s) persistentvolume-controller waiting for a volume to be created, either by external provisioner "nfs-provisioner-01" or manually created by system administrator
persistentvolume-controller waiting for a volume to be created, either by external provisioner "nfs-provisioner-01" or manually created by system administrator
从persistentvolume-controller反馈出来的信息是 没有权限来创建出pvc。
查看 nfs-provisioner pod日志
远程NFS服务器上的动态子目录卷预配器: https://github.com/kubernetes-retired/external-storage/tree/master/nfs
Unexpected error getting claim reference to claim "default/pvc-sc": selfLink was empty, can't make reference
注:
Kubernetes 1.20及以后版本废弃了 selfLink 所致。
相关issue链接:https://github.com/kubernetes/kubernetes/pull/94397
解决方案
修改 /etc/kubernetes/manifests/kube-apiserver.yaml
,添加 - --feature-gates=RemoveSelfLink=false
后重启apiserver,及替换nfs-provisioner镜像文件(末尾会+链接),接着进行重试创建,又发现如下的新报错信息.
4 pod has unbound immediate PersistentVolumeClaims
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning FailedScheduling 24s (x6 over 7m26s) default-scheduler 0/4 nodes are available: 4 pod has unbound immediate PersistentVolumeClaims.
需要设置k8s默认的sc
kubectl patch storageclass nfs-yinwu -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
再次尝试创建正常!
附:
ccr.ccs.tencentyun.com/kason/nfs-subdir-external-provisioner:v4.0.0
更多推荐
所有评论(0)