0

我正在尝试在我的 kubernetes 集群中设置自动缩放。在为它部署 heapster 和服务之后。我面临以下错误。

horizontal.go:99] Failed to reconcile nginx: failed to compute desired number of replicas based on CPU utilization for Deployment/default/nginx: failed to get CPU utilization: failed to get CPU consumption and request: failed to unmarshall heapster response: json: cannot unmarshal object into Go value of type []v1alpha1.PodMetrics
Sep 09 18:15:37 dev1-132869446-3-157772786 kube-controller-manager[27951]: I0909 18:15:37.432445 27951 horizontal.go:403] Successfully updated status for nginx
Sep 09 18:15:37 dev1-132869446-3-157772786 kube-controller-manager[27951]: }
Sep 09 18:15:37 dev1-132869446-3-157772786 kube-controller-manager[27951]: ]
Sep 09 18:15:37 dev1-132869446-3-157772786 kube-controller-manager[27951]: }
Sep 09 18:15:37 dev1-132869446-3-157772786 kube-controller-manager[27951]: ]
Sep 09 18:15:37 dev1-132869446-3-157772786 kube-controller-manager[27951]: }
Sep 09 18:15:37 dev1-132869446-3-157772786 kube-controller-manager[27951]: }
Sep 09 18:15:37 dev1-132869446-3-157772786 kube-controller-manager[27951]: "memory": "1512Ki"
Sep 09 18:15:37 dev1-132869446-3-157772786 kube-controller-manager[27951]: "cpu": "0",
Sep 09 18:15:37 dev1-132869446-3-157772786 kube-controller-manager[27951]: "usage": {
Sep 09 18:15:37 dev1-132869446-3-157772786 kube-controller-manager[27951]: "name": "nginx",
Sep 09 18:15:37 dev1-132869446-3-157772786 kube-controller-manager[27951]: {
Sep 09 18:15:37 dev1-132869446-3-157772786 kube-controller-manager[27951]: "containers": [
Sep 09 18:15:37 dev1-132869446-3-157772786 kube-controller-manager[27951]: "window": "1m0s",
Sep 09 18:15:37 dev1-132869446-3-157772786 kube-controller-manager[27951]: "timestamp": "2016-09-09T18:15:00Z",
Sep 09 18:15:37 dev1-132869446-3-157772786 kube-controller-manager[27951]: },
Sep 09 18:15:37 dev1-132869446-3-157772786 kube-controller-manager[27951]: "creationTimestamp": "2016-09-09T18:15:37Z"
Sep 09 18:15:37 dev1-132869446-3-157772786 kube-controller-manager[27951]: "namespace": "default",
Sep 09 18:15:37 dev1-132869446-3-157772786 kube-controller-manager[27951]: "name": "nginx-24809263-3idn3",
Sep 09 18:15:37 dev1-132869446-3-157772786 kube-controller-manager[27951]: "metadata": {
Sep 09 18:15:37 dev1-132869446-3-157772786 kube-controller-manager[27951]: {
Sep 09 18:15:37 dev1-132869446-3-157772786 kube-controller-manager[27951]: "items": [
Sep 09 18:15:37 dev1-132869446-3-157772786 kube-controller-manager[27951]: "metadata": {},
Sep 09 18:15:37 dev1-132869446-3-157772786 kube-controller-manager[27951]: I0909 18:15:37.424164 27951 metrics_client.go:166] Heapster metrics result: {

Heapster 成功地从 pod 中提取指标,并且可以在

http://master:8080/api/v1/proxy/namespaces/kube-system/services/heapster/apis/metrics/v1alpha1/namespaces/default/pods

{
"metadata": {},
"items": [
{
"metadata": {
"name": "nginx-24809263-3idn3",
"namespace": "default",
"creationTimestamp": "2016-09-10T02:57:03Z"
},
"timestamp": "2016-09-10T02:56:00Z",
"window": "1m0s",
"containers": [
{
"name": "nginx",
"usage": {
"cpu": "0",
"memory": "1400Ki"
}
}
]
}
]
}

我在所有 heapster 版本(heapster:canary, v1.2.0-beta.2, v1.1.0)中都遇到了这个问题

以下是有关我的环境的更多详细信息

Kubernetes版本客户端版本:version.Info{Major:"1", Minor:"3", GitVersion:"v1.3.5", GitCommit:"b0deb2eb8f4037421077f77cb163dbb4c0a2a9f5", GitTreeState:"clean", BuildDate:"2016-08-11T20: 29:08Z", GoVersion:"go1.6.2", Compiler:"gc", Platform:"linux/amd64"} 服务器版本: version.Info{Major:"1", Minor:"3", GitVersion:"v1 .3.5", GitCommit:"b0deb2eb8f4037421077f77cb163dbb4c0a2a9f5", GitTreeState:"clean", BuildDate:"2016-08-11T20:21:58Z", GoVersion:"go1.6.2", 编译器:"gc", 平台:"linux/amd64 "}

自定义/本地集群

操作系统(例如来自 /etc/os-release):NAME="CentOS Linux" VERSION="7 (Core)" 内核(例如 uname -a):Linux dev1-132869446-3-157772786 3.10.0-327.13.1。 el7.x86_64 #1 SMP 2016 年 3 月 31 日星期四 16:04:38 UTC x86_64 x86_64 x86_64 GNU/Linux

自动缩放 (HPA)中的建议未能获得 CPU 消耗:无法将对象解组为 []v1alpha1 类型的 Go 值。PodMetrics无法解决问题

4

1 回答 1

1

这是由于版本不匹配 Kubernetes 1.3.5 与 Heapster v1.1.0-beta2 一起使用

于 2016-09-10T15:40:50.433 回答