Kubernetes HPA无法正常工作:未能解除对heapster的反应

时间:2016-06-30 15:40:22

标签: kubernetes heapster

我在裸机kubernetes集群上设置HPA时遇到问题。

毋庸置疑,DNS和monitoring服务已在运行。

让我添加一些环境信息:

# kubectl version
Client Version: version.Info{Major:"1", Minor:"2", GitVersion:"v1.2.4", GitCommit:"3eed1e3be6848b877ff80a93da3785d9034d0a4f", GitTreeState:"clean"}
Server Version: version.Info{Major:"1", Minor:"2", GitVersion:"v1.2.4", GitCommit:"3eed1e3be6848b877ff80a93da3785d9034d0a4f", GitTreeState:"clean"}
# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)

豆荚:

# kubectl describe pods php-apache-580041376-65z45
Name:           php-apache-580041376-65z45
Namespace:      default
Node:           node4/172.16.150.29
Start Time:     Thu, 30 Jun 2016 11:23:02 -0300
Labels:         pod-template-hash=580041376,run=php-apache
Status:         Running
IP:             10.20.10.7
Controllers:    ReplicaSet/php-apache-580041376
Containers:
  php-apache:
    Container ID:       docker://d9a98a539fca4b6b93b4c7e065c46e60958e52d8b8b57b1fd5438b03a8a32c23
    Image:              gcr.io/google_containers/hpa-example
    Image ID:           docker://beeb6a4e16c80f4ca23132bc2ac06d6bf6a872a9af4307fb1e9dd0f993c1f102
    Port:               80/TCP
    QoS Tier:
      cpu:      Burstable
      memory:   BestEffort
    Requests:
      cpu:              200m
    State:              Running
      Started:          Thu, 30 Jun 2016 11:23:11 -0300
    Ready:              True
    Restart Count:      0
    Environment Variables:
Conditions:
  Type          Status
  Ready         True
Volumes:
  default-token-hu1se:
    Type:       Secret (a volume populated by a Secret)
    SecretName: default-token-hu1se
Events:
  FirstSeen     LastSeen        Count   From                    SubobjectPath                   Type            Reason          Message
  ---------     --------        -----   ----                    -------------                   --------        ------          -------
  59m           59m             1       {default-scheduler }                                    Normal          Scheduled       Successfully assigned php-apache-580041376-65z45 to node4
  59m           59m             1       {kubelet node4}         spec.containers{php-apache}     Normal          Pulling         pulling image "gcr.io/google_containers/hpa-example"
  59m           59m             1       {kubelet node4}         spec.containers{php-apache}     Normal          Pulled          Successfully pulled image "gcr.io/google_containers/hpa-example"
  59m           59m             1       {kubelet node4}         spec.containers{php-apache}     Normal          Created         Created container with docker id d9a98a539fca
  59m           59m             1       {kubelet node4}         spec.containers{php-apache}     Normal          Started         Started container with docker id d9a98a539fca

HPA无法设置“当前CPU利用率”:

    # kubectl describe hpa php-apache
    Name:                           php-apache
    Namespace:                      default
    Labels:                         <none>
    Annotations:                    <none>
    CreationTimestamp:              Thu, 30 Jun 2016 11:23:29 -0300
    Reference:                      Deployment/php-apache/scale
    Target CPU utilization:         50%
    Current CPU utilization:        <unset>
    Min replicas:                   1
    Max replicas:                   10
    Events:
      FirstSeen     LastSeen        Count   From                            SubobjectPath   Type            Reason                  Message
      ---------     --------        -----   ----                            -------------   --------        ------                  -------
      1h            5s              123     {horizontal-pod-autoscaler }                    Warning         FailedGetMetrics        failed to get CPU consumption and request: failed to unmarshall heapster response: invalid character 'E' looking for beginning of value
      1h            5s              123     {horizontal-pod-autoscaler }                    Warning         FailedComputeReplicas   failed to get CPU utilization: failed to get CPU consumption and request: failed to unmarshall heapster response: invalid character 'E' looking for beginning of value

不过,您可以从Heapster服务集群IP获取CPU统计信息:

 # kubectl exec busyboxplus -- curl http://10.254.134.145/api/v1/model/namespaces/default/pods/php-apache-580041376-65z45/metrics/cpu-usage
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  1072  100  1072    0     0   932k      0 --:--:-- --:--:-- --:--:-- 1046k
    {
      "metrics": [
       {
        "timestamp": "2016-06-30T15:12:00Z",
        "value": 0
       },
       {
        "timestamp": "2016-06-30T15:13:00Z",
        "value": 0
       },
       {
        "timestamp": "2016-06-30T15:14:00Z",
        "value": 0
       },
       {
        "timestamp": "2016-06-30T15:15:00Z",
        "value": 0
       },
       {
        "timestamp": "2016-06-30T15:16:00Z",
        "value": 0
       },
       {
        "timestamp": "2016-06-30T15:17:00Z",
        "value": 0
       },
       {
        "timestamp": "2016-06-30T15:18:00Z",
        "value": 0
       },
       {
        "timestamp": "2016-06-30T15:19:00Z",
        "value": 0
       },
       {
        "timestamp": "2016-06-30T15:20:00Z",
        "value": 0
       },
       {
        "timestamp": "2016-06-30T15:21:00Z",
        "value": 0
       },
       {
        "timestamp": "2016-06-30T15:22:00Z",
        "value": 0
       },
       {
        "timestamp": "2016-06-30T15:23:00Z",
        "value": 0
       },
       {
        "timestamp": "2016-06-30T15:24:00Z",
        "value": 0
       },
       {
        "timestamp": "2016-06-30T15:25:00Z",
        "value": 0
       },
       {
        "timestamp": "2016-06-30T15:26:00Z",
        "value": 0
       }
      ],
      "latestTimestamp": "2016-06-30T15:26:00Z"
     }[

有人可以帮我解决这个问题吗?

提前致谢。

1 个答案:

答案 0 :(得分:0)

要使其工作,主节点也需要是一个节点。 请参阅:https://github.com/openshift/origin/issues/6293