pvc相关
创建pvc时如下:
一直pengding
[root@k8s-master-1 test]# kubectl get pvc -n test -o wide
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE VOLUMEMODE
nginx-disk Pending managed-nfs-storage 28s Filesystem
[root@k8s-master-1 test]# kubectl describe pvc nginx-disk -n test
Name: nginx-disk
Namespace: test
StorageClass: managed-nfs-storage
Status: Pending
Volume:
Labels: <none>
Annotations: volume.beta.kubernetes.io/storage-provisioner: my/provisioner
volume.kubernetes.io/storage-provisioner: my/provisioner
Finalizers: [kubernetes.io/pvc-protection]
Capacity:
Access Modes:
VolumeMode: Filesystem
Used By: <none>
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal ExternalProvisioning 14s (x3 over 40s) persistentvolume-controller waiting for a volume to be created, either by external provisioner "my/provisioner" or manually created by system administrator
解决
修改apiserver的配置
[root@k8sm storage]# vim /etc/kubernetes/manifests/kube-apiserver.yaml
apiVersion: v1
···
- --tls-private-key-file=/etc/kubernetes/pki/apiserver.key
- --feature-gates=RemoveSelfLink=false # 添加这个配置
重启下kube-apiserver.yaml
[root@k8sm manifests]# kubectl apply -f kube-apiserver.yaml
[root@k8sm storage]# kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
my-pvc Bound pvc-ae9f6d4b-fc4c-4e19-8854-7bfa259a3a04 1Mi RWX example-nfs 13m
重启
systemctl restart kubelet
再查看正常了
原因
就正常了,查了下为什么?
因为原来是1.20版本(我的是1.23.4)默认禁止使用selfLink。
哦,那啥事selfLink?
selfLink:通过API访问资源自身的URL,例如一个Pod的link可能是/api/v1/namespaces/ns36aa8455/pods/sc-cluster-test-1-6bc58d44d6-r8hld