在k8s下配置 nfs,k8s版本 1.21.1。会遇到 “unexpected error getting claim reference: selfLink was empty“ 的问题,在GitHub上 有关于这个问题的讨论以及解决方法 https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner/issues/25

nfs provision 配置文件,网上的k8s版本比较老,nfs启动会报错。

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nfs-client-provisioner
  labels:
    app: nfs-client-provisioner
  # replace with namespace where provisioner is deployed
  namespace: default  #与RBAC文件中的namespace保持一致
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nfs-client-provisioner
  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: registry.cn-beijing.aliyuncs.com/mydlq/nfs-subdir-external-provisioner:v4.0.0
          volumeMounts:
            - name: nfs-client-root
              mountPath: /persistentvolumes
          env:
            - name: PROVISIONER_NAME
              value: qgg-nfs-storage  #provisioner名称,请确保该名称与 nfs-StorageClass.yaml文件中的provisioner名称保持一致
            - name: NFS_SERVER
              value: 10.91.1.80  #NFS Server IP地址
            - name: NFS_PATH  
              value: /opt2/nfs   #NFS挂载卷
      volumes:
        - name: nfs-client-root
          nfs:
            server: 10.91.1.80  #NFS Server IP地址
            path: /opt2/nfs     #NFS 挂载卷

参考了这篇文章,步骤是一样的,这里需要更新用最新版本的NFS Provisioner。

https://blog.zuolinux.com/2020/06/10/nfs-client-provisioner.html

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐