本文介绍了来自服务器的错误(未找到):podmetrics.metrics.k8s.io"mem-example/memory-demo"未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注本教程: https://kubernetes.io/docs/tasks/configure-pod-container/assign-memory-resource/

我已经创建了内存Pod演示,并且我试图从Pod中获取指标,但是它无法正常工作.

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

我通过克隆安装了指标服务器: https://github.com/kubernetes-incubator /metrics-server

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+/

我正在使用kubernetes版本1.10.11.

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

但是metics命令不起作用,并显示错误消息:

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

我做错了什么?

推荐答案

要对指标服务器部署进行一些修补,以使指标正常工作.

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

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

这篇关于来自服务器的错误(未找到):podmetrics.metrics.k8s.io"mem-example/memory-demo"未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-27 14:24