0

how to install heapster or metric server to get pod metrics in kubernetes. I need those pod metrics for using it to horizontal pod auto-scaling. I'm using Digital Ocean cloud cluster. deployment file is in the screenshot below enter image description here

AATHITH RAJENDRAN
  • 4,689
  • 8
  • 34
  • 58

2 Answers2

0

You need to first download the following files:

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

Then create the following service instance of grafana, influxdb and 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

Follow this tutorial for test your autoscaling pods:

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

Hope this helps.

EDIT: Resource request in your deployment file:

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"    

resources and request should be there in your deployment files so that HPA can access it to autoscale.

Prafull Ladha
  • 12,341
  • 2
  • 37
  • 58
  • "kubectl get hpa" the TARGETS remains unknown/25 %. I think the hpa cant retrieve pod metrics. what should I do now? @prafull – AATHITH RAJENDRAN Dec 10 '18 at 07:50
  • 1
    You need to specify resource requests in the Pod spec section of your deployment for the HPA to be able to display that information – Prafull Ladha Dec 10 '18 at 08:38
  • I followed the link you posted above. Where should I specify resource request? (I'm new to kubernetes)@prafull – AATHITH RAJENDRAN Dec 10 '18 at 09:06
  • 1
    I have edited my ans, that have resources request in spec section, you must have those to access metrics of mem and cpu by HPA – Prafull Ladha Dec 10 '18 at 09:12
  • resources and requests were there already, (screenshot of the deployment file is added to the question ) @prafull – AATHITH RAJENDRAN Dec 10 '18 at 11:23
  • can you add `kubectl get hpa` results? – aurelius Dec 10 '18 at 16:53
  • Heapster is being deprecated right? Anyway, I tried with your proposed answer, And I see from dashboard pods logs that : ```No metric client provided. Skipping metrics.``` I looked it up and it seems this is intentional in favor to a feature thats being worked up on. https://github.com/kubernetes/dashboard/issues/3147 – Venu S May 29 '19 at 15:20
0

Heapster is Deprecated in Latest Kubernetes. Fetching metrics from Heapster is deprecated as of Kubernetes 1.11.

Installing with metrics-server worked for me :

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

Source :

Anthony Vinay
  • 513
  • 5
  • 17