PodDisruptionBudget

PodDisruptionBudget 是一个对象,用于定义可以对一组 Pod 造成的最大干扰。

apiVersion: policy/v1

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

PodDisruptionBudget

PodDisruptionBudget 是一个对象,用于定义可以对一组 Pod 造成的最大干扰


PodDisruptionBudgetSpec

PodDisruptionBudgetSpec 是 PodDisruptionBudget 的描述。


  • maxUnavailable (IntOrString)

    如果通过“selector”选择的最多“maxUnavailable”个 Pod 在驱逐后不可用,则允许进行驱逐,即使在驱逐的 Pod 不存在的情况下也是如此。例如,可以通过指定 0 来防止所有自愿驱逐。这是一个与“minAvailable”相互排斥的设置。

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

  • minAvailable (IntOrString)

    如果通过“selector”选择的至少“minAvailable”个 Pod 在驱逐后仍然可用,则允许进行驱逐,即使在驱逐的 Pod 不存在的情况下也是如此。因此,例如,可以通过指定“100%”来防止所有自愿驱逐。

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

  • selector (LabelSelector)

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

  • unhealthyPodEvictionPolicy (string)

    UnhealthyPodEvictionPolicy 定义了何时应考虑不健康的 Pod 进行驱逐的标准。当前实现将状态条件项类型为“Ready”,状态为“True”的 Pod 视为健康 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,如果它们在此字段中遇到未识别的策略。

    可能的枚举值

    • "AlwaysAllow" 策略意味着所有正在运行的 Pod(status.phase="Running"),但尚未健康,都被视为已中断,并且无论是否满足 PDB 中的标准,都可以被驱逐。这意味着受干扰应用程序的潜在运行 Pod 可能没有机会变得健康。健康的 Pod 将受到 PDB 的驱逐约束。
    • "IfHealthyBudget" 策略意味着正在运行的 Pod(status.phase="Running"),但尚未健康,只有在受保护的应用程序未受到干扰(status.currentHealthy 至少等于 status.desiredHealthy)时才能被驱逐。健康的 Pod 将受到 PDB 的驱逐约束。

PodDisruptionBudgetStatus

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


  • currentHealthy (int32), required

    当前健康 Pod 的数量

  • desiredHealthy (int32), required

    所需的最小健康 Pod 数量

  • disruptionsAllowed (int32), required

    当前允许的 Pod 中断数量。

  • expectedPods (int32), required

    此中断预算统计的总 Pod 数量

  • conditions ([]Condition)

    Patch 策略:在键 type 上合并

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

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

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

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

    • conditions.lastTransitionTime (Time), required

      lastTransitionTime 是条件从一个状态过渡到另一个状态的最后时间。这应该是在底层条件发生变化时的时间。如果不知道,则使用 API 字段发生变化的时间是可以接受的。

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

    • conditions.message (string), required

      message 是一个人类可读的消息,指示过渡的详细信息。这可能是一个空字符串。

    • conditions.reason (string), required

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

    • conditions.status (string), required

      条件的 status,可以是 True、False 或 Unknown。

    • conditions.type (string), required

      条件的类型,采用 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 仍然存在,PodDisruptionBudget 控制器将在一段时间后自动将其从列表中删除。如果一切顺利,此映射在大多数情况下应为空。映射中大量条目可能表明 Pod 删除存在问题。

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

  • observedGeneration (int64)

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

PodDisruptionBudgetList

PodDisruptionBudgetList 是 PodDisruptionBudget 的集合。


操作


get 读取指定的 PodDisruptionBudget

HTTP 请求

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

Parameters

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

    PodDisruptionBudget 的名称

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

    命名空间

  • pretty (在查询中): string

    pretty

响应

200 (PodDisruptionBudget): OK

401: 未授权

get 读取指定 PodDisruptionBudget 的状态

HTTP 请求

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

Parameters

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

    PodDisruptionBudget 的名称

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

    命名空间

  • pretty (在查询中): string

    pretty

响应

200 (PodDisruptionBudget): OK

401: 未授权

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

HTTP 请求

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

Parameters

响应

200 (PodDisruptionBudgetList): OK

401: 未授权

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

HTTP 请求

GET /apis/policy/v1/poddisruptionbudgets

Parameters

响应

200 (PodDisruptionBudgetList): OK

401: 未授权

create 创建 PodDisruptionBudget

HTTP 请求

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

Parameters

响应

200 (PodDisruptionBudget): OK

201 (PodDisruptionBudget): Created

202 (PodDisruptionBudget): Accepted

401: 未授权

update 替换指定的 PodDisruptionBudget

HTTP 请求

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

Parameters

响应

200 (PodDisruptionBudget): OK

201 (PodDisruptionBudget): Created

401: 未授权

update 替换指定 PodDisruptionBudget 的状态

HTTP 请求

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

Parameters

响应

200 (PodDisruptionBudget): OK

201 (PodDisruptionBudget): Created

401: 未授权

patch 部分更新指定的 PodDisruptionBudget

HTTP 请求

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

Parameters

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

    PodDisruptionBudget 的名称

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

    命名空间

  • body: Patch, 必需

  • dryRun (在查询中): string

    dryRun

  • fieldManager (在查询中): string

    fieldManager

  • fieldValidation (在查询中): string

    fieldValidation

  • force (in query): boolean

    force

  • pretty (在查询中): string

    pretty

响应

200 (PodDisruptionBudget): OK

201 (PodDisruptionBudget): Created

401: 未授权

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

HTTP 请求

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

Parameters

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

    PodDisruptionBudget 的名称

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

    命名空间

  • body: Patch, 必需

  • dryRun (在查询中): string

    dryRun

  • fieldManager (在查询中): string

    fieldManager

  • fieldValidation (在查询中): string

    fieldValidation

  • force (in query): boolean

    force

  • pretty (在查询中): string

    pretty

响应

200 (PodDisruptionBudget): OK

201 (PodDisruptionBudget): Created

401: 未授权

delete 删除 PodDisruptionBudget

HTTP 请求

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

Parameters

响应

200 (Status): 确定

202 (Status): 已接受

401: 未授权

deletecollection 删除 PodDisruptionBudget 集合

HTTP 请求

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

Parameters

响应

200 (Status): 确定

401: 未授权

本页面是自动生成的。

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

最后修改时间:2025年10月03日 下午8:48 PST:更新资源 API 1.34,添加枚举值 (24e17cbfa6)