运行 kubernetes 自动标量 [英] Running kubernetes autoscalar

查看:15
本文介绍了运行 kubernetes 自动标量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用以下规范运行的复制控制器:

I have a replication controller running with the following spec:

apiVersion: v1
kind: ReplicationController
metadata:
  name: owncloud-controller
spec:
  replicas: 1
  selector:
    app: owncloud
  template:
    metadata:
      labels:
        app: owncloud
    spec:
      containers:
      - name: owncloud
        image: adimania/owncloud9-centos7
        ports:
          - containerPort: 80
        volumeMounts:
          - name: userdata
            mountPath: /var/www/html/owncloud/data
        resources:
          requests:
            cpu: 400m
      volumes:
        - name: userdata
          hostPath:
            path: /opt/data

现在我使用自动缩放命令运行 hpa.

Now I run a hpa using autoscale command.

$ kubectl autoscale rc owncloud-controller --max=5 --cpu-percent=10

我也使用 kubernetes run 命令启动了 heapster.

I have also started heapster using kubernetes run command.

$ kubectl run heapster --image=gcr.io/google_containers/heapster:v1.0.2 --command -- /heapster --source=kubernetes:http://192.168.0.103:8080?inClusterConfig=false --sink=log

毕竟,自动缩放从未启动.从日志中,似乎没有报告实际的 CPU 利用率.

After all this, the autoscaling never kicks in. From logs, it seems that the actual CPU utilization is not getting reported.

$ kubectl describe hpa owncloud-controller
Name:               owncloud-controller
Namespace:          default
Labels:             <none>
Annotations:            <none>
CreationTimestamp:      Thu, 26 May 2016 14:24:51 +0530
Reference:          ReplicationController/owncloud-controller/scale
Target CPU utilization:     10%
Current CPU utilization:    <unset>
Min replicas:           1
Max replicas:           5
ReplicationController pods: 1 current / 1 desired
Events:
  FirstSeen LastSeen    Count   From                SubobjectPath   Type        Reason          Message
  --------- --------    -----   ----                -------------   --------    ------          -------
  44m       8s      92  {horizontal-pod-autoscaler }            Warning     FailedGetMetrics    failed to get CPU consumption and request: metrics obtained for 0/1 of pods
  44m       8s      92  {horizontal-pod-autoscaler }            Warning     FailedComputeReplicas   failed to get CPU utilization: failed to get CPU consumption and request: metrics obtained for 0/1 of pods

我在这里错过了什么?

推荐答案

很可能 heapster 在错误的命名空间(默认")中运行.HPA 期望 heapster 位于kube-system"命名空间中.请将 --namespace=kube-system 添加到 kubectl run heapster 命令中.

Most probably heapster is running in a wrong namespace ("default"). HPA expects heapster to be in "kube-system" namespace. Please, add --namespace=kube-system to kubectl run heapster command.

这篇关于运行 kubernetes 自动标量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆