PodDisruptionBudget

PodDisruptionBudget 是一个对象,用于定义可能导致 Pod 集合发生的最大中断。

apiVersion: policy/v1

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

PodDisruptionBudget

PodDisruptionBudget 是一个对象,用于定义可能导致 Pod 集合发生的最大中断


PodDisruptionBudgetSpec

PodDisruptionBudgetSpec 是 PodDisruptionBudget 的描述。


  • maxUnavailable (IntOrString)

    当驱逐后,由 “selector” 选中的 Pod 中最多有 “maxUnavailable” 个 Pod 不可用时,驱逐是被允许的,即使没有被驱逐的 Pod 也是如此。例如,通过指定 0,可以阻止所有自愿驱逐。这与 “minAvailable” 是互斥设置。

    IntOrString 是一种可以容纳 int32 或字符串的类型。当用于 JSON 或 YAML 编组(marshalling)和解组(unmarshalling)时,它会产生或消费内部类型。这允许你有一个 JSON 字段,例如,可以接受名称或数字。

  • minAvailable (IntOrString)

    当驱逐后,由 “selector” 选中的 Pod 中至少有 “minAvailable” 个 Pod 仍然可用时,驱逐是被允许的,即使没有被驱逐的 Pod 也是如此。因此,例如,通过指定 “100%”,你可以阻止所有自愿驱逐。

    IntOrString 是一种可以容纳 int32 或字符串的类型。当用于 JSON 或 YAML 编组(marshalling)和解组(unmarshalling)时,它会产生或消费内部类型。这允许你有一个 JSON 字段,例如,可以接受名称或数字。

  • selector (LabelSelector)

    标签查询,作用于其驱逐由中断预算管理的 Pod。空选择器(null selector)将不匹配任何 Pod,而空的花括号 ({}) 选择器将选中命名空间中的所有 Pod。

  • unhealthyPodEvictionPolicy (string)

    UnhealthyPodEvictionPolicy 定义了何时应考虑驱逐不健康 Pod 的标准。当前实现将健康 Pod 视为 status.conditions 中包含 type="Ready"、status="True" 条目的 Pod。

    有效的策略是 IfHealthyBudget 和 AlwaysAllow。如果未指定策略,将使用默认行为,该行为对应于 IfHealthyBudget 策略。

    IfHealthyBudget 策略意味着运行中(status.phase="Running")但尚未健康的 Pod 只有在被保护的应用未发生中断(status.currentHealthy 至少等于 status.desiredHealthy)时才可被驱逐。健康的 Pod 将受 PDB 驱逐的约束。

    AlwaysAllow 策略意味着所有运行中(status.phase="Running")但尚未健康的 Pod 都被视为已中断,无论 PDB 中的条件是否满足,都可以被驱逐。这意味着发生中断的应用的潜在运行中 Pod 可能没有机会变得健康。健康的 Pod 将受 PDB 驱逐的约束。

    未来可能会添加更多策略。进行驱逐决策的客户端如果在此字段中遇到无法识别的策略,应禁止驱逐不健康 Pod。

PodDisruptionBudgetStatus

PodDisruptionBudgetStatus 表示 PodDisruptionBudget 的状态信息。状态可能落后于系统的实际状态。


  • currentHealthy (int32),必须

    当前健康 Pod 数量

  • desiredHealthy (int32),必须

    期望的最小健康 Pod 数量

  • disruptionsAllowed (int32),必须

    当前允许的 Pod 中断数量。

  • expectedPods (int32),必须

    此中断预算计算的 Pod 总数

  • conditions ([]Condition)

    Patch 策略:按键 type 合并

    映射:合并时将保留 key type 的唯一值

    Conditions 包含 PDB 的条件。中断控制器设置 DisruptionAllowed 条件。reason 字段的已知值如下(将来可能会添加更多 reason):- SyncFailed:控制器遇到错误,无法计算允许的中断数量。因此不允许中断,条件的状态将为 False。

    • InsufficientPods:Pod 数量达到或低于 PodDisruptionBudget 要求的数量。不允许中断,条件的状态将为 False。
    • SufficientPods:Pod 数量多于 PodDisruptionBudget 要求的数量。条件将为 True,允许的中断数量由 disruptionsAllowed 属性提供。

    Condition 包含有关此 API Resource 当前状态的一个方面的详细信息。

    • conditions.lastTransitionTime (Time),必须

      lastTransitionTime 是条件上次从一种状态转换到另一种状态的时间。这应该是底层条件发生变化的时间。如果不知道,那么使用 API 字段发生变化的时间是可以接受的。

      Time 是 time.Time 的包装器,支持正确编组(marshalling)到 YAML 和 JSON。提供了 time 包提供的许多工厂方法的包装器。

    • conditions.message (string),必须

      message 是人类可读的消息,指示有关转换的详细信息。这可以是一个空字符串。

    • conditions.reason (string),必须

      reason 包含一个程序化标识符,指示条件上次转换的原因。特定条件类型的生产者可以为此字段定义预期值和含义,以及这些值是否被视为有保证的 API。该值应为 CamelCase 字符串。此字段不得为空。

    • conditions.status (string),必须

      条件的状态,可以是 True、False、Unknown 之一。

    • conditions.type (string),必须

      条件的类型,采用 CamelCase 或 foo.example.com/CamelCase 格式。

    • conditions.observedGeneration (int64)

      observedGeneration 表示条件所基于的 .metadata.generation。例如,如果 .metadata.generation 当前为 12,但 .status.conditions[x].observedGeneration 为 9,则条件相对于实例的当前状态而言已过期。

  • disruptedPods (map[string]Time)

    DisruptedPods 包含有关 Pod 的信息,这些 Pod 的驱逐已由 API server 驱逐子资源处理程序处理,但尚未被 PodDisruptionBudget 控制器观察到。Pod 将在此映射中,从 API server 处理驱逐请求的时间起,到 PDB 控制器看到该 Pod 被标记为删除(或超时后)为止。映射中的键是 Pod 的名称,值是 API server 处理驱逐请求的时间。如果删除未发生且 Pod 仍在,它将在一段时间后由 PodDisruptionBudget 控制器自动从列表中移除。如果一切顺利,此映射大部分时间应为空。映射中的大量条目可能表明 Pod 删除存在问题。

    Time 是 time.Time 的包装器,支持正确编组(marshalling)到 YAML 和 JSON。提供了 time 包提供的许多工厂方法的包装器。

  • observedGeneration (int64)

    更新此 PDB 状态时观察到的最近一代。DisruptionsAllowed 和其他状态信息仅在 observedGeneration 等于 PDB 的对象生成时有效。

PodDisruptionBudgetList

PodDisruptionBudgetList 是 PodDisruptionBudget 的集合。


操作


get 读取指定的 PodDisruptionBudget

HTTP 请求

GET /apis/policy/v1/namespaces/{namespace}/poddisruptionbudgets/{name}

参数

  • name (in path): string,必须

    PodDisruptionBudget 的名称

  • namespace (in path): string,必须

    命名空间

  • pretty (in query): string

    pretty

响应

200 (PodDisruptionBudget): OK

401: Unauthorized

get 读取指定的 PodDisruptionBudget 的状态

HTTP 请求

GET /apis/policy/v1/namespaces/{namespace}/poddisruptionbudgets/{name}/status

参数

  • name (in path): string,必须

    PodDisruptionBudget 的名称

  • namespace (in path): string,必须

    命名空间

  • pretty (in query): string

    pretty

响应

200 (PodDisruptionBudget): OK

401: Unauthorized

list 列出或监听 PodDisruptionBudget 类型的对象

HTTP 请求

GET /apis/policy/v1/namespaces/{namespace}/poddisruptionbudgets

参数

响应

200 (PodDisruptionBudgetList): OK

401: Unauthorized

list 列出或监听 PodDisruptionBudget 类型的对象

HTTP 请求

GET /apis/policy/v1/poddisruptionbudgets

参数

响应

200 (PodDisruptionBudgetList): OK

401: Unauthorized

create 创建一个 PodDisruptionBudget

HTTP 请求

POST /apis/policy/v1/namespaces/{namespace}/poddisruptionbudgets

参数

响应

200 (PodDisruptionBudget): OK

201 (PodDisruptionBudget): Created

202 (PodDisruptionBudget): Accepted

401: Unauthorized

update 替换指定的 PodDisruptionBudget

HTTP 请求

PUT /apis/policy/v1/namespaces/{namespace}/poddisruptionbudgets/{name}

参数

响应

200 (PodDisruptionBudget): OK

201 (PodDisruptionBudget): Created

401: Unauthorized

update 替换指定的 PodDisruptionBudget 的状态

HTTP 请求

PUT /apis/policy/v1/namespaces/{namespace}/poddisruptionbudgets/{name}/status

参数

响应

200 (PodDisruptionBudget): OK

201 (PodDisruptionBudget): Created

401: Unauthorized

patch 部分更新指定的 PodDisruptionBudget

HTTP 请求

PATCH /apis/policy/v1/namespaces/{namespace}/poddisruptionbudgets/{name}

参数

  • name (in path): string,必须

    PodDisruptionBudget 的名称

  • namespace (in path): string,必须

    命名空间

  • body: Patch,必须

  • dryRun (in query): string

    dryRun

  • fieldManager (in query): string

    fieldManager

  • fieldValidation (in query): string

    fieldValidation

  • force (in query): boolean

    force

  • pretty (in query): string

    pretty

响应

200 (PodDisruptionBudget): OK

201 (PodDisruptionBudget): Created

401: Unauthorized

patch 部分更新指定的 PodDisruptionBudget 的状态

HTTP 请求

PATCH /apis/policy/v1/namespaces/{namespace}/poddisruptionbudgets/{name}/status

参数

  • name (in path): string,必须

    PodDisruptionBudget 的名称

  • namespace (in path): string,必须

    命名空间

  • body: Patch,必须

  • dryRun (in query): string

    dryRun

  • fieldManager (in query): string

    fieldManager

  • fieldValidation (in query): string

    fieldValidation

  • force (in query): boolean

    force

  • pretty (in query): string

    pretty

响应

200 (PodDisruptionBudget): OK

201 (PodDisruptionBudget): Created

401: Unauthorized

delete 删除一个 PodDisruptionBudget

HTTP 请求

DELETE /apis/policy/v1/namespaces/{namespace}/poddisruptionbudgets/{name}

参数

响应

200 (Status): OK

202 (Status): Accepted

401: Unauthorized

deletecollection 删除 PodDisruptionBudget 集合

HTTP 请求

DELETE /apis/policy/v1/namespaces/{namespace}/poddisruptionbudgets

参数

响应

200 (Status): OK

401: Unauthorized

此页面是自动生成的。

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

上次修改时间:2025 年 4 月 24 日 9:14 AM PST:Markdown API 参考 for v1.33 (b84ec30bbb)