发布时间: 2024-11-19 文章作者: myluzh 分类名称: Kubernetes 朗读文章
root@k8s-master:~# kubectl apply -f https://raw.githubusercontent.com/rancher/local-path-provisioner/master/deploy/local-path-storage.yaml
root@k8s-master:~# kubectl get storageclass NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE local-path (default) rancher.io/local-path Delete WaitForFirstConsumer false 35m
root@k8s-master:~# kubectl patch storageclass local-path -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
# 查看当前使用的存储路径 root@k8s-master:~# kubectl -n local-path-storage get configmap local-path-config -o yaml | grep paths "paths":["/opt/local-path-provisioner"] # 在k8s每个节点都创建目录跟权限 sudo mkdir -p /opt/local-path-provisioner sudo chmod 777 /opt/local-path-provisioner
root@k8s-master:~# kubectl get pods -n local-path-storage NAME READY STATUS RESTARTS AGE # 发现镜像拉取失败 需要替换成私有仓地址 local-path-provisioner-798b97f8f7-jg884 0/1 ImagePullBackOff 0 5m29s替换镜像地址为私有仓地址
root@k8s-master:~# kubectl edit deployment local-path-provisioner -n local-path-storage image: 172.30.82.223:5443/rancher/local-path-provisioner:v0.0.30
root@k8s-master:~# kubectl get pod -n local-path-storage NAME READY STATUS RESTARTS AGE helper-pod-create-pvc-0c6af74d-61c0-4fbe-9431-ab37a533444b 0/1 ErrImagePull 0 113s helper-pod-create-pvc-33ad5b18-9800-4006-9099-d0082d8c6cde 0/1 ErrImagePull 0 113s helper-pod-create-pvc-6e85f33d-5fe3-444d-9d07-1d41feeb4cc7 0/1 ImagePullBackOff 0 112s helper-pod-create-pvc-bb098b75-c492-445b-a620-770d65b43224 0/1 ImagePullBackOff 0 83shelper-pod 使用的镜像定义是busybox,也替换成私有镜像仓地址
root@k8s-master:~# kubectl edit configmap local-path-config -n local-path-storage ... containers: - name: helper-pod image: 172.30.82.223:5443/base/busybox:240703 imagePullPolicy: IfNotPresent ...
标签: k8s pv pvc storageclass 本地路径存储 Local-Path-Storage
发表评论