释放双眼,带上耳机,听听看~!
🤖 由 ChatGPT 生成的文章摘要
错误日志如下:
I0620 07:19:39.552037 1 leaderelection.go:185] attempting to acquire leader lease cephfs/ceph.com-cephfs...
E0620 07:19:39.610071 1 event.go:259] Could not construct reference to: '&v1.Endpoints{TypeMeta:v1.TypeMeta{Kind:"", APIVersion:""}, ObjectMeta:v1.ObjectMeta{Name:"ceph.com-cephfs", GenerateName:"", Namespace:"cephfs", SelfLink:"", UID:"4f4ead7b-c097-4074-b56c-76c6888ceed7", ResourceVersion:"209907", Generation:0, CreationTimestamp:v1.Time{Time:time.Time{wall:0x0, ext:63791306379, loc:(*time.Location)(0x19b4b00)}}, DeletionTimestamp:(*v1.Time)(nil), DeletionGracePeriodSeconds:(*int64)(nil), Labels:map[string]string(nil), Annotations:map[string]string{"control-plane.alpha.kubernetes.io/leader":"{\"holderIdentity\":\"cephfs-provisioner-688cc75-xgd5g_58e8a7a6-f069-11ec-aba4-c627c8b0022e\",\"leaseDurationSeconds\":15,\"acquireTime\":\"2022-06-20T07:19:39Z\",\"renewTime\":\"2022-06-20T07:19:39Z\",\"leaderTransitions\":0}"}, OwnerReferences:[]v1.OwnerReference(nil), Initializers:(*v1.Initializers)(nil), Finalizers:[]string(nil), ClusterName:""}, Subsets:[]v1.EndpointSubset(nil)}' due to: 'selfLink was empty, can't make reference'. Will not report event: 'Normal' 'LeaderElection' 'cephfs-provisioner-688cc75-xgd5g_58e8a7a6-f069-11ec-aba4-c627c8b0022e became leader'
I0620 07:19:39.610143 1 leaderelection.go:194] successfully acquired lease cephfs/ceph.com-cephfs
I0620 07:19:39.610187 1 controller.go:631] Starting provisioner controller ceph.com/cephfs_cephfs-provisioner-688cc75-xgd5g_58e8a7a6-f069-11ec-aba4-c627c8b0022e!
I0620 07:19:39.710456 1 controller.go:680] Started provisioner controller ceph.com/cephfs_cephfs-provisioner-688cc75-xgd5g_58e8a7a6-f069-11ec-aba4-c627c8b0022e!
I0620 07:20:00.618780 1 controller.go:987] provision "default/cephfs-abcdocker" class "cephfs": started
E0620 07:20:00.624863 1 controller.go:1004] provision "default/cephfs-abcdocker" class "cephfs": unexpected error getting claim reference: selfLink was empty, can't make reference
当我们使用ceph csi,已经创建好cephfs并且storageclass也已经创建好了。当pvc通过sc申请pvc时提示的错误。
解决办法:
在Kubernetes 1.24版本之前,可以通过下面的方法解决。but 从1.24.0版本,下面的参数已经不可以使用。
本次使用1.23.5
通过下面的方式解决
#需要在所有apiserver节点(master节点)添加配置文件
[root@k8s-01 ~]# vim /etc/kubernetes/manifests/kube-apiserver.yaml
#添加参数
- --feature-gates=RemoveSelfLink=false
apiserver组件为静态Pod,更改完配置文件后会自动重启Apiserver
修改完所有apiserver节点,需要检查节点是否有异常。建议一台一台修改
[root@k8s-01 ~]# kubectl get pod -n kube-system |grep api
kube-apiserver-k8s-01 1/1 Running 0 5m15s
kube-apiserver-k8s-02 1/1 Running 0 38s
kube-apiserver-k8s-03 1/1 Running 0 17s
1.24以上的版本可以采用替换镜像的方式
将nfs镜像替换为gcr.io/k8s staging sig-storage/nfs-subdir external provisioner:v4.0.0
gcr.io/k8s staging sig-storage/nfs-subdir external provisioner:v4.0.0