获取local-path-provisioner
git clone https://github.com/rancher/local-path-provisioner.git
修改local-path-storage.yaml
vi local-path-provisioner/deploy/local-path-storage.yaml
修改前(修改部分):
---
kind: ConfigMap
apiVersion: v1
metadata:name: local-path-confignamespace: local-path-storage
data:config.json: |-{"nodePathMap":[{"node":"DEFAULT_PATH_FOR_NON_LISTED_NODES","paths":["/opt/local-path-provisioner"]}]}
修改后(修改部分):
---
kind: ConfigMap
apiVersion: v1
metadata:name: local-path-confignamespace: local-path-storage
data:config.json: |-{"nodePathMap":[{"node":"DEFAULT_PATH_FOR_NON_LISTED_NODES","paths":["/u01/local-path-provisioner"]}]}
创建文件路径
mkdir -p /u01/local-path-provisioner
chmod 777 /u01/local-path-provisioner
创建namespace
kubectl create ns local-path-storage
发布local-path-storage
kubectl apply -f local-path-provisioner/deploy/local-path-storage.yaml -n local-path-storage
确认发布结果
确认结果:
kubectl get po -n local-path-storage
结果如下:
NAME READY STATUS RESTARTS AGE
local-path-provisioner-54bbdbb5cc-7d8kw 1/1 Running 0 18m
确认结果:
kubectl get storageclass
结果如下:
NAME PROVISIONER AGE
local-path rancher.io/local-path 18m
设置为default的storageclass
kubectl patch storageclass local-path -p ‘{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}‘
kubectl patch storageclass local-path -p ‘{"metadata": {"annotations":{"storageclass.beta.kubernetes.io/is-default-class":"true"}}}‘
卸载
kubectl delete -f local-path-provisioner/deploy/local-path-storage.yaml