Lease

Lease 定义了一个租约概念。

apiVersion: coordination.k8s.io/v1

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

Lease

Lease 定义了一个租约概念。


LeaseSpec

LeaseSpec 是 Lease 的一个规范。


  • acquireTime (MicroTime)

    acquireTime 是当前租约被获取的时间。

    MicroTime 是精确到微秒级别的时间版本。

  • holderIdentity (string)

    holderIdentity 包含当前租约持有者的身份。如果使用协调式领导者选举,持有者身份必须等于当选的 LeaseCandidate.metadata.name 字段。

  • leaseDurationSeconds (int32)

    leaseDurationSeconds 是租约候选者强制获取租约需要等待的持续时间。这是根据上次观察到的 renewTime 计算的。

  • leaseTransitions (int32)

    leaseTransitions 是租约在持有者之间转换的次数。

  • preferredHolder (string)

    PreferredHolder 向租约持有者发出信号,表明租约有一个更优的持有者,应该放弃。此字段只能在 Strategy 也已设置时设置。

  • renewTime (MicroTime)

    renewTime 是当前租约持有者最后一次更新租约的时间。

    MicroTime 是精确到微秒级别的时间版本。

  • strategy (string)

    Strategy 指示协调式领导者选举中选择领导者的策略。如果未指定此字段,则此租约没有活跃的协调。(Alpha)使用此字段需要启用 CoordinatedLeaderElection 功能门控。

LeaseList

LeaseList 是 Lease 对象的列表。


操作


get 读取指定的 Lease

HTTP 请求

GET /apis/coordination.k8s.io/v1/namespaces/{namespace}/leases/{name}

参数

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

    Lease 的名称

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

    命名空间

  • pretty (在查询中): string

    pretty

响应

200 (Lease): 成功

401: 未授权

list 列出或监视类型为 Lease 的对象

HTTP 请求

GET /apis/coordination.k8s.io/v1/namespaces/{namespace}/leases

参数

响应

200 (LeaseList): 成功

401: 未授权

list 列出或监视类型为 Lease 的对象

HTTP 请求

GET /apis/coordination.k8s.io/v1/leases

参数

响应

200 (LeaseList): 成功

401: 未授权

create 创建一个 Lease

HTTP 请求

POST /apis/coordination.k8s.io/v1/namespaces/{namespace}/leases

参数

响应

200 (Lease): 成功

201 (Lease): 已创建

202 (Lease): 已接受

401: 未授权

update 替换指定的 Lease

HTTP 请求

PUT /apis/coordination.k8s.io/v1/namespaces/{namespace}/leases/{name}

参数

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

    Lease 的名称

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

    命名空间

  • body: Lease, 必填

  • dryRun (在查询中): string

    dryRun

  • fieldManager (在查询中): string

    fieldManager

  • fieldValidation (在查询中): string

    fieldValidation

  • pretty (在查询中): string

    pretty

响应

200 (Lease): 成功

201 (Lease): 已创建

401: 未授权

patch 部分更新指定的 Lease

HTTP 请求

PATCH /apis/coordination.k8s.io/v1/namespaces/{namespace}/leases/{name}

参数

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

    Lease 的名称

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

    命名空间

  • body: Patch,必需

  • dryRun (在查询中): string

    dryRun

  • fieldManager (在查询中): string

    fieldManager

  • fieldValidation (在查询中): string

    fieldValidation

  • force (在查询中): boolean

    force

  • pretty (在查询中): string

    pretty

响应

200 (Lease): 成功

201 (Lease): 已创建

401: 未授权

delete 删除一个 Lease

HTTP 请求

DELETE /apis/coordination.k8s.io/v1/namespaces/{namespace}/leases/{name}

参数

响应

200 (Status): OK

202 (Status): 已接受

401: 未授权

deletecollection 删除 Lease 集合

HTTP 请求

DELETE /apis/coordination.k8s.io/v1/namespaces/{namespace}/leases

参数

响应

200 (Status): OK

401: 未授权

本页面是自动生成的。

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

上次修改时间:2025 年 4 月 9 日太平洋标准时间下午 6:36:更新 v1.32 的 API 参考文档 (a3b579d035)