Kubernetes 创建 pvc error getting claim reference: selfLink was empty, can‘t make refere,kubernetes 1.

Kubernetes 创建 pvc error getting claim reference: selfLink was empty, can‘t make refere

nfs插件报错误日志如下:

I0517 12:05:38.865404       1 leaderelection.go:156] attempting to acquire leader lease...
I0517 12:05:38.912969       1 leaderelection.go:178] successfully acquired lease to provision for pvc default/pvc-sc
I0517 12:05:38.913107       1 controller.go:1167] scheduleOperation[provision-default/pvc-sc[a75c71c6-f313-44d3-8fb6-ce67deabc651]]
E0517 12:05:38.926057       1 controller.go:853] Unexpected error getting claim reference to claim "default/pvc-sc": selfLink was empty, can't make reference

找了找资料发现,kubernetes 1.20版本 禁用了 selfLink。

解决方法1:

资料连接:
https://*.com/questions/65376314/kubernetes-nfs-provider-selflink-was-empty
https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner/issues/25

当前的解决方法是编辑/etc/kubernetes/manifests/kube-apiserver.yaml
在这里:

spec:
  containers:
  - command:
    - kube-apiserver
      添加这一行:
- --feature-gates=RemoveSelfLink=false

然后应用它,即可

kubectl apply -f /etc/kubernetes/manifests/kube-apiserver.yaml

解决方法2:

如果是二进制安装的kubernetes集群,可以直接修改kube-apiserver文件,然后重启

vim /etc/systemd/system/kube-apiserver.service
[Unit]
Description=Kubernetes API Server
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
After=network.target

[Service]
ExecStart=/opt/kube/bin/kube-apiserver \
  --advertise-address=192.168.40.199 \
  --allow-privileged=true \
  --anonymous-auth=false \
  --api-audiences=api,istio-ca \
  --authorization-mode=Node,RBAC \
  --bind-address=192.168.40.199 \
  --client-ca-file=/etc/kubernetes/ssl/ca.pem \
  --endpoint-reconciler-type=lease \
  --etcd-cafile=/etc/kubernetes/ssl/ca.pem \
  --etcd-certfile=/etc/kubernetes/ssl/kubernetes.pem \
  --etcd-keyfile=/etc/kubernetes/ssl/kubernetes-key.pem \
  --etcd-servers=https://192.168.40.199:2379,https://192.168.40.207:2379,https://192.168.40.209:2379 \
  --kubelet-certificate-authority=/etc/kubernetes/ssl/ca.pem \
  --kubelet-client-certificate=/etc/kubernetes/ssl/kubernetes.pem \
  --kubelet-client-key=/etc/kubernetes/ssl/kubernetes-key.pem \
  --secure-port=6443 \
  --service-account-issuer=https://kubernetes.default.svc \
  --service-account-signing-key-file=/etc/kubernetes/ssl/ca-key.pem \
  --service-account-key-file=/etc/kubernetes/ssl/ca.pem \
  --service-cluster-ip-range=10.68.0.0/16 \
  --service-node-port-range=30000-32767 \
  --tls-cert-file=/etc/kubernetes/ssl/kubernetes.pem \
  --tls-private-key-file=/etc/kubernetes/ssl/kubernetes-key.pem \
  --requestheader-client-ca-file=/etc/kubernetes/ssl/ca.pem \
  --requestheader-allowed-names= \
  --requestheader-extra-headers-prefix=X-Remote-Extra- \
  --requestheader-group-headers=X-Remote-Group \
  --requestheader-username-headers=X-Remote-User \
  --proxy-client-cert-file=/etc/kubernetes/ssl/aggregator-proxy.pem \
  --proxy-client-key-file=/etc/kubernetes/ssl/aggregator-proxy-key.pem \
  --enable-aggregator-routing=true \
  --feature-gates=RemoveSelfLink=false \
  --v=2
Restart=always
RestartSec=5
Type=notify
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target




重新加载kube-apiserver.service

systemctl daemon-reload && systemctl restart kube-apiserver

重新删除一下nfs插件,观察日志,直到日志显示如下,即为成功

[root@master1-192-168-40-199 ~]# kubectl  logs -n kube-system nfs-provisioner-01-574d6c4db6-nbfdw
I0517 12:06:33.573502       1 controller.go:492] Starting provisioner controller 52712073-b708-11eb-804e-86e1c009f86c!
I0517 12:06:33.602105       1 controller.go:1167] scheduleOperation[lock-provision-default/pvc-sc[a75c71c6-f313-44d3-8fb6-ce67deabc651]]
I0517 12:06:33.639435       1 leaderelection.go:156] attempting to acquire leader lease...
I0517 12:06:48.602638       1 controller.go:1167] scheduleOperation[lock-provision-default/pvc-sc[a75c71c6-f313-44d3-8fb6-ce67deabc651]]
I0517 12:06:50.264165       1 leaderelection.go:178] successfully acquired lease to provision for pvc default/pvc-sc
I0517 12:06:50.264748       1 controller.go:1167] scheduleOperation[provision-default/pvc-sc[a75c71c6-f313-44d3-8fb6-ce67deabc651]]
I0517 12:06:50.281135       1 controller.go:900] volume "pvc-a75c71c6-f313-44d3-8fb6-ce67deabc651" for claim "default/pvc-sc" created
I0517 12:06:50.298751       1 controller.go:917] volume "pvc-a75c71c6-f313-44d3-8fb6-ce67deabc651" for claim "default/pvc-sc" saved
I0517 12:06:50.298796       1 controller.go:953] volume "pvc-a75c71c6-f313-44d3-8fb6-ce67deabc651" provisioned for claim "default/pvc-sc"
I0517 12:06:52.282891       1 leaderelection.go:198] stopped trying to renew lease to provision for pvc default/pvc-sc, task succeeded

上一篇:kube-controller-manager源码分析-PV controller分析


下一篇:【asp.net core 系列】15 自定义Identity