[root@master k8sfiles]# kubectl describe pvc data-kubia-0 Name: data-kubia-0 Namespace: default StorageClass: managed-nfs-storage Status: Pending Volume: Labels: app=kubia Annotations: volume.beta.kubernetes.io/storage-provisioner: fuseim.pri/ifs Finalizers: [kubernetes.io/pvc-protection] Capacity: Access Modes: VolumeMode: Filesystem Used By: kubia-0 Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal ExternalProvisioning 6s (x10 over 2m2s) persistentvolume-controller waiting for a volume to be created, either by external provisioner "fuseim.pri/ifs" or manually created by system administrator
1 2 3 4 5 6 7 8 9 10 11 12 13
#查看对应pod的日志
[root@master k8sfiles]# kubectl logs -f nfs-client-provisioner-9547dc76b-6g4wj I0819 01:26:01.017938 1 leaderelection.go:185] attempting to acquire leader lease default/fuseim.pri-ifs... E0819 01:26:18.445583 1 event.go:259] Could not construct reference to: '&v1.Endpoints{TypeMeta:v1.TypeMeta{Kind:"", APIVersion:""}, ObjectMeta:v1.ObjectMeta{Name:"fuseim.pri-ifs", GenerateName:"", Namespace:"default", SelfLink:"", UID:"c55af7a2-b250-4c45-9cb2-19aa95610dbf", ResourceVersion:"1083335", Generation:0, CreationTimestamp:v1.Time{Time:time.Time{wall:0x0, ext:63764873777, loc:(*time.Location)(0x1956800)}}, DeletionTimestamp:(*v1.Time)(nil), DeletionGracePeriodSeconds:(*int64)(nil), Labels:map[string]string(nil), Annotations:map[string]string{"control-plane.alpha.kubernetes.io/leader":"{\"holderIdentity\":\"nfs-client-provisioner-9547dc76b-6g4wj_69af896c-008c-11ec-b671-620ce41148af\",\"leaseDurationSeconds\":15,\"acquireTime\":\"2021-08-19T01:26:18Z\",\"renewTime\":\"2021-08-19T01:26:18Z\",\"leaderTransitions\":2}"}, 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' 'nfs-client-provisioner-9547dc76b-6g4wj_69af896c-008c-11ec-b671-620ce41148af became leader' I0819 01:26:18.445645 1 leaderelection.go:194] successfully acquired lease default/fuseim.pri-ifs I0819 01:26:18.445737 1 controller.go:631] Starting provisioner controller fuseim.pri/ifs_nfs-client-provisioner-9547dc76b-6g4wj_69af896c-008c-11ec-b671-620ce41148af! I0819 01:26:18.546716 1 controller.go:680] Started provisioner controller fuseim.pri/ifs_nfs-client-provisioner-9547dc76b-6g4wj_69af896c-008c-11ec-b671-620ce41148af! I0819 01:39:26.997185 1 controller.go:987] provision "default/data-kubia-0" class "managed-nfs-storage": started E0819 01:39:27.006858 1 controller.go:1004] provision "default/data-kubia-0" class "managed-nfs-storage": unexpected error getting claim reference: selfLink was empty, can't make reference I0819 01:41:18.449551 1 controller.go:987] provision "default/data-kubia-0" class "managed-nfs-storage": started E0819 01:41:18.452684 1 controller.go:1004] provision "default/data-kubia-0" class "managed-nfs-storage": unexpected error getting claim reference: selfLink was empty, can't make reference
即pvc在“waiting for a volume to be created”,错误原因则是“selfLink was empty, can’t make reference”。经过搜索得知,原来selfLink已经在k8sv1.20.0及以后的版本上弃用,这里也给出了新的provisioner image:gcr.io/k8s-staging-sig-storage/nfs-subdir-external-provisioner:v4.0.0。但由于gcr.io在大陆访问不便,在上面的yaml文件中,我将其替换成了dockerhub镜像:sunjqv/nfs-subdir-external-provisioner:v4.0.0。
5. 创建Statefulset
在部署Statufulset之前,创建一个用于在有状态的pod之间提供网络标识的headless Service