0%

nfs-client安装

说明

nfs-client的chart已经迁移到https://kubernetes-sigs.github.io/nfs-subdir-external-provisioner/,但是该chart对应的镜像都放在k8s.gcr.io,国内不方便下载.

本文继续使用以前的chart.

安装步骤

  1. 添加repo
helm repo add stable https://charts.helm.sh/stable
  1. 更新repo
helm repo update
  1. 安装nfs-client
# 这里nfs server参考centos nfs安装
helm install nfs  stable/nfs-client-provisioner  --set nfs.server=172.16.100.13 --set nfs.path=/data/nfs
  1. 设置nfs为默认存储
[root@node1 ~]# kubectl get sc
NAME         PROVISIONER                                RECLAIMPOLICY   VOLUMEBINDINGMODE   ALLOWVOLUMEEXPANSION   AGE
nfs-client   cluster.local/nfs-nfs-client-provisioner   Delete          Immediate           true                   30s
[root@node1 ~]# kubectl patch storageclass nfs-client -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
storageclass.storage.k8s.io/nfs-client patched
[root@node1 ~]# kubectl get sc
NAME                   PROVISIONER                                RECLAIMPOLICY   VOLUMEBINDINGMODE   ALLOWVOLUMEEXPANSION   AGE
nfs-client (default)   cluster.local/nfs-nfs-client-provisioner   Delete          Immediate           true                   118s

遇到的问题

k8s-v1.21.5版本安装完nfs-client,创建pvc会一直在pending状态,kubectl logs nfs-client-provisioner后台有报错

unexpected error getting claim reference: selfLink was empty, can't make reference
  1. 临时解决方法:
    编辑/etc/kubernetes/manifests/kube-apiserver.yaml,在这里:
spec:
  containers:
  - command:
    - kube-apiserver

添加这一行:
- --feature-gates=RemoveSelfLink=false

然后应用它,即可

kubectl apply -f /etc/kubernetes/manifests/kube-apiserver.yaml
  1. 解决方案
    参考issue,升级nfs-client-provisioner镜像到v4.0以上版本.
# 一个可用的版本
easzlab/nfs-subdir-external-provisioner:v4.0.1