我无法让自动伸缩在targetcpuutilization设置下工作。我的配置如下:
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: pod
namespace: pod
spec:
minReplicas: 1
maxReplicas: 5
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: pod
metrics:
- type: Resource
resource:
name: cpu
targetAverageUtilization: 10
消息:‘HPA无法计算副本计数:无法获取资源的度量cpu:无法从资源度量获取度量API:服务器找不到请求的资源(获取pods.metrics.k8s.io)’原因: FailedGetResourceMetric
我已经验证了指标服务器正在运行。当我检查hpa时,我得到以下信息:
名称引用目标MINPODS MAXPODS复制副本年龄pod-name部署/pod- NAME /10% 1 5 1 15h
命名空间的事件日志显示如下:
LAST SEEN FIRST SEEN COUNT NAME KIND SUBOBJECT TYPE REASON SOURCE MESSAGE
46m 15h 1721 pod-name.155162c884d417be HorizontalPodAutoscaler Warning FailedComputeMetricsReplicas horizontal-pod-autoscaler failed to get cpu utilization: unable to get metrics for resource cpu: no metrics returned from resource metrics API
1m 15h 1811 pod-name.155162c884a5caa2 HorizontalPodAutoscaler Warning FailedGetResourceMetric horizontal-pod-autoscaler unable to get metrics for resource cpu: no metrics returned from resource metrics API
看起来pods无法到达指标服务器。
指标服务器上的日志:
unable to fully collect metrics: [unable to fully scrape metrics from source kubelet_summary:host.com: unable to fetch metrics from Kubelet host.com (host.com): Get https://host.com:10250/stats/summary/: x509: certificate signed by unknown authority, unable to fully scrape metrics from source
kubelet_summary:host.ibaset.com: unable to fetch metrics from Kubelet host.ibaset.com (host.ibaset.com): Get https://host.com:10250/stats/summary/: x509: certificate signed by unknown authority, unable to fully scrape metrics from source kubelet_summary:host.com: unable to fetch metrics from Kubelet host.com (host.com): Get https://host.com:10250/stats/summary/: x509: certificate signed by unknown authority]
https://stackoverflow.com/questions/52191838
复制相似问题