首页 > 解决方案 > 在本地 kubernetes 集群上遇到问题 - ProvisioningFailed - 没有匹配的卷插件

问题描述

我不确定它是否是初学者级别的问题,但我想把它放在这里。我正在尝试在 Kubernetes 集群中设置动态卷配置。

但是我的 Kubernetes 集群在我的本地虚拟环境中运行(我使用 ubuntu 启动了我的 vagrant box,并使用 kuberspra​​y 来配置我的 Kubernetes 集群)。我遵循了本指南 -使用 kubespray 设置 Kubernetes 集群

简而言之,我没有使用任何云服务,一切都在虚拟机中运行。

对于动态卷配置,我创建了一个存储类 -

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: jhooq-storage-class
provisioner: kubernetes.io/no-provisioner
parameters:
  type: pd-ssd
 

之后,我创建了持久卷声明

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: jhooq-pvc-with-sc
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: jhooq-storage-class
  resources:
    requests:
      storage: 1Gi

但是我在应用PVC配置时遇到了问题

这是持久卷声明(PVC)的状态

Name:          pvc-with-sc
Namespace:     default
StorageClass:  storage-class
Status:        Pending
Volume:        
Labels:        <none>
Annotations:   Finalizers:  [kubernetes.io/pvc-protection]
Capacity:      
Access Modes:  
VolumeMode:    Filesystem
Mounted By:    <none>
Events:
  Type     Reason              Age                   From                         Message
  ----     ------              ----                  ----                         -------
  Warning  ProvisioningFailed  100s (x182 over 46m)  persistentvolume-controller  no volume plugin matched
 

我在这里错过了一些非常基本的东西吗?或者在虚拟环境中是不可能的?

任何建议或想法将不胜感激

标签: kubernetes

解决方案


Basically in your case you are just missing the PV.

According to k8s documentation:

Local volumes do not currently support dynamic provisioning, however a StorageClass should still be created to delay volume binding until Pod scheduling. This is specified by the WaitForFirstConsumer volume binding mode.

So, even though it's not currently supported, you should still be able to create it.

Going through some docs, I found out that you actually need to create the PV to have it bounded to your PVC, and you can define your storageClass within the PV definition, so in your case would be something like that:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: local-pv
  labels:
    type: local-pv
spec:
  storageClassName: jhooq-storage-class
  capacity:
    storage: 1Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/whatever/path"

推荐阅读