在kubernetes中安装heapster或metric服务器以进行水平pod自动缩放

时间:2018-12-10 04:49:20

标签: kubernetes digital-ocean autoscaling kubernetes-pod heapster

如何安装heapster或指标服务器以在kubernetes中获取pod指标。 我需要那些吊舱指标才能将其用于水平吊舱自动缩放。我正在使用Digital Ocean云集群。 部署文件位于enter image description here

下面的屏幕截图中

2 个答案:

答案 0 :(得分:0)

您需要先下载以下文件:

curl https://raw.githubusercontent.com/kubernetes/heapster/master/deploy/kube-config/influxdb/grafana.yaml > grafana.yaml
curl https://raw.githubusercontent.com/kubernetes/heapster/master/deploy/kube-config/influxdb/heapster.yaml > heapster.yaml
curl https://raw.githubusercontent.com/kubernetes/heapster/master/deploy/kube-config/influxdb/influxdb.yaml > influxdb.yaml
curl https://raw.githubusercontent.com/kubernetes/heapster/master/deploy/kube-config/rbac/heapster-rbac.yaml > heapster-rbac.yaml

然后创建以下grafana,influxdb和heapster服务实例:

$ kubectl create -f grafana.yaml
deployment "monitoring-grafana" created
service "monitoring-grafana" created

$ kubectl create -f heapster.yaml
serviceaccount "heapster" created
deployment "heapster" created
service "heapster" created

$ kubectl create -f influxdb.yaml
deployment "monitoring-influxdb" created
service "monitoring-influxdb" created

$ kubectl create -f heapster-rbac.yaml
clusterrolebinding "heapster" created

请按照本教程测试您的自动缩放Pod:

https://developer.ibm.com/tutorials/autoscale-application-on-kubernetes-cluster/

希望这会有所帮助。

编辑:部署文件中的资源请求:

apiVersion: v1
kind: Pod
metadata:
  name: frontend
spec:
  containers:
  - name: db
    image: mysql
    env:
    - name: MYSQL_ROOT_PASSWORD
      value: "password"
    resources:
      requests:
        memory: "64Mi"
        cpu: "250m"
      limits:
        memory: "128Mi"
        cpu: "500m"
  - name: wp
    image: wordpress
    resources:
      requests:
        memory: "64Mi"
        cpu: "250m"
      limits:
        memory: "128Mi"
        cpu: "500m"    
资源和请求应该位于部署文件中,以便HPA可以对其进行自动缩放。

答案 1 :(得分:0)

最新的Kubernetes中不推荐使用Heapster。从Kubernetes 1.11开始,不建议从Heapster中获取指标。

使用metrics-server安装对我有用:

kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml

来源: