How to troubleshoot metrics-server on kubeadm?
Edit the metric-server deployment like Subramanian Manickam's answer said, you can also do it with
$ kubectl edit deploy -n kube-system metrics-server
That will open a text editor with the deployment yaml-file where you can make the following changes:
Under spec.template.spec.containers, on the same level as name: metrics-server
add
args:
- --kubelet-insecure-tls
- --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname
- --metric-resolution=30s
and then under spec.template.spec at the same level as containers
I also had to add:
hostNetwork: true
to fix the metrics-server working with the CNI (calico in my case).
Afterwards your deployment yaml should look something like this:
[...]
spec:
[...]
template:
metadata:
creationTimestamp: null
labels:
k8s-app: metrics-server
name: metrics-server
spec:
containers:
- args:
- --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname
- --kubelet-insecure-tls
- --metric-resolution=30s
image: k8s.gcr.io/metrics-server-amd64:v0.3.3
imagePullPolicy: Always
name: metrics-server
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /tmp
name: tmp-dir
dnsPolicy: ClusterFirst
hostNetwork: true
[...]
After that it took about 10-15s for kubectl top pods
to return some data.
You have to add this command section after line number #33 on metrics-server-deployment.yaml file.
command:
- /metrics-server
- --kubelet-preferred-address-types=InternalIP
- --kubelet-insecure-tls
Once you have updated the file, you have to re-deploy the pod.