Kubernetes目标cpu利用率策略
我无法使用TargetCPUUUtilization设置使自动缩放工作。我的配置如下:Kubernetes目标cpu利用率策略,kubernetes,metrics,autoscaling,kubectl,Kubernetes,Metrics,Autoscaling,Kubectl,我无法使用TargetCPUUUtilization设置使自动缩放工作。我的配置如下: apiVersion: autoscaling/v2beta1 kind: HorizontalPodAutoscaler metadata: name: pod namespace: pod spec: minReplicas: 1 maxReplicas: 5 scaleTargetRef: apiVersion: apps/v1 kind: Deploymen
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
我已验证metrics服务器是否正在运行。当我检查hpa时,我得到以下信息:
NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
pod-name Deployment/pod-name <unknown>/10% 1 5 1 15h
看起来POD无法访问metrics服务器
在metrics服务器上的日志:
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端点接收度量
尝试将以下参数添加到metrics服务器:
--kubelet不安全tls
根据文档,它不是必需的。>--tls证书文件,--tls私钥文件:服务证书和密钥文件。如果未指定,将生成自签名证书,但建议您在Production中使用非自签名证书尝试将以下参数添加到metrics server:--kubelet Unsecure tls
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
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]