开发者社区> 问答> 正文

k8s的hpa报错 missing request for cpu

使用kubeadm搭建的k8s,版本是1.14.0, 从github下载的文件搭建了metrics-server, hpa创建好后报错 missing request for cpu

被监控的pod增加了cpu的限制

    image: httpd:latest
    resources: 
       requests:
          cpu: "100m"
       limits:
          cpu: "200m"

metrics server正常运行,搭建的时候增加了

--kubelet-insecure-tls
--kubelet-preferred-address-types=InternalIP

kubectl 可以得到node和pod的资源使用

[root@temp-01 tmp]# kubectl top nodes
NAME      CPU(cores)   CPU%   MEMORY(bytes)   MEMORY%   
temp-01   79m          3%     982Mi           28%       
temp-02   42m          2%     587Mi           16%       
temp-03   24m          1%     463Mi           13%      
[root@temp-01 tmp]# kubectl top pods
NAME                             CPU(cores)   MEMORY(bytes)   
busybox                          0m           0Mi             
httpd-6c8f566dc8-9mscd           1m           16Mi            
httpd-6c8f566dc8-d5lf2           1m           12Mi            
httpd-6c8f566dc8-zhwh4           1m           18Mi            
httpd-hpatest-7899864fb8-c6dn4   1m           20Mi  

hpa和httpd在同一个namspaces内,目前报错 missing request for cpu

[root@temp-01 tmp]# kubectl describe  hpa
Name:                                                  httpd-hpa
Namespace:                                             default
Labels:                                                <none>
Annotations:                                           kubectl.kubernetes.io/last-applied-configuration:
                                                         {"apiVersion":"autoscaling/v2beta1","kind":"HorizontalPodAutoscaler","metadata":{"annotations":{},"name":"httpd-hpa","namespace":"default"...
CreationTimestamp:                                     Thu, 13 Feb 2020 12:25:37 +0800
Reference:                                             Deployment/httpd-hpatest
Metrics:                                               ( current / target )
  resource memory on pods:                             <unknown> / 200Mi
  resource cpu on pods  (as a percentage of request):  <unknown> / 80%
Min replicas:                                          1
Max replicas:                                          3
Deployment pods:                                       1 current / 0 desired
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: missing request for cpu
Events:
  Type     Reason                        Age                  From                       Message
  ----     ------                        ----                 ----                       -------
  Warning  FailedComputeMetricsReplicas  23m (x12 over 26m)   horizontal-pod-autoscaler  failed to get cpu utilization: missing request for cpu
  Warning  FailedGetResourceMetric       72s (x101 over 26m)  horizontal-pod-autoscaler  missing request for cpu

我怀疑是hpa从metrics server获取资源使用量的时候,使用了https请求,但具体的配置和日志都无从下手,请问如何解决谢谢

展开
收起
dogstar 2020-02-13 12:57:52 6145 0
1 条回答
写回答
取消 提交回答
  • 已找到问题,metrics-server版本和yaml的格式不符,使用0.3.6版本已确认可实现

    2020-02-14 19:41:04
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
ACK 云原生弹性方案—云原生时代的加速器 立即下载
ACK集群类型选择最佳实践 立即下载
企业运维之云原生和Kubernetes 实战 立即下载

相关镜像