我可以获得 storageclasses.storage.k8s.io 支持的访问模式吗?

Can I getting the ACCESS MODES supported by storageclasses.storage.k8s.io?

例如我想用 RWX 创建一个 pvc ACCESS_MODE 我可以提前知道默认的 sorageclasses 是否支持 RWX 吗?

Kubernetes 不支持此功能。您必须手动找到您的存储支持哪些访问模式class。

从头开始 - 我建议您阅读有关 StorageClasses 的官方文档。

A StorageClass provides a way for administrators to describe the "classes" of storage they offer. Different classes might map to quality-of-service levels, or to backup policies, or to arbitrary policies determined by the cluster administrators. Kubernetes itself is unopinionated about what classes represent. This concept is sometimes called "profiles" in other storage systems. Each StorageClass contains the fields provisioner, parameters, and reclaimPolicy, which are used when a PersistentVolume belonging to the class needs to be dynamically provisioned.

看看volume plugins(aka provisioners)

Each StorageClass has a provisioner that determines what volume plugin is used for provisioning PVs. This field must be specified. You are not restricted to specifying the "internal" provisioners listed here (whose names are prefixed with "kubernetes.io" and shipped alongside Kubernetes). You can also run and specify external provisioners, which are independent programs that follow a specification defined by Kubernetes.

重要特征是 mount-option

PersistentVolumes that are dynamically created by a StorageClass will have the mount options specified in the mountOptions field of the class. If the volume plugin does not support mount options but mount options are specified, provisioning will fail. Mount options are not validated on either the class or PV, so mount of the PV will simply fail if one is invalid.

最后你必须手动检查资源的访问模式。首先检查默认设置的 StorageClass:

$ kubectl get storageclass

然后获取相关信息:

$ kubectl describe storageclass <your-default-storage-class>

现在您将能够检查卷插件及其挂载选项和访问模式。它特定的存储 class 不支持想要的访问模式将不同的存储 class 标记为默认值:

$ kubectl patch storageclass <your-storage-class> -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'

请注意,最多可以将一个 StorageClass 标记为默认。如果其中两个或多个标记为默认值,则无法创建没有明确指定 storageClassNamePersistentVolumeClaim。集群管理员可以根据需要定义任意数量的 StorageClass 对象。 查看更多:changing-default-storageclass.