Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error from server (NotFound): podmetrics.metrics.k8s.io "mem-example/memory-demo" not found

I am following this tutorial: https://kubernetes.io/docs/tasks/configure-pod-container/assign-memory-resource/

I have created the memory pod demo and I am trying to get the metrics from the pod but it is not working.

I installed the metrics server by cloning: https://github.com/kubernetes-incubator/metrics-server

And then running this command from top level:

kubectl create -f deploy/1.8+/

I am using kubernetes version 1.10.11.

The pod is definitely created:

λ kubectl get pod memory-demo --namespace=mem-example
NAME          READY     STATUS    RESTARTS   AGE
memory-demo   1/1       Running   0          6m

But the metics command does not work and gives an error:

λ kubectl top pod memory-demo --namespace=mem-example
Error from server (NotFound): podmetrics.metrics.k8s.io "mem-example/memory-demo" not found

What did I do wrong?

like image 270
Guerrilla Avatar asked Jan 02 '23 05:01

Guerrilla


1 Answers

There are some patches to be done to metrics server deployment to get the metrics working.

Follow the below steps

kubectl delete -f deploy/1.8+/

wait till the metrics server gets undeployed

run the below command
kubectl create -f https://raw.githubusercontent.com/epasham/docker-repo/master/k8s/metrics-server.yaml
master $ kubectl get po -n kube-system
NAME                              READY     STATUS    RESTARTS   AGE
coredns-78fcdf6894-6zg78          1/1       Running   0          2h
coredns-78fcdf6894-gk4sb          1/1       Running   0          2h
etcd-master                       1/1       Running   0          2h
kube-apiserver-master             1/1       Running   0          2h
kube-controller-manager-master    1/1       Running   0          2h
kube-proxy-f5z9p                  1/1       Running   0          2h
kube-proxy-ghbvn                  1/1       Running   0          2h
kube-scheduler-master             1/1       Running   0          2h
metrics-server-85c54d44c8-rmvxh   2/2       Running   0          1m
weave-net-4j7cl                   2/2       Running   1          2h
weave-net-82fzn                   2/2       Running   1          2h
master $ kubectl top pod -n kube-system
NAME                              CPU(cores)   MEMORY(bytes)
coredns-78fcdf6894-6zg78          2m           11Mi
coredns-78fcdf6894-gk4sb          2m           9Mi
etcd-master                       14m          90Mi
kube-apiserver-master             24m          425Mi
kube-controller-manager-master    26m          62Mi
kube-proxy-f5z9p                  2m           19Mi
kube-proxy-ghbvn                  3m           17Mi
kube-scheduler-master             8m           14Mi
metrics-server-85c54d44c8-rmvxh   1m           19Mi
weave-net-4j7cl                   2m           59Mi
weave-net-82fzn                   1m           60Mi

Check and verify the below lines in metrics server deployment manifest.

        command:
        - /metrics-server
        - --metric-resolution=30s
        - --kubelet-preferred-address-types=InternalIP
        - --kubelet-insecure-tls
like image 62
P Ekambaram Avatar answered Jan 04 '23 00:01

P Ekambaram