k8s存储类(storageclass)动态创建pv失败

k8s存储类(storageclass)动态创建pv失败

背景:安装kubesphere后发现prometheus的pod创建一直有问题

kubectl get pod -n kubesphere-monitoring-system
.......
prometheus-k8s-0                                   0/2     Pending   0          3h47m
prometheus-k8s-1                                   0/2     Pending   0          3h47m
..........

查看日志报错

pod has unbound immediate PersistentVolumeClaims

查看pvc发现一直是Pending

kubectl get pvc  -n kubesphere-monitoring-system
.........
prometheus-k8s-db-prometheus-k8s-0   Pending              managed-nfs-storage   16h
prometheus-k8s-db-prometheus-k8s-1   Pending              managed-nfs-storage   16h
.........

再查看pv发现没有被自动创建

kubectl get pv -n kubesphere-monitoring-system

查看nfs-client-provisioner日志发现报错

kubectl logs -n storgeclass nfs-client-provisioner-57b584586b-v4xz7
.........
 unexpected error getting claim reference: selfLink was empty, can't make reference
.........

原因:

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

vim /etc/kubernetes/manifests/kube-apiserver.yaml 
spec:
containers:
- command:
   ...........
    - kube-apiserver
    - --feature-gates=RemoveSelfLink=false #添加内容
   ..............
kubectl apply -f /etc/kubernetes/manifests/kube-apiserver.yaml

到此问题解决

你可能感兴趣的:(云原生,kubernetes,docker,云原生,容器)