首页 文章

Kubernetes Autoscaling

提问于
浏览
1

我在我的集群上安装了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

但这里的目标显示unkown / 70 kubectl获取hpa --spacename示例NAMESPACE NAME参考目标MINOPODES MAXPODS REPLICAS AGE示例示例-app-tier部署/示例-app-tier / 70%1 3 1 3h35m

当我尝试运行kubectl顶级节点或pod时,我收到错误消息:错误:指标不适用于pod default / pi-ss8j6,年龄:282h48m5.334137739s

所以我正在寻找任何帮助我一步一步地使用metrics-server或Prometheus进行自动调节的教程(而不是Heapster,因为它已被弃用,不再受支持)

谢谢!

1 回答

  • 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).
    

    note: 我使用1.10,也许在您的版本中,选项不同

相关问题