This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.26.7. 查看 Horizontal Pod Autoscaler
查看 pod 横向自动扩展的状态:
使用
oc get
命令查看 CPU 使用率和 pod 限制的信息:oc get hpa/hpa-resource-metrics-cpu
$ oc get hpa/hpa-resource-metrics-cpu NAME REFERENCE TARGET CURRENT MINPODS MAXPODS AGE hpa-resource-metrics-cpu DeploymentConfig/default/frontend/scale 80% 79% 1 10 8d
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 输出包括:
- Target。部署配置控制的所有 Pod 的目标平均 CPU 使用率。
- Current。由部署配置控制的所有 Pod 的当前 CPU 使用率。
- Minpods/Maxpods.自动缩放器可设置的最小和最大副本数。
使用
oc describe
命令获取有关 pod 横向自动扩展对象的详细信息。Copy to Clipboard Copied! Toggle word wrap Toggle overflow
26.7.1. 查看 Horizontal Pod Autoscaler 状态条件 复制链接链接已复制到粘贴板!
您可以使用状态条件集来确定横向 pod 自动缩放器是否能够扩展以及是否以任何方式限制它。
pod 横向自动扩展状态条件可通过 v2beta1
版的自动扩展 API 使用:
kubernetesMasterConfig: ... apiServerArguments: runtime-config: - apis/autoscaling/v2beta1=true
kubernetesMasterConfig:
...
apiServerArguments:
runtime-config:
- apis/autoscaling/v2beta1=true
设定了以下状态条件:
AbleToScale
指示 pod 横向自动扩展是否可以获取和更新扩展,以及任何 backoff 条件是否阻止扩展。-
True
条件表示允许缩放。 -
False
条件表示因为指定原因不允许缩放。
-
ScalingActive
指示 pod 横向自动扩展是否已启用(目标的副本计数不为零),并且可以计算所需的扩展。-
True
条件表示指标工作正常。 -
False
条件通常表示获取指标时出现问题。
-
ScalingLimited
表示不允许自动扩展,因为达到最大或最小副本数。-
True
条件表示您需要提高或降低最小或最大副本数才能进行缩放。 -
False
条件表示允许请求的缩放。
-
如果需要添加或编辑这一行,请重启 OpenShift Container Platform 服务:
systemctl restart atomic-openshift-master-api atomic-openshift-master-controllers
# systemctl restart atomic-openshift-master-api atomic-openshift-master-controllers
要查看影响 pod 横向自动扩展的条件,请使用 oc describe hpa
。条件会出现在 status.conditions
字段中:
- 1
- pod 横向自动扩展状态消息。
-
AbleToScale
条件指示 HPA 是否能够获取和更新扩展,以及任何与退避相关的条件是否可防止扩展。 -
ScalingActive
条件指示 HPA 是否已启用(例如,目标副本数不为零),并且可以计算所需的扩展。False 的状态通常表示获取指标时出现问题。 -
ScalingLimited
条件表示所需的规模由 pod 横向自动扩展限定最大或最小限制。True
状态通常表示您可能需要提高或降低 pod 横向自动扩展中的最小和最大副本数限制。
-
下例中是一个无法缩放的 pod:
Conditions: Type Status Reason Message ---- ------ ------ ------- AbleToScale False FailedGetScale the HPA controller was unable to get the target's current scale: replicationcontrollers/scale.extensions "hello-hpa-cpu" not found
Conditions:
Type Status Reason Message
---- ------ ------ -------
AbleToScale False FailedGetScale the HPA controller was unable to get the target's current scale: replicationcontrollers/scale.extensions "hello-hpa-cpu" not found
下例中是一个无法获得缩放所需指标的 pod:
Conditions: Type Status Reason Message ---- ------ ------ ------- AbleToScale True SucceededGetScale the HPA controller was able to get the target's current scale ScalingActive False FailedGetResourceMetric the HPA was unable to compute the replica count: unable to get metrics for resource cpu: no metrics returned from heapster
Conditions:
Type Status Reason Message
---- ------ ------ -------
AbleToScale True SucceededGetScale the HPA controller was able to get the target's current scale
ScalingActive False FailedGetResourceMetric the HPA was unable to compute the replica count: unable to get metrics for resource cpu: no metrics returned from heapster
下例中是一个请求的自动缩放低于所需下限的 pod: