当前位置:   article > 正文

在K8S中使用NFS_resource mapping not found for name: "nfs-client-p

resource mapping not found for name: "nfs-client-provisioner-runner" namespa

PS:

因为 原来是1.20版本默认禁止使用selfLink。 所以后续版本需要在kube-apiserver.yaml后面增加  - --feature-gates=RemoveSelfLink=false

最好解决方案: https://blog.csdn.net/joker_zhou/article/details/125478979

基本流程简单: 

1. 首先在客户端按照nfs 服务..这个网上一堆不介绍了,

2. 创建一个命名空间 (kubectl create namespace xxxx)

3. 创建rbac  (rbac.yaml)

4. 创建nfs的provisioner (deployment.yaml)

5. 创建StorageClass (storageClass.yaml)

6. 在PVC使用storageClass即可 (pvc.yaml)

rbac.yaml

  1. apiVersion: v1
  2. kind: ServiceAccount
  3. metadata:
  4. name: nfs-client-provisioner
  5. # replace with namespace where provisioner is deployed
  6. namespace: hello-storageclass
  7. ---
  8. kind: ClusterRole
  9. apiVersion: rbac.authorization.k8s.io/v1
  10. metadata:
  11. name: nfs-client-provisioner-runner
  12. rules:
  13. - apiGroups: [""]
  14. resources: ["persistentvolumes"]
  15. verbs: ["get", "list", "watch", "create", "delete"]
  16. - apiGroups: [""]
  17. resources: ["persistentvolumeclaims"]
  18. verbs: ["get", "list", "watch", "update"]
  19. - apiGroups: ["storage.k8s.io"]
  20. resources: ["storageclasses"]
  21. verbs: ["get", "list", "watch"]
  22. - apiGroups: [""]
  23. resources: ["events"]
  24. verbs: ["create", "update", "patch"]
  25. ---
  26. kind: ClusterRoleBinding
  27. apiVersion: rbac.authorization.k8s.io/v1
  28. metadata:
  29. name: run-nfs-client-provisioner
  30. subjects:
  31. - kind: ServiceAccount
  32. name: nfs-client-provisioner
  33. # replace with namespace where provisioner is deployed
  34. namespace: hello-storageclass
  35. roleRef:
  36. kind: ClusterRole
  37. name: nfs-client-provisioner-runner
  38. apiGroup: rbac.authorization.k8s.io
  39. ---
  40. kind: Role
  41. apiVersion: rbac.authorization.k8s.io/v1
  42. metadata:
  43. name: leader-locking-nfs-client-provisioner
  44. # replace with namespace where provisioner is deployed
  45. namespace: hello-storageclass
  46. rules:
  47. - apiGroups: [""]
  48. resources: ["endpoints"]
  49. verbs: ["get", "list", "watch", "create", "update", "patch"]
  50. ---
  51. kind: RoleBinding
  52. apiVersion: rbac.authorization.k8s.io/v1
  53. metadata:
  54. name: leader-locking-nfs-client-provisioner
  55. # replace with namespace where provisioner is deployed
  56. namespace: hello-storageclass
  57. subjects:
  58. - kind: ServiceAccount
  59. name: nfs-client-provisioner
  60. # replace with namespace where provisioner is deployed
  61. namespace: hello-storageclass
  62. roleRef:
  63. kind: Role
  64. name: leader-locking-nfs-client-provisioner
  65. apiGroup: rbac.authorization.k8s.io

deployment.yaml

  1. apiVersion: apps/v1
  2. kind: Deployment
  3. metadata:
  4. name: nfs-client-provisioner
  5. labels:
  6. app: nfs-client-provisioner
  7. # replace with namespace where provisioner is deployed
  8. namespace: hello-storageclass
  9. spec:
  10. replicas: 1
  11. strategy:
  12. type: Recreate
  13. selector:
  14. matchLabels:
  15. app: nfs-client-provisioner
  16. template:
  17. metadata:
  18. labels:
  19. app: nfs-client-provisioner
  20. spec:
  21. serviceAccountName: nfs-client-provisioner
  22. containers:
  23. - name: nfs-client-provisioner
  24. image: quay.io/external_storage/nfs-client-provisioner:latest
  25. volumeMounts:
  26. - name: nfs-client-root
  27. mountPath: /persistentvolumes
  28. env:
  29. - name: PROVISIONER_NAME
  30. value: fuseim.pri/ifs
  31. #记住这个名字fuseim.pri/ifs 后面要用到
  32. - name: NFS_SERVER
  33. value: 192.168.1.4 #NFS服务器的IP
  34. - name: NFS_PATH
  35. # remote server (192.168.1.4) nfs directory
  36. value: /hddisk/nfsdata/nacos #这里是NFS创建的文件夹目录 需要 777 权限
  37. volumes:
  38. - name: nfs-client-root
  39. nfs:
  40. server: 192.168.1.4 #这个和上面配置一致
  41. path: /hddisk/nfsdata/nacos

storageclass.yaml

  1. kind: StorageClass
  2. apiVersion: storage.k8s.io/v1
  3. metadata:
  4. name: managed-nfs-storage #这个也记住在pvc中使用到
  5. annotations:
  6. kubesphere.io/creator: admin
  7. storageclass.kubesphere.io/support-snapshot: 'false'
  8. provisioner: fuseim.pri/ifs #这个就是deployment.yaml里面让记住的名字
  9. parameters:
  10. archiveOnDelete: 'false'
  11. reclaimPolicy: Delete
  12. volumeBindingMode: Immediate

pvc.yaml

  1. kind: PersistentVolumeClaim
  2. apiVersion: v1
  3. metadata:
  4. name: ks-mavenresp
  5. namespace: p-lms
  6. annotations:
  7. kubesphere.io/alias-name: mysql-data
  8. kubesphere.io/creator: admin
  9. pv.kubernetes.io/bind-completed: 'yes'
  10. pv.kubernetes.io/bound-by-controller: 'yes'
  11. volume.beta.kubernetes.io/storage-provisioner: fuseim.pri/ifs
  12. spec:
  13. accessModes:
  14. - ReadWriteOnce
  15. resources:
  16. requests:
  17. storage: 10Gi
  18. volumeName: pvc-4a1833c6-a922-4824-9236-613329394482
  19. storageClassName: managed-nfs-storage #这里..不用说吧= =storageClassName 很明显了
  20. volumeMode: Filesystem

deployment.yaml

  1. spec:
  2. volumes:
  3. - name: volume-2 #这里起个别名 引用pvc
  4. persistentVolumeClaim:
  5. claimName: ks-mavenresp #pvc名字
  6. containers:
  7. - name: jnlp
  8. image: 'jenkins/jnlp-slave:3.27-1'
  9. command:
  10. - jenkins-slave
  11. args:
  12. - f739d2774efec33b8d0f5cdf8159e35954af289b3f3ce8fbe38d36b3cb16bf46
  13. - maven-nd1fh
  14. volumeMounts:
  15. - name: volume-2 #这里使用pvc
  16. mountPath: /root/.m2

关于在k8s-v1.20以上版本使用nfs作为storageclass出现selfLink was empty, can‘t make reference_w2909526的博客-CSDN博客

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/565508
推荐阅读
相关标签
  

闽ICP备14008679号