Local Path Provisioner 是解决 K8s 本地存储管理难 的利器。它比原生的 hostPath 更智能,又比原生的 local PV 配置更简单。
Local Path Provisioner#
核心概括:
- 自动创建:当你提交一个 PersistentVolumeClaim (PVC) 时,它会自动在指定的 Node 目录下创建一个子目录。
- 生命周期绑定:它会自动创建对应的 PersistentVolume (PV) 并与其绑定。
- 动态供给:不需要像使用原生 local 卷那样手动为每个节点写 PV 的 YAML。
部署安装#
- 安装
kubectl apply -f https://raw.githubusercontent.com/rancher/local-path-provisioner/v0.0.34/deploy/local-path-storage.yaml
- 查看服务
root@kubernetes01:~/metallb# kubectl get pods -n metallb-system
NAME READY STATUS RESTARTS AGE
controller-9c6cff498-bg8fz 1/1 Running 0 14h
speaker-5v59w 1/1 Running 0 14h
speaker-92fdj 1/1 Running 0 14h
speaker-mw7jk 1/1 Running 0 14h
speaker-mzm6j 1/1 Running 0 14h
speaker-nbvwc 1/1 Running 0 14h
speaker-qtpgk 1/1 Running 0 14h
- 默认存储
kubectl patch storageclass local-path -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
- 查看服务
root@kubernetes01:~/local-path-provisioner# kubectl get storageclasses.storage.k8s.io
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
local-path (default) rancher.io/local-path Delete WaitForFirstConsumer false 4h42m
结语#
参考:


