kubernetes hpa不能获得cpu消耗

我正在尝试configurationkubernetes水平吊舱autoscaling。 我的部署的定义在这里 。

我开始heapster部署和heapster服务如下:

# kubectl run heapster --namespace=kube-system --image=gcr.io/google_containers/heapster:v1.0.2 --command -- /heapster --source=kubernetes:http://192.168.122.159:8080?inClusterConfig=false --sink=log # kubectl expose deployment heapster --port=80 --target-port=8082 --name=heapster --namespace=kube-system 

hpa是这样创build的:

 # kubectl autoscale deployment nginx-rc --max=5 --cpu-percent=25 

heapster似乎运行良好。 这里是日志 。

毕竟,hpa没有收到CPU利用率的任何数据。

 # kubectl describe hpa Name: nginx-rc Namespace: default Labels: <none> Annotations: <none> CreationTimestamp: Sat, 04 Jun 2016 07:23:03 -0400 Reference: Deployment/nginx-rc/scale Target CPU utilization: 25% Current CPU utilization: <unset> Min replicas: 1 Max replicas: 5 Events: FirstSeen LastSeen Count From SubobjectPath Type Reason Message --------- -------- ----- ---- ------------- -------- ------ ------- 9m 7s 22 {horizontal-pod-autoscaler } Warning FailedGetMetrics failed to get CPU consumption and request: metrics obtained for 0/1 of pods 9m 7s 22 {horizontal-pod-autoscaler } Warning FailedComputeReplicas failed to get CPU utilization: failed to get CPU consumption and request: metrics obtained for 0/1 of pods 

控制器pipe理器日志有一个循环线:

 Jun 04 07:21:33 master kube-controller-manager[8202]: W0604 07:21:33.079677 8202 horizontal.go:108] Failed to reconcile nginx-rc: failed to compute desired number of replicas based on CPU utilization for Deployment/default/nginx-rc: failed to get CPU utilization: failed to get CPU consumption and request: metrics obtained for 0/1 of pods 

有人能指出这个问题的性质吗?

问题很可能是您没有在群集中运行DNS。

HPA目前使用heapster服务名称来读取指标。 您已经正确创build了它,但HPA控制器无法将服务名称parsing为IP地址,因为群集中没有DNS。

我已经创build问题https://github.com/kubernetes/kubernetes/issues/27044有更多的信息事件,这将有助于用户/pipe理员更好地理解问题&#x3002;

我怀疑这是因为你没有运行heapster服务。 Horizo​​ntalPodAutoscaler的度量客户端尝试从kube-system名称空间中的名为heapster的服务获取度量标准。 您可以在这里查看默认的Heapster定义。

如果这不是问题,请在主节点上查找/var/log/kube-controller-manager 。 特别是,查找failed to get pods metrics条目。