如何对Kubeadm上的Metrics-Server进行故障排除? [英] How to troubleshoot metrics-server on kubeadm?

查看:1795
本文介绍了如何对Kubeadm上的Metrics-Server进行故障排除?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在裸机上使用kubeadm的1.15.1 kubenetes集群,并且像文档中一样部署了metrics-server:

I have a working 1.15.1 kubenetes cluster using kubeadm on bare-metal and just deployed metrics-server as in the docs:

git clone https://github.com/kubernetes-incubator/metrics-server.git
kubectl create -f metrics-server/deploy/1.8+/

一段时间后,我尝试kubectl top node并得到响应:

After some time I try kubectl top node and I get as response:

错误:指标尚不可用

error: metrics not available yet

另外,当我尝试kubectl top pods时,我得到:

Also when I try kubectl top pods I get:

W0721 20:01:31.786615 21232 top_pod.go:266]指标不适用于 pod default/pod-deployment-57b99df6b4-khh84,年龄:27h31m59.78660593s 错误:指标不适用于广告连播 默认/pod-deployment-57b99df6b4-khh84,年龄:27h31m59.78660593s

W0721 20:01:31.786615 21232 top_pod.go:266] Metrics not available for pod default/pod-deployment-57b99df6b4-khh84, age: 27h31m59.78660593s error: Metrics not available for pod default/pod-deployment-57b99df6b4-khh84, age: 27h31m59.78660593s

我检查了pod和service的metrics-server,它们都运行良好.我应该在哪里尝试发现问题?

I checked the pod and service for metrics-server and all of them are running fine. Where should I try to see a problem?

推荐答案

按照Subramanian Manickam的回答说,编辑度量服务器部署,您也可以使用

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

这将打开带有部署yaml文件的文本编辑器,您可以在其中进行以下更改:

That will open a text editor with the deployment yaml-file where you can make the following changes:

spec.template.spec.containers 下,与name: metrics-server add

args:
- --kubelet-insecure-tls
- --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname
- --metric-resolution=30s

,然后在与containers相同级别的 spec.template.spec 下,我也必须添加:

and then under spec.template.spec at the same level as containers I also had to add:

hostNetwork: true

修复与CNI(在我的情况下为calico)一起使用的指标服务器.

to fix the metrics-server working with the CNI (calico in my case).

之后,您的部署Yaml应该如下所示:

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
[...]

此后,kubectl top pods花了大约10到15秒的时间才能返回一些数据.

After that it took about 10-15s for kubectl top pods to return some data.

这篇关于如何对Kubeadm上的Metrics-Server进行故障排除?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆