【问题标题】:Kubernetes target cpu utilization policyKubernetes 目标 cpu 使用策略
【发布时间】:2019-02-10 23:53:02
【问题描述】:

我无法使用 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
  message: 'the HPA was unable to compute the replica count: unable to get metrics
    for resource cpu: unable to fetch metrics from resource metrics API: the server
    could not find the requested resource (get pods.metrics.k8s.io)'
  reason: FailedGetResourceMetric

我已验证指标服务器正在运行。当我检查 hpa 时,我得到以下信息:

NAME      REFERENCE           TARGETS         MINPODS   MAXPODS      REPLICAS   AGE 
pod-name    Deployment/pod-name   <unknown>/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

看起来 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]

【问题讨论】:

    标签: kubernetes metrics autoscaling kubectl


    【解决方案1】:

    由于证书无效,指标服务器似乎无法从 Kubelet 端点接收指标。

    尝试向指标服务器添加以下参数:--kubelet-insecure-tls

    【讨论】:

    • 根据文档,这不是必需的。 > --tls-cert-file, --tls-private-key-file:服务证书和密钥文件。如果不指定,将生成自签名证书,但建议您在生产中使用非自签名证书
    • 尝试将以下参数添加到度量服务器:--kubelet-insecure-tls
    猜你喜欢
    • 2019-06-11
    • 2019-11-28
    • 2019-06-24
    • 2020-08-11
    • 2019-11-26
    • 1970-01-01
    • 2017-04-27
    • 2021-04-28
    • 2018-11-08
    相关资源
    最近更新 更多