租约

Lease 定义了一个租约概念。

apiVersion: coordination.k8s.io/v1

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

租约

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):OK

401:未授权

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

HTTP 请求

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

参数

响应

200 (LeaseList):OK

401:未授权

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

HTTP 请求

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

参数

响应

200 (LeaseList):OK

401:未授权

create 创建一个 Lease

HTTP 请求

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

参数

响应

200 (Lease):OK

201 (Lease):已创建

202 (Lease):已接受

401:未授权

update 替换指定的 Lease

HTTP 请求

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

参数

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

    Lease 的名称

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

    命名空间

  • bodyLease,必选

  • dryRun (在查询参数中):string

    dryRun

  • fieldManager (在查询参数中):string

    fieldManager

  • fieldValidation (在查询参数中):string

    fieldValidation

  • pretty (在查询参数中):string

    pretty

响应

200 (Lease):OK

201 (Lease):已创建

401:未授权

patch 部分更新指定的 Lease

HTTP 请求

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

参数

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

    Lease 的名称

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

    命名空间

  • bodyPatch,必选

  • dryRun (在查询参数中):string

    dryRun

  • fieldManager (在查询参数中):string

    fieldManager

  • fieldValidation (在查询参数中):string

    fieldValidation

  • force (在查询参数中):boolean

    force

  • pretty (在查询参数中):string

    pretty

响应

200 (Lease):OK

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 PST:更新 v1.32 的 API 参考文档 (a3b579d035)