PodDisruptionBudget

PodDisruptionBudget 是一个对象,用于定义可能对一组 Pod 造成的最大中断。

apiVersion: policy/v1

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

PodDisruptionBudget

PodDisruptionBudget 是一个对象,用于定义可能对一组 Pod 造成的最大中断


PodDisruptionBudgetSpec

PodDisruptionBudgetSpec 是 PodDisruptionBudget 的描述。


  • maxUnavailable (IntOrString)

    如果驱逐后,由 "selector" 选择的最多 "maxUnavailable" 个 Pod 处于不可用状态,则允许驱逐。例如,可以通过指定 0 来阻止所有自愿驱逐。这是与 "minAvailable" 互斥的设置。

    IntOrString 是一种可以包含 int32 或 string 的类型。在 JSON 或 YAML 编组和解组时,它会生成或消耗内部类型。这允许您拥有一个例如可以接受名称或数字的 JSON 字段。

  • minAvailable (IntOrString)

    如果驱逐后,至少有 "minAvailable" 个由 "selector" 选择的 Pod 仍然可用,则允许驱逐。因此,例如,您可以通过指定 "100%" 来阻止所有自愿驱逐。

    IntOrString 是一种可以包含 int32 或 string 的类型。在 JSON 或 YAML 编组和解组时,它会生成或消耗内部类型。这允许您拥有一个例如可以接受名称或数字的 JSON 字段。

  • selector (LabelSelector)

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

  • unhealthyPodEvictionPolicy (string)

    UnhealthyPodEvictionPolicy 定义了何时应考虑驱逐不健康 Pod 的标准。当前实现考虑健康的 Pod,即 status.conditions 项的 type="Ready" 且 status="True" 的 Pod。

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

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

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

    未来可能会添加其他策略。进行驱逐决策的客户端应在遇到此字段中未识别的策略时,拒绝驱逐不健康的 Pod。

PodDisruptionBudgetStatus

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


  • currentHealthy (int32), required

    当前健康 Pod 的数量

  • desiredHealthy (int32), required

    最少期望的健康 Pod 数量

  • disruptionsAllowed (int32), required

    当前允许的 Pod 中断数量。

  • expectedPods (int32), required

    此中断预算所计数的 Pod 的总数

  • conditions ([]Condition)

    补丁策略:按键 type 合并

    映射:合并时将保留键类型上的唯一值

    Conditions 包含 PDB 的条件。中断控制器设置 DisruptionAllowed 条件。以下是 reason 字段的已知值(未来可能添加其他原因):- SyncFailed:控制器遇到错误,无法计算允许的中断数量。因此,不允许任何中断,并且条件的状态将为 False。

    • InsufficientPods:Pod 数量等于或低于 PodDisruptionBudget 所需的数量。不允许任何中断,并且条件的状态将为 False。
    • SufficientPods:Pod 的数量多于 PodDisruptionBudget 所需的数量。条件将为 True,并且允许的中断数量由 disruptionsAllowed 属性提供。

    Condition 包含此 API 资源当前状态的一个方面的详细信息。

    • conditions.lastTransitionTime (Time),必需

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

      Time 是 time.Time 的一个包装器,支持正确地编组到 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 包含有关其驱逐已被 API 服务器驱逐子资源处理程序处理但尚未被 PodDisruptionBudget 控制器观察到的 Pod 的信息。Pod 将从 API 服务器处理驱逐请求时到 Pod 被 PDB 控制器视为已标记删除时(或在超时后)在此映射中。映射中的键是 Pod 的名称,值是 API 服务器处理驱逐请求的时间。如果删除未发生并且 Pod 仍然存在,PodDisruptionBudget 控制器将在一段时间后自动将其从列表中删除。如果一切顺利,此映射大部分时间应为空。此映射中的大量条目可能表明 Pod 删除存在问题。

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

  • observedGeneration (int64)

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

PodDisruptionBudgetList

PodDisruptionBudgetList 是 PodDisruptionBudgets 的集合。


操作


get 读取指定的 PodDisruptionBudget

HTTP 请求

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

参数

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

    PodDisruptionBudget 的名称

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

    命名空间

  • pretty (在查询中): string

    pretty

响应

200 (PodDisruptionBudget): OK

401: 未授权

get 读取指定的 PodDisruptionBudget 的状态

HTTP 请求

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

参数

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

    PodDisruptionBudget 的名称

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

    命名空间

  • pretty (在查询中): string

    pretty

响应

200 (PodDisruptionBudget): OK

401: 未授权

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

HTTP 请求

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

参数

响应

200 (PodDisruptionBudgetList): OK

401: 未授权

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

HTTP 请求

GET /apis/policy/v1/poddisruptionbudgets

参数

响应

200 (PodDisruptionBudgetList): OK

401: 未授权

create 创建一个 PodDisruptionBudget

HTTP 请求

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

参数

响应

200 (PodDisruptionBudget): OK

201 (PodDisruptionBudget): Created

202 (PodDisruptionBudget): Accepted

401: 未授权

update 替换指定的 PodDisruptionBudget

HTTP 请求

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

参数

响应

200 (PodDisruptionBudget): OK

201 (PodDisruptionBudget): Created

401: 未授权

update 替换指定的 PodDisruptionBudget 的状态

HTTP 请求

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

参数

响应

200 (PodDisruptionBudget): OK

201 (PodDisruptionBudget): Created

401: 未授权

patch 部分更新指定的 PodDisruptionBudget

HTTP 请求

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

参数

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

    PodDisruptionBudget 的名称

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

    命名空间

  • body: Patch,必需

  • dryRun (在查询中): string

    dryRun

  • fieldManager (在查询中): string

    fieldManager

  • fieldValidation (在查询中): string

    fieldValidation

  • force (在查询中): boolean

    force

  • pretty (在查询中): string

    pretty

响应

200 (PodDisruptionBudget): OK

201 (PodDisruptionBudget): Created

401: 未授权

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

HTTP 请求

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

参数

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

    PodDisruptionBudget 的名称

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

    命名空间

  • body: Patch,必需

  • dryRun (在查询中): string

    dryRun

  • fieldManager (在查询中): string

    fieldManager

  • fieldValidation (在查询中): string

    fieldValidation

  • force (在查询中): boolean

    force

  • pretty (在查询中): string

    pretty

响应

200 (PodDisruptionBudget): OK

201 (PodDisruptionBudget): Created

401: 未授权

delete 删除一个 PodDisruptionBudget

HTTP 请求

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

参数

响应

200 (Status): OK

202 (Status): 已接受

401: 未授权

deletecollection 删除 PodDisruptionBudget 的集合

HTTP 请求

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

参数

响应

200 (Status): OK

401: 未授权

本页面是自动生成的。

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

最后修改时间:2025 年 4 月 24 日上午 9:14 PST:v1.33 的 Markdown API 参考 (b84ec30bbb)