使用helm安装NFS-Client Provisioner实现动态存储

需要使用NFS创建动态pv,之前查到的都是这个https://github.com/kubernetes-retired/external-storage/tree/master/nfs-client,后来实验了不可以,是因为版本更新了,插件的项目换为https://github.com/helm/charts/tree/master/stable/nfs-client-provisioner了,特此记录

k8s版本: v1.23.1

  1. 准备:

    • 搭建好NFS服务;
    • 安装好helm
  2. 安装:

    #添加helm源
    helm repo add nfs-subdir-external-provisioner https://kubernetes-sigs.github.io/nfs-subdir-external-provisioner
    
    #直接安装(10.1.129.86为NFS地址,/data/nfs-ops为共享的目录)
    helm install nfs-subdir-external-provisioner nfs-subdir-external-provisioner/nfs-subdir-external-provisioner \
        --set nfs.server=10.1.129.86 \
        --set nfs.path=/data/nfs-ops \
        -n kube-ops (可以选择安装的namespace)
    
    #查看创建的sc
    kubectl get sc -n kube-ops
    

    如果想改的参数更多些,可以下载chartvalues.yaml

    #下载chart
    helm pull nfs-subdir-external-provisioner/nfs-subdir-external-provisioner
    
    #解压后可以看到values.yaml
    cat values.yaml | egrep -v '#|^$'
    
    #####
    replicaCount: 1
    strategyType: Recreate
    image:
      repository: k8s.gcr.io/sig-storage/nfs-subdir-external-provisioner
      tag: v4.0.2
      pullPolicy: IfNotPresent
    imagePullSecrets: []
    nfs:
      server: 10.1.129.86	#修改为NFS服务地址
      path: /data/nfs-ops	#修改共享目录地址
      mountOptions:
      volumeName: nfs-subdir-external-provisioner-root
      reclaimPolicy: Retain
    storageClass:
      create: true
      defaultClass: false
      name: sc-nfs-ops	#修改sc的名字
      allowVolumeExpansion: true
      reclaimPolicy: Delete
      archiveOnDelete: true
      onDelete:
      pathPattern:
      accessModes: ReadWriteOnce
      annotations: {}
    leaderElection:
      enabled: true
    rbac:
      create: true
    podSecurityPolicy:
      enabled: false
    podAnnotations: {}
    podSecurityContext: {}
    securityContext: {}
    serviceAccount:
      create: true
      annotations: {}
      name:
    resources: {}
    nodeSelector: {}
    tolerations: []
    affinity: {}
    labels: {}
    
    #####
    #就修改了上面3处参数后安装
    helm install sc-nfs-ops nfs-subdir-external-provisioner/nfs-subdir-external-provisioner -f values.yaml -n kube-ops
    
上一篇:redis分析系列之set命令


下一篇:HiveSQL高级进阶10大技巧