Rancher v2.5.11 如何部署一套可用的 nfs-client-provisioner

我的rancher部署好了跑了不少测试应用,
现在是要部署一套rabbitmq集群,用到了storageclass。我们使用nfs-client-provisioner提供相关服务;
相关yaml如下:

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
   name: managed-nfs-storage
provisioner: kyle-nfs-client-provisioner  # or choose another name, must match deployment's env PROVISIONER_NAME'
parameters:
  archiveOnDelete: "false"
  pathPattern: "\${.PVC.namespace}/${.PVC.annotations.nfs.io/storage-path}"

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nfs-client-provisioner
  labels:
    app: nfs-client-provisioner
  namespace: sp-poc
spec:
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: nfs-client-provisioner
  template:
    metadata:
      labels:
        app: nfs-client-provisioner
    spec:
      serviceAccountName: nfs-client-provisioner
      containers:
        - name: nfs-client-provisioner
          image: quay.io/external_storage/nfs-client-provisioner:latest
          imagePullPolicy: IfNotPresent
          volumeMounts:
            - name: nfs-client-root
              mountPath: /persistentvolumes
          env:
            - name: PROVISIONER_NAME
              value: kyle-nfs-storageclass
            - name: NFS_SERVER
              value: 10.230.3.7
            - name: NFS_PATH
              value: /sp-poc-share-files
      volumes:
        - name: nfs-client-root
          nfs:
            server: 10.230.3.7
            path: /sp-poc-share-files

\# replace with namespace where provisioner is deployed
  namespace: sp-poc
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: nfs-client-provisioner-runner
rules:
  - apiGroups: [""]
    resources: ["nodes"]
    verbs: ["get", "list", "watch"]
  - apiGroups: [""]
    resources: ["persistentvolumes"]
    verbs: ["get", "list", "watch", "create", "delete"]
  - apiGroups: [""]
    resources: ["persistentvolumeclaims"]
    verbs: ["get", "list", "watch", "update"]
  - apiGroups: ["storage.k8s.io"]
    resources: ["storageclasses"]
    verbs: ["get", "list", "watch"]
  - apiGroups: [""]
    resources: ["events"]
    verbs: ["create", "update", "patch"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: run-nfs-client-provisioner
subjects:
  - kind: ServiceAccount
    name: nfs-client-provisioner
    \# replace with namespace where provisioner is deployed
    namespace: sp-poc
roleRef:
  kind: ClusterRole
  name: nfs-client-provisioner-runner
  apiGroup: rbac.authorization.k8s.io
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: leader-locking-nfs-client-provisioner
  \# replace with namespace where provisioner is deployed
  namespace: sp-poc
rules:
  - apiGroups: [""]
    resources: ["endpoints"]
    verbs: ["get", "list", "watch", "create", "update", "patch"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: leader-locking-nfs-client-provisioner
  # replace with namespace where provisioner is deployed
  namespace: sp-poc
subjects:
  - kind: ServiceAccount
    name: nfs-client-provisioner
    # replace with namespace where provisioner is deployed
    namespace: sp-poc
roleRef:
  kind: Role
  name: leader-locking-nfs-client-provisioner
  apiGroup: rbac.authorization.k8s.io

上面的yaml执行完了,也没有报错
kubectl get pod -n sp-poc检车也没有问题
创建的test-pvc如下:

apiVersion: v1
metadata:
  name: test-claim
  namespace: sp-poc
  annotations:
    volume.beta.kubernetes.io/storage-class: "managed-nfs-storage"
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 1Mi

执行以后,这个Pvc一直处于pending状态。
网络的解决方案,添加SelfLink也加过,修改集群的yaml

   kube-api:
      always_pull_images: false
      extra_args:
        feature-gates: RemoveSelfLink=false

接下来实在不知道要怎么弄了。 因为我们的服务器是离线的,不可出网。所以在线的解决方案就不能用了。

你的业务集群用的是什么啊?rancher 自定义创建的集群,还是K3s 或导入的?

还有你的下游集群版本是什么?最好按照提交话题的模板去填写。

还有你的具体报错信息是什么?

按照官方文档自建的rancher,没有用到 k3s或者导入;
不太明白你说的下游集群版本是什么, nfs-client-provisionser是最新版,
具体报错就是这样:
0/3 nodes are available: 3 pod has unbound immediate PersistentVolumeClaims.
和:
waiting for a volume to be created, either by external provisioner “kyle-nfs-client-provisioner” or manually created by system administrator

其中“kyle-nfs-client-provisioner” 这个是我nfs-client-provisioner 是参数: PROVISIONER_NAME 的名称

现在问题已解决;之前我使用的 storageclass 动态存储镜像是 registry.cn-hangzhou.aliyuncs.com/open-ali/nfs-client-provisioner:latest 但是这个版本同事说太老 了; 更换了一个其他的镜像就好了;换成了;nfs-subdir-external-provisioner