Kubernetes External provisioning无法创建存储卷问题咨询
问题排查步骤
1. 版本适配变动说明
- Minikube v1.17.1默认配套Kubernetes v1.20.2版本,该版本对StatefulSet的PVC绑定逻辑、HostPath存储类的默认配置做了调整:v1.20及以上Kubernetes版本不再默认授予
hostpath外部供给器PV/PVC操作权限,需手动配置RBAC规则。 - 你今年3月操作时使用的Minikube/Kubernetes版本大概率低于v1.20,无该权限限制,因此可以正常部署。
2. PVC pending问题修复步骤
第一步:校验存储类配置
执行命令查看当前集群存储类:
kubectl get storageclasses.storage.k8s.io
若默认存储类标记为<none>,执行以下命令将minikube自带的hostpath存储类设为默认:
kubectl patch storageclass standard -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
第二步:配置HostPath供给器RBAC权限
创建rbac.yaml文件,写入以下内容:
apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: hostpath-provisioner-runner rules: - apiGroups: [""] resources: ["persistentvolumes"] verbs: ["get", "list", "watch", "create", "delete"] - apiGroups: [""] resources: ["persistentvolumeclaims"] verbs: ["get", "list", "watch", "update"] - apiGroups: ["storage.k8s.io"] resources: ["storageclasses"] verbs: ["get", "list", "watch"] - apiGroups: [""] resources: ["events"] verbs: ["create", "update", "patch"] --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: run-hostpath-provisioner subjects: - kind: ServiceAccount name: hostpath-provisioner namespace: kube-system roleRef: kind: ClusterRole name: hostpath-provisioner-runner apiGroup: rbac.authorization.k8s.io
执行配置生效命令:
kubectl apply -f rbac.yaml
第三步:重建异常PVC
删除当前处于pending状态的PVC,StatefulSet会自动触发重建,新PVC可正常绑定PV:
kubectl delete pvc -l app=mysql
3. 快速验证方案
若上述操作后仍未恢复,直接启用minikube官方存储供给器插件即可:
minikube addons enable storage-provisioner
重启minikube后重新执行教程部署步骤即可正常运行。
内容的提问来源于stack exchange,提问作者EoinHanan
相关产品推荐
相关产品推荐

