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.2.4.5. 使用 CLI 了解 pod 横向自动扩展状态条件
您可以使用设置的状态条件来判断 pod 横向自动扩展 (HPA) 是否能够缩放,以及目前是否受到某种方式的限制。
					HPA 状态条件可通过 v2beta1 版的自动扩展 API 使用。
				
HPA 可以通过下列状态条件给予响应:
AbleToScale条件指示 HPA 是否能够获取和更新指标,以及是否有任何与退避相关的条件阻碍了缩放。- 
									
True条件表示允许缩放。 - 
									
False条件表示因为指定原因不允许缩放。 
- 
									
 ScalingActive条件指示 HPA 是否已启用(例如,目标的副本数不为零),并且可以计算所需的指标。- 
									
True条件表示指标工作正常。 - 
									
False条件通常表示获取指标时出现问题。 
- 
									
 ScalingLimited条件表示所需的规模由 pod 横向自动扩展限定最大或最小限制。- 
									
True条件表示您需要提高或降低最小或最大副本数才能进行缩放。 False条件表示允许请求的缩放。oc describe hpa cm-test
$ oc describe hpa cm-testCopy to Clipboard Copied! Toggle word wrap Toggle overflow 输出示例
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
 - pod 横向自动扩展状态消息。
 
- 
									
 
下例中是一个无法缩放的 pod:
输出示例
下例中是一个无法获得缩放所需指标的 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: failed to get cpu utilization: unable to get metrics for resource cpu: no metrics returned from resource metrics API
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: failed to get cpu utilization: unable to get metrics for resource cpu: no metrics returned from resource metrics API
下例中是一个请求的自动缩放低于所需下限的 pod:
输出示例
2.4.5.1. 使用 CLI 查看 pod 横向自动扩展状态条件 复制链接链接已复制到粘贴板!
您可以查看 pod 横向自动扩展 (HPA) 对 pod 设置的状态条件。
							pod 横向自动扩展状态条件可通过 v2beta1 版的自动扩展 API 使用。
						
先决条件
							要使用 pod 横向自动扩展,您的集群管理员必须已经正确配置了集群指标。您可以使用 oc describe PodMetrics <pod-name> 命令来判断是否已配置了指标。如果配置了指标,输出类似于以下示例,其中 Usage 下列出了 Cpu 和 Memory。
						
oc describe PodMetrics openshift-kube-scheduler-ip-10-0-135-131.ec2.internal
$ oc describe PodMetrics openshift-kube-scheduler-ip-10-0-135-131.ec2.internal
输出示例
流程
要查看 pod 上的状态条件,请使用以下命令并提供 pod 的名称:
oc describe hpa <pod-name>
$ oc describe hpa <pod-name>
例如:
oc describe hpa cm-test
$ oc describe hpa cm-test
						这些条件会出现在输出中的 Conditions 字段里。
					
输出示例