【问题标题】:Kubernetes AutoscalingKubernetes 自动缩放
【发布时间】:2018-11-06 22:31:00
【问题描述】:

我的集群上安装了 Kubernetes v1.12.1。 我从以下 repo 下载了 metrics-server: https://github.com/kubernetes-incubator/metrics-server

然后运行以下命令:

kubectl create -f metrics-server/deploy/1.8+/

然后我尝试使用以下方法自动缩放部署:

kubectl autoscale deployment example-app-tier --min 1 --max 3 --cpu-percent 70 --spacename example

但这里的目标显示未知/70%

kubectl get hpa --spacename example
NAMESPACE   NAME               REFERENCE                     TARGETS         MINPODS   MAXPODS   REPLICAS   AGE
example example-app-tier   Deployment/example-app-tier   <unknown>/70%   1         3         1          3h35m

当我尝试运行 kubectl 顶级节点或 pod 时,我收到一条错误消息:

error: Metrics not available for pod default/pi-ss8j6, age: 282h48m5.334137739s

所以我正在寻找任何教程,帮助我逐步启用使用 metrics-server 或 Prometheus(而不是 Heapster,因为它已被弃用且不再受支持)

谢谢!

【问题讨论】:

    标签: kubernetes prometheus autoscaling


    【解决方案1】:

    您需要向 API 服务器注册您的指标服务器并确保它们能够通信。

    https://github.com/kubernetes/kubernetes/issues/59438

    如果已经完成,您需要查看您的 k8s 版本中 kubectl top 命令的帮助,该命令可能默认使用 heapster ,您可能需要告诉它使用新服务。

    https://github.com/kubernetes/kubernetes/pull/56206

    从帮助命令看来,它尚未移植到新的度量服务器,默认情况下仍在寻找 heapster。

    C02W84XMHTD5:tmp iahmad$ kubectl top node --help
    Display Resource (CPU/Memory/Storage) usage of nodes. 
    
    The top-node command allows you to see the resource consumption of nodes.
    
    Aliases:
    node, nodes, no
    
    Examples:
      # Show metrics for all nodes
      kubectl top node
    
      # Show metrics for a given node
      kubectl top node NODE_NAME
    
    Options:
          --heapster-namespace='kube-system': Namespace Heapster service is located in
          --heapster-port='': Port name in service to use
          --heapster-scheme='http': Scheme (http or https) to connect to Heapster as
          --heapster-service='heapster': Name of Heapster service
      -l, --selector='': Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l
    key1=value1,key2=value2)
    
    Usage:
      kubectl top node [NAME | -l label] [options]
    
    Use "kubectl options" for a list of global command-line options (applies to all commands).
    

    注意:我使用的是 1.10 ,可能在你的版本中,选项不同

    【讨论】:

    • 那么我应该如何运行 top 命令以使其链接到指标服务器,如果它出现在名为 v1beta1.metrics.k8s.io 的 apiservices 列表中?
    猜你喜欢
    • 2018-12-13
    • 2020-11-25
    • 2021-04-07
    • 2017-01-18
    • 2020-07-09
    • 2021-01-26
    • 2019-08-07
    • 2016-09-04
    • 1970-01-01
    相关资源
    最近更新 更多