HorizontalPodAutoscaler

水平 Pod 自动扩缩器的配置。

apiVersion: autoscaling/v1

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

HorizontalPodAutoscaler

水平 Pod 自动扩缩器的配置。


HorizontalPodAutoscalerSpec

水平 Pod 自动扩缩器的规格。


  • maxReplicas (int32),必填

    maxReplicas 是自动扩缩器可以设置的 Pod 数量上限;不能小于 MinReplicas。

  • scaleTargetRef (CrossVersionObjectReference),必填

    指向要扩缩的资源的引用;水平 Pod 自动扩缩器将通过其 Scale 子资源学习当前资源消耗并设置所需的 Pod 数量。

    CrossVersionObjectReference 包含足够的信息,让您可以识别所引用的资源。

  • minReplicas (int32)

    minReplicas 是自动扩缩器可以缩小的副本数量下限。默认值为 1 个 Pod。如果启用了 alpha 特性门 HPAScaleToZero 且至少配置了一个 Object 或 External 指标,则 minReplicas 允许为 0。只要至少有一个指标值可用,扩缩就会一直活跃。

  • targetCPUUtilizationPercentage (int32)

    targetCPUUtilizationPercentage 是所有 Pod 的目标平均 CPU 利用率(表示为请求 CPU 的百分比);如果未指定,将使用默认的自动扩缩策略。

HorizontalPodAutoscalerStatus

水平 Pod 自动扩缩器的当前状态


  • currentReplicas (int32),必填

    currentReplicas 是此自动扩缩器管理的 Pod 的当前副本数量。

  • desiredReplicas (int32),必填

    desiredReplicas 是此自动扩缩器管理的 Pod 的期望副本数量。

  • currentCPUUtilizationPercentage (int32)

    currentCPUUtilizationPercentage 是所有 Pod 的当前平均 CPU 利用率,表示为请求 CPU 的百分比,例如 70 表示平均每个 Pod 现在使用了其请求 CPU 的 70%。

  • lastScaleTime (Time)

    lastScaleTime 是 HorizontalPodAutoscaler 上次扩缩 Pod 数量的时间;自动扩缩器使用它来控制 Pod 数量更改的频率。

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

  • observedGeneration (int64)

    observedGeneration 是此自动扩缩器观察到的最新生成。

HorizontalPodAutoscalerList

水平 Pod 自动扩缩器对象列表。


  • apiVersion: autoscaling/v1

  • kind: HorizontalPodAutoscalerList

  • metadata (ListMeta)

    标准列表元数据。

  • items ([]HorizontalPodAutoscaler),必填

    items 是水平 Pod 自动扩缩器对象的列表。

操作


get 读取指定的 HorizontalPodAutoscaler

HTTP 请求

GET /apis/autoscaling/v1/namespaces/{namespace}/horizontalpodautoscalers/{name}

参数

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

    HorizontalPodAutoscaler 的名称

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

    命名空间

  • pretty (在查询中): string

    pretty

响应

200 (HorizontalPodAutoscaler): 成功

401: 未授权

get 读取指定 HorizontalPodAutoscaler 的状态

HTTP 请求

GET /apis/autoscaling/v1/namespaces/{namespace}/horizontalpodautoscalers/{name}/status

参数

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

    HorizontalPodAutoscaler 的名称

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

    命名空间

  • pretty (在查询中): string

    pretty

响应

200 (HorizontalPodAutoscaler): 成功

401: 未授权

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

HTTP 请求

GET /apis/autoscaling/v1/namespaces/{namespace}/horizontalpodautoscalers

参数

响应

200 (HorizontalPodAutoscalerList): 成功

401: 未授权

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

HTTP 请求

GET /apis/autoscaling/v1/horizontalpodautoscalers

参数

响应

200 (HorizontalPodAutoscalerList): 成功

401: 未授权

create 创建一个 HorizontalPodAutoscaler

HTTP 请求

POST /apis/autoscaling/v1/namespaces/{namespace}/horizontalpodautoscalers

参数

响应

200 (HorizontalPodAutoscaler): 成功

201 (HorizontalPodAutoscaler): 已创建

202 (HorizontalPodAutoscaler): 已接受

401: 未授权

update 替换指定的 HorizontalPodAutoscaler

HTTP 请求

PUT /apis/autoscaling/v1/namespaces/{namespace}/horizontalpodautoscalers/{name}

参数

响应

200 (HorizontalPodAutoscaler): 成功

201 (HorizontalPodAutoscaler): 已创建

401: 未授权

update 替换指定的 HorizontalPodAutoscaler 的状态

HTTP 请求

PUT /apis/autoscaling/v1/namespaces/{namespace}/horizontalpodautoscalers/{name}/status

参数

响应

200 (HorizontalPodAutoscaler): 成功

201 (HorizontalPodAutoscaler): 已创建

401: 未授权

patch 部分更新指定的 HorizontalPodAutoscaler

HTTP 请求

PATCH /apis/autoscaling/v1/namespaces/{namespace}/horizontalpodautoscalers/{name}

参数

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

    HorizontalPodAutoscaler 的名称

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

    命名空间

  • body: Patch,必需

  • dryRun (在查询中): string

    dryRun

  • fieldManager (在查询中): string

    fieldManager

  • fieldValidation (在查询中): string

    fieldValidation

  • force (在查询中): boolean

    force

  • pretty (在查询中): string

    pretty

响应

200 (HorizontalPodAutoscaler): 成功

201 (HorizontalPodAutoscaler): 已创建

401: 未授权

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

HTTP 请求

PATCH /apis/autoscaling/v1/namespaces/{namespace}/horizontalpodautoscalers/{name}/status

参数

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

    HorizontalPodAutoscaler 的名称

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

    命名空间

  • body: Patch,必需

  • dryRun (在查询中): string

    dryRun

  • fieldManager (在查询中): string

    fieldManager

  • fieldValidation (在查询中): string

    fieldValidation

  • force (在查询中): boolean

    force

  • pretty (在查询中): string

    pretty

响应

200 (HorizontalPodAutoscaler): 成功

201 (HorizontalPodAutoscaler): 已创建

401: 未授权

delete 删除一个 HorizontalPodAutoscaler

HTTP 请求

DELETE /apis/autoscaling/v1/namespaces/{namespace}/horizontalpodautoscalers/{name}

参数

响应

200 (Status): OK

202 (Status): 已接受

401: 未授权

deletecollection 删除 HorizontalPodAutoscaler 集合

HTTP 请求

DELETE /apis/autoscaling/v1/namespaces/{namespace}/horizontalpodautoscalers

参数

响应

200 (Status): OK

401: 未授权

本页面是自动生成的。

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

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