k8s uses nfs to configure the StorageClass. After the configuration is complete, the creation of pvc is always pending.

background

Use nfs to configure the StorageClass
configuration process:

  1. Configure ServiceAccount
  2. Configure nfs-client-provisioner
  3. Configure StorageClass
  4. Create pvc
    nfs-client-provisioner and StorageClass are created successfully, no error
    reported
    insert image description here

    insert image description here
provision "default/exampleforstorageclass" class "managed-nfs-storage": unexpected error getting claim reference: selfLink was empty, can't make reference

solution

selfLink was empty existed before k8s cluster v1.20, and was deleted after v1.20, you need to /etc/kubernetes/manifests/kube-apiserver.yamladd `- --feature-gates=RemoveSelfLink=false`` in the added parameter

spec:
  containers:
  - command:
    - kube-apiserver
    - --feature-gates=RemoveSelfLink=false

After adding, the cluster deployed with kubeadm will automatically load the deployment pod

kubeadm安装的apiserver是Static Pod,它的配置文件被修改后,立即生效。
Kubelet 会监听该文件的变化,当您修改了 /etc/kubenetes/manifest/kube-apiserver.yaml 文件之后,kubelet 将自动终止原有的 kube-apiserver-{nodename} 的 Pod,并自动创建一个使用了新配置参数的 Pod 作为替代。
如果您有多个 Kubernetes Master 节点,您需要在每一个 Master 节点上都修改该文件,并使各节点上的参数保持一致。

It should be noted here that if the api-server fails to start, it needs to be executed again

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

After configuration, use kubectl get pvc

image-20220623200938804

pvc STATUS becomes Bound

Guess you like

Origin blog.csdn.net/qq_45473439/article/details/125434215