我无法使用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
命名空间的事件日志显示如下:
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
似乎Pod无法访问指标服务器。
登录指标服务器:
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]
最佳答案
指标服务器似乎由于证书无效而无法从Kubelet端点接收指标。
尝试向度量服务器添加以下参数:--kubelet-insecure-tls
关于kubernetes - Kubernetes目标CPU利用率政策,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52191838/