我在kubernetes中使用pv,在绑定pvc的时候,一直不成功,pvc报:
no persistent volumes available for this claim and no storage class is set
我使用的是 nfs-client-provisioner,查看其日志发现
kubectl logs -f nfs-client-provisioner-6449d655d9-hmmgb
报:
I0421 05:56:14.312000 1 controller.go:987] provision "my-space/datadir-kafka-0" class "nfs-storage": started
E0421 05:56:14.322457 1 controller.go:1004] provision "my-space/datadir-kafka-0" class "nfs-storage": unexpected error getting claim reference: selfLink was empty, can't make reference
I0421 05:56:14.331860 1 controller.go:987] provision "my-space/datadir-kafka-1" class "nfs-storage": started
E0421 05:56:14.341974 1 controller.go:1004] provision "my-space/datadir-kafka-1" class "nfs-storage": unexpected error getting claim reference: selfLink was empty, can't make reference
I0421 05:56:14.351496 1 controller.go:987] provision "my-space/datadir-kafka-2" class "nfs-storage": started
E0421 05:56:14.363755 1 controller.go:1004] provision "my-space/datadir-kafka-2" class "nfs-storage": unexpected error getting claim reference: selfLink was empty, can't make reference
kubernetes的版本:v1.20.2
我该如何解决?
报错信息“selfLink was empty”,在官方1.20的变更说明中:
Stop propagating SelfLink (deprecated in 1.16) in kube-apiserver
selfLink在1.16版本以后已经弃用,在1.20版本停用。
而由于nfs-provisioner的实现是基于selfLink功能(同时也会影响其他用到selfLink这个功能的第三方软件),需要等nfs-provisioner的制作方重新提供新的解决方案。
目前可用的临时方案是:
修改
/etc/kubernetes/manifests/kube-apiserver.yaml
文件,找到如下内容后,在最后添加一项参数spec: containers: - command: - kube-apiserver - --advertise-address=192.168.210.20 - --....... #省略多行内容 - --feature-gates=RemoveSelfLink=false #添加此行
如果是高可用的k8s集群,则需要在所有master节点上进行此操作。
添加后需要重启
apiserver
(静态pod默认会重启)。三台apiserver被kubelet重启后,再次查询PVC,可以看到PVC状态都为Bound,可以正常被PV绑定了
你的答案