kubectl top node|pod

November 9, 2018 825 views
Kubernetes

It looks like heapster is not enabled on the cluster? Is this a planned feature?

kubectl top node
Error from server (NotFound): the server could not find the requested resource (get services http:heapster:)

I've used the same on other cloud providers (AKS, IKS) and it seems to be enabled...

1 comment
3 Answers

The following will help with understanding what is happening on the nodes:

$ cat bin/node-resources.sh 
#!/bin/bash
set -euo pipefail

echo -e "Iterating...\n"

nodes=$(kubectl get node --no-headers -o custom-columns=NAME:.metadata.name)

for node in $nodes; do
  echo "Node: $node"
  kubectl describe node "$node" | sed '1,/Non-terminated Pods/d'
  echo
done

From https://github.com/kubernetes/kubernetes/issues/17512

You have to deploy heapster in your cluster to collect metrics ;)
by default its not activated on digitalocean k8s-cluster.

There is a helm chart for heapster: https://github.com/helm/charts/tree/master/stable/heapster

  • Install metrics server chart
  • Update the command metrics server deployment and add the following two options to the pod command :

    - --kubelet-insecure-tls
    - --kubelet-preferred-address-types=InternalIP
    

Command will be look like this :

   command:
    - /metrics-server
    - --kubelet-insecure-tls
    - --kubelet-preferred-address-types=InternalIP

Wait two or three minutes, then the "top" command should work.

  • Because heapster is deprecated, use metrics-server if you can.
    Unfortuenatly kubernetes-dashboard requires heapster for any graphs.

    I've got it working with a helm installment using the https kubelet port 10250 instead of the readonly http port 10255 - which is deprecated and not available on DO too

    helm upgrade --install --wait k8s-heapster stable/heapster --set=command='{/heapster,--source=kubernetes:https://kubernetes.default?kubeletHttps=true&kubeletPort=10250&insecure=true}' --namespace kube-system
    
Have another answer? Share your knowledge.