Skip to main content

local static provisioner

ben.wangzLess than 1 minute

local static provisioner

prepare

  1. k8s is ready
  2. argocd is ready and logged in

installation

  1. prepare local-static-provisioner.yaml
    • apiVersion: argoproj.io/v1alpha1
      kind: Application
      metadata:
        name: local-static-provisioner
      spec:
        syncPolicy:
          syncOptions:
          - CreateNamespace=true
        project: default
        source:
          repoURL: https://kubernetes-sigs.github.io/sig-storage-local-static-provisioner
          chart: local-static-provisioner
          targetRevision: 2.0.0
          helm:
            releaseName: local-static-provisioner
            values: |
              rbac:
                create: true
              serviceAccount:
                create: true
              setPVOwnerRef: true
              mountDevVolume: false
              image: registry.k8s.io/sig-storage/local-volume-provisioner:v2.6.0
              classes:
              - name: local-disks
                hostDir: /data/local-static-provisioner
                volumeMode: Filesystem
                fsType: ext4
                namePattern: '*'
                blockCleanerCommand:
                - /scripts/shred.sh
                - 2
                storageClass:
                  isDefaultClass: true
              serviceMonitor:
                enabled: false
        destination:
          server: https://kubernetes.default.svc
          namespace: provisioner
      
      
  2. apply to k8s
    • kubectl -n argocd apply -f local-static-provisioner.yaml
      
  3. sync by argocd
    • argocd app sync argocd/local-static-provisioner
      
  4. configure local volumes is required for not support dynamic provisioning
    • with mount --bind to mount the directories
      • HOSTNAME=$(hostname)
        for index in $(seq 1 3)
        do
            sudo mkdir -p /data/virtual-disks/$HOSTNAME-volume-$index
            sudo mkdir -p /data/local-static-provisioner/$HOSTNAME-volume-$index
            sudo mount --bind /data/virtual-disks/$HOSTNAME-volume-$index /data/local-static-provisioner/$HOSTNAME-volume-$index
        done
        
    • with devices directly
      • HOSTNAME=$(hostname)
        sudo mount /dev/sdb1 /data/local-static-provisioner/$HOSTNAME-volume-dev-sdb1
        
  5. check storage class
    • kubectl get sc
      
  6. check pv status
    • kubectl get pv
      

references

  • https://github.com/kubernetes-sigs/sig-storage-local-static-provisioner
  • https://github.com/kubernetes-sigs/sig-storage-local-static-provisioner/blob/master/helm/README.md