[英]How to troubleshoot metrics-server on kubeadm?
I have a working 1.15.1 kubenetes cluster using kubeadm on bare-metal and just deployed metrics-server as in the docs:我有一个在裸机上使用 kubeadm 的 1.15.1 kubenetes 集群,并且刚刚部署了 metrics-server,如文档中所示:
git clone https://github.com/kubernetes-incubator/metrics-server.git
kubectl create -f metrics-server/deploy/1.8+/
After some time I try kubectl top node
and I get as response:一段时间后,我尝试
kubectl top node
并得到响应:
error: metrics not available yet
错误:指标尚不可用
Also when I try kubectl top pods
I get:此外,当我尝试
kubectl top pods
我得到:
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
W0721 20:01:31.786615 21232 top_pod.go:266] 指标不适用于 pod 默认/pod-deployment-57b99df6b4-khh84,年龄:27h31m59.78660593s 错误:指标默认值/pod-deployment-57b99df6b4-khh84,错误:Metrics/pod-deployment-57b99df6b4-khh84s 不可用年龄:27h31m59.78660593s
I checked the pod and service for metrics-server and all of them are running fine.我检查了度量服务器的 pod 和服务,它们都运行良好。 Where should I try to see a problem?
我应该在哪里尝试查看问题?
Edit the metric-server deployment like Subramanian Manickam's answer said, you can also do it with像 Subramanian Manickam 的回答一样编辑 metric-server 部署,您也可以使用
$ 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:这将打开一个带有部署 yaml 文件的文本编辑器,您可以在其中进行以下更改:
Under spec.template.spec.containers , on the same level as name: metrics-server
add在spec.template.spec.containers 下,与
name: metrics-server
处于同一级别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 :然后在与
containers
相同级别的spec.template.spec下,我还必须添加:
hostNetwork: true
to fix the metrics-server working with the CNI (calico in my case).修复与 CNI 一起工作的度量服务器(在我的情况下为 calico)。
Afterwards your deployment yaml should look something like this:之后,您的部署 yaml 应如下所示:
[...]
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.之后,
kubectl top pods
大约需要kubectl top pods
才能返回一些数据。
You have to add this command section after line number #33 on metrics-server-deployment.yaml file.您必须在metrics-server-deployment.yaml文件的第 33 行之后添加此命令部分。
command:
- /metrics-server
- --kubelet-preferred-address-types=InternalIP
- --kubelet-insecure-tls
Once you have updated the file, you have to re-deploy the pod.更新文件后,您必须重新部署 pod。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.