Skip to content

Instantly share code, notes, and snippets.

@weshouman
Last active January 31, 2020 13:35
Show Gist options
  • Save weshouman/cc56af9ee8b59fc71af758b210db030b to your computer and use it in GitHub Desktop.
Save weshouman/cc56af9ee8b59fc71af758b210db030b to your computer and use it in GitHub Desktop.
metrics-server deployment tips

Using Geerlingguy's K8s cluster and trying to install the metrics-server has some little snowflakes, following is how they got solved for me.

Steps

  • get the metrics server git clone https://github.com/kubernetes-sigs/metrics-server.git metrics-server
  • label the nodes according to the metrics-server node affinity to ensure it works, original labelling was in my case beta.kubernetes.io/arch=amd64
kubectl label node master kubernetes.io/arch=amd64
kubectl label node node1  kubernetes.io/arch=amd64
kubectl label node node2  kubernetes.io/arch=amd64
  • Fix the scrapping and allow inscecure tls by adding this the following command with the two options based on this answer and the ones above.
        command:
          - /metrics-server
          - --kubelet-insecure-tls
          - --kubelet-preferred-address-types=InternalIP,Hostname,InternalDNS,ExternalDNS,ExternalIP

just after those lines

      containers:
      - name: metrics-server
        image: k8s.gcr.io/metrics-server-amd64:v0.3.6
  • Based on this answer, enable the hostnetwork by adding
      hostNetwork: true

just after those lines

    spec:
      serviceAccountName: metrics-server

Debugging

How I've done the debugging

  • Inspect the nodes kubectl describe node node1
  • Inspect the pod kubectl describe -n kube-system $(kubectl get po -n kube-system | grep metrics-server | \awk '{print $1;}') to get the affinity and the logs.
  • Increase the logs by using max (10) verbosity, according to the README
        command:
          - /metrics-server
          - --v=10
          - --kubelet-insecure-tls
          - --kubelet-preferred-address-types=InternalIP,Hostname,InternalDNS,ExternalDNS,ExternalIP
  • Run kubectl top pods or kubectl top nodes or kubectl get --raw /apis/metrics.k8s.io/v1beta1
  • Run kubectl get apiservice v1beta1.metrics.k8s.io -o yaml to get further info about the APIService status, based on this answer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment