helm安装测试nfs-client-provisioner,创建和测试nfs类型的PVC 解决selfLink was empty,

  • A+
所属分类:kubernetes

前提:

  1. 先部署好nfs-server
  2. 已安装helm

添加helm repo:

helm repo add  stable     https://charts.helm.sh/stable
helm search repo nfs

helm pull stable/nfs-client-provisioner --untar
cd nfs-client-provisioner/

vi values.yaml

nfs 配置正确, defaultClass 修改为:true

nfs:
  server: 192.168.132.39
  path: /nas
  mountOptions

  defaultClass: true

安装:

helm install nfs -f ./values.yaml .

查看 storageclassies

kubectl get sc

创建一个测试pvc:

vi pvc.yaml

内容如下:

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: pvc1
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 300Mi
kubectl apply -f pvc.yaml


发现始终处于“Pending”

pvc1 Pending nfs-client 5s

kubectl describe pvc pvc1

Events:
Type Reason Age From Message


Normal ExternalProvisioning 14s persistentvolume-controller waiting for a volume to be created, either by external provisioner “cluster.local/nfs-nfs-client-provisioner” or manually created by system administrator

查看 pod,运行情况:

kubectl get po
kubectl logs pod/nfs-nfs-client-provisioner-7dbc8499cd-s79r6

helm安装测试nfs-client-provisioner,创建和测试nfs类型的PVC 解决selfLink was empty,
1 controller.go:1004] provision “default/pvc1” class “nfs-client”: unexpected error getting claim reference: selfLink was empty, can’t make reference

vi /etc/kubernetes/manifests/kube-apiserver.yaml

lfLink was empty 在k8s集群 v1.20之前都存在,在v1.20之后被删除,需要在/etc/kubernetes/manifests/kube-apiserver.yaml 添加参数
增加 - --feature-gates=RemoveSelfLink=false

spec:
containers:
- command:
    - kube-apiserver
    - --feature-gates=RemoveSelfLink=false
kubectl apply -f /etc/kubernetes/manifests/kube-apiserver.yaml

再次检查PVC,处于“Bound”状态了。

kubectl get pv,pvc

persistentvolumeclaim/pvc1 Bound pvc-97856442-be39-439e-974d-17f323bdc137 300Mi RWO nfs-client 15m

pvc1 Bound pvc-97856442-be39-439e-974d-17f323bdc137 300Mi RWO nfs-client 15m

[the end]

https://cloud.tencent.com/developer/article/1694640

w3cjava