CSIDriver

CSIDriver 捕获有关集群上部署的容器存储接口 (CSI) 卷驱动程序的信息。

apiVersion: storage.k8s.io/v1

import "k8s.io/api/storage/v1"

CSIDriver

CSIDriver 捕获有关集群上部署的容器存储接口 (CSI) 卷驱动程序的信息。Kubernetes 的挂载/卸载控制器使用此对象来确定是否需要挂载。Kubelet 使用此对象来确定在挂载时是否需要传递 Pod 信息。CSIDriver 对象是非命名空间的。


  • apiVersion: storage.k8s.io/v1

  • kind: CSIDriver

  • metadata (ObjectMeta)

    标准对象元数据。metadata.Name 指示此对象引用的 CSI 驱动程序的名称;它必须与 CSI GetPluginName() 调用为该驱动程序返回的名称相同。驱动程序名称最多为 63 个字符,以字母数字字符([a-z0-9A-Z])开头和结尾,中间可以包含连字符(-)、点(.)和字母数字字符。更多信息:https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata

  • spec (CSIDriverSpec),必需

    spec 表示 CSI 驱动程序的规范。

CSIDriverSpec

CSIDriverSpec 是 CSIDriver 的规范。


  • attachRequired (boolean)

    attachRequired 表明此 CSI 卷驱动程序需要执行 attach 操作(因为它实现了 CSI ControllerPublishVolume() 方法),并且 Kubernetes 的 attach detach 控制器应调用 attach volume 接口,该接口会检查 volumeattachment 状态并在继续挂载之前等待卷已挂载。CSI 外部 attach 协调器与 CSI 卷驱动程序协同工作,并在 attach 操作完成后更新 volumeattachment 状态。如果将此值指定为 false,则会跳过 attach 操作。否则,将调用 attach 操作。

    此字段不可变。

  • fsGroupPolicy (string)

    fsGroupPolicy 定义了在挂载前底层卷是否支持更改卷的所有权和权限。有关更多详细信息,请参阅特定的 FSGroupPolicy 值。

    此字段在 Kubernetes < 1.29 中是不可变的,现在是可变的。

    默认为 ReadWriteOnceWithFSType,它将检查每个卷以确定 Kubernetes 是否应修改卷的所有权和权限。使用默认策略,只有在定义了 fstype 且卷的访问模式包含 ReadWriteOnce 时,才会应用定义的 fsGroup。

  • nodeAllocatableUpdatePeriodSeconds (int64)

    nodeAllocatableUpdatePeriodSeconds 指定此驱动程序的 CSINode 可分配容量的定期更新间隔。设置后,将启用定期更新和由容量相关故障触发的更新。如果未设置,则不发生更新(既不定期也不在检测到容量相关故障时),并且 allocatable.count 保持静态。此字段允许的最小值为 10 秒。

    这是一个 Beta 功能,需要启用 MutableCSINodeAllocatableCount 功能门。

    此字段是可变的。

  • podInfoOnMount (boolean)

    podInfoOnMount 表明此 CSI 卷驱动程序在挂载操作期间需要额外的 Pod 信息(如 podName、podUID 等),如果设置为 true。如果设置为 false,则不会在挂载时传递 Pod 信息。默认为 false。

    CSI 驱动程序在驱动程序部署时指定 podInfoOnMount。如果为 true,Kubelet 将在 CSI NodePublishVolume() 调用中将 Pod 信息作为 VolumeContext 传递。CSI 驱动程序负责解析和验证作为 VolumeContext 传递的信息。

    如果 podInfoOnMount 设置为 true,将传递以下 VolumeContext。此列表可能会增长,但将使用前缀。“csi.storage.k8s.io/pod.name”:pod.Name “csi.storage.k8s.io/pod.namespace”:pod.Namespace “csi.storage.k8s.io/pod.uid”:string(pod.UID) “csi.storage.k8s.io/ephemeral”:“true”如果卷是 CSIVolumeSource 定义的临时内联卷,否则为“false”

    “csi.storage.k8s.io/ephemeral”是 Kubernetes 1.16 中的一项新功能。它仅适用于支持“Persistent”和“Ephemeral” VolumeLifecycleMode 的驱动程序。其他驱动程序可以禁用 Pod 信息传递和/或忽略此字段。由于 Kubernetes 1.15 不支持此字段,因此驱动程序在 such 集群上部署时只能支持一种模式,并且部署决定了是哪种模式,例如通过驱动程序的命令行参数。

    此字段在 Kubernetes < 1.29 中是不可变的,现在是可变的。

  • requiresRepublish (boolean)

    requiresRepublish 表明 CSI 驱动程序希望 periodically 调用 NodePublishVolume 以反映挂载卷的任何可能更改。此字段默认为 false。

    注意:在成功的初始 NodePublishVolume 调用后,后续对 NodePublishVolume 的调用应仅更新卷的内容。正在运行的容器将看不到新的挂载点。

  • seLinuxMount (boolean)

    seLinuxMount 指定 CSI 驱动程序是否支持“-o context”挂载选项。

    当为“true”时,CSI 驱动程序必须确保此 CSI 驱动程序提供的所有卷都可以使用不同的 -o context 选项单独挂载。这对于将卷提供为块设备上的文件系统或独立的共享卷的存储后端来说很常见。Kubernetes 将在挂载 Pod 中明确设置了 SELinux 上下文的 ReadWriteOncePod 卷时,使用“-o context=xyz”挂载选项调用 NodeStage / NodePublish。将来,它可能会扩展到其他卷的 AccessModes。无论如何,Kubernetes 将确保卷仅以单个 SELinux 上下文挂载。

    当为“false”时,Kubernetes 不会将任何特殊的 SELinux 挂载选项传递给驱动程序。这对于表示更大共享文件系统子目录的卷来说很常见。

    默认为“false”。

  • storageCapacity (boolean)

    storageCapacity 表明 CSI 卷驱动程序希望 Pod 调度考虑驱动程序部署将通过创建具有容量信息的 CSIStorageCapacity 对象来报告的存储容量,如果设置为 true。

    在部署驱动程序时可以立即启用检查。在这种情况下,使用延迟绑定配置新卷的操作将暂停,直到驱动程序部署发布一些合适的 CSIStorageCapacity 对象。

    或者,可以不设置此字段或将其设置为 false 来部署驱动程序,并在发布存储容量信息后将其切换。

    此字段在 Kubernetes <= 1.22 中是不可变的,现在是可变的。

  • tokenRequests ([]TokenRequest)

    原子性:在合并期间将被替换

    tokenRequests 表明 CSI 驱动程序需要挂载卷的 Pod 的服务账户令牌来进行必要的身份验证。Kubelet 将在 CSI NodePublishVolume 调用中的 VolumeContext 中传递令牌。CSI 驱动程序应解析并验证以下 VolumeContext:“csi.storage.k8s.io/serviceAccount.tokens”:{ “<audience>”: { “token”: <token>,“expirationTimestamp”: <RFC3339 格式的到期时间戳>,} ...}

    注意:“TokenRequestSpec”中的 audience 必须不同,并且最多只有一个令牌为空字符串。要获取到期后的新令牌,可以使用 RequiresRepublish 来 periodic 调用 NodePublishVolume。

    TokenRequest 包含服务账户令牌的参数。

    • tokenRequests.audience (string),必需

      audience 是“TokenRequestSpec”中令牌的目标受众。它将默认为 kube apiserver 的受众。

    • tokenRequests.expirationSeconds (int64)

      expirationSeconds 是“TokenRequestSpec”中令牌的有效持续时间。它与“TokenRequestSpec”中的“ExpirationSeconds”具有相同的默认值。

  • volumeLifecycleModes ([]string)

    Set: 合并时将保留唯一值

    volumeLifecycleModes 定义此 CSI 卷驱动程序支持哪种类型的卷。如果列表为空,则默认为“Persistent”,这是 CSI 规范中定义的用法,并在 Kubernetes 中通过常规的 PV/PVC 机制实现。

    另一种模式是“Ephemeral”。在此模式下,卷在 Pod spec 中使用 CSIVolumeSource 内联定义,其生命周期与该 Pod 的生命周期绑定。驱动程序必须意识到这一点,因为它只会为此类卷收到 NodePublishVolume 调用。

    有关实现此模式的更多信息,请参阅 https://kubernetes-csi.github.io/docs/ephemeral-local-volumes.html。驱动程序可以支持一种或多种模式,将来还可能添加更多模式。

    此字段是 Beta 版。此字段不可变。

CSIDriverList

CSIDriverList 是 CSIDriver 对象的集合。


操作


get 读取指定的 CSIDriver

HTTP 请求

GET /apis/storage.k8s.io/v1/csidrivers/{name}

参数

  • name (在路径中): string,必填

    CSIDriver 的名称

  • pretty (在查询中): string

    pretty

响应

200 (CSIDriver): OK

401: 未授权

list 列出或监视 CSIDriver 类型的对象

HTTP 请求

GET /apis/storage.k8s.io/v1/csidrivers

参数

响应

200 (CSIDriverList): OK

401: 未授权

create 创建一个 CSIDriver

HTTP 请求

POST /apis/storage.k8s.io/v1/csidrivers

参数

响应

200 (CSIDriver): OK

201 (CSIDriver): Created

202 (CSIDriver): Accepted

401: 未授权

update 替换指定的 CSIDriver

HTTP 请求

PUT /apis/storage.k8s.io/v1/csidrivers/{name}

参数

  • name (在路径中): string,必填

    CSIDriver 的名称

  • body: CSIDriver, required

  • dryRun (在查询中): string

    dryRun

  • fieldManager (在查询中): string

    fieldManager

  • fieldValidation (在查询中): string

    fieldValidation

  • pretty (在查询中): string

    pretty

响应

200 (CSIDriver): OK

201 (CSIDriver): Created

401: 未授权

patch 部分更新指定的 CSIDriver

HTTP 请求

PATCH /apis/storage.k8s.io/v1/csidrivers/{name}

参数

  • name (在路径中): string,必填

    CSIDriver 的名称

  • body: Patch,必需

  • dryRun (在查询中): string

    dryRun

  • fieldManager (在查询中): string

    fieldManager

  • fieldValidation (在查询中): string

    fieldValidation

  • force (在查询中): boolean

    force

  • pretty (在查询中): string

    pretty

响应

200 (CSIDriver): OK

201 (CSIDriver): Created

401: 未授权

delete 删除一个 CSIDriver

HTTP 请求

DELETE /apis/storage.k8s.io/v1/csidrivers/{name}

参数

响应

200 (CSIDriver): OK

202 (CSIDriver): Accepted

401: 未授权

deletecollection 删除 CSIDriver 的集合

HTTP 请求

DELETE /apis/storage.k8s.io/v1/csidrivers

参数

响应

200 (Status): OK

401: 未授权

本页面是自动生成的。

如果你打算报告此页面存在的问题,请在问题描述中提及此页面是自动生成的。修复可能需要在 Kubernetes 项目的其他地方进行。

上次修改时间:2025 年 9 月 4 日 下午 3:37 PST:更新 v1.34 的 API 资源参考 (3e10e8c195)