溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

在Kubernetes Cluster中如何部署Metrics Server服務

發(fā)布時間:2021-10-13 11:57:29 來源:億速云 閱讀:146 作者:iii 欄目:編程語言

這篇文章主要講解了“在Kubernetes Cluster中如何部署Metrics Server服務”,文中的講解內(nèi)容簡單清晰,易于學習與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學習“在Kubernetes Cluster中如何部署Metrics Server服務”吧!

問題描述

該筆記將記錄:在 Kubernetes Cluster 中,如何部署 Metrics Server 服務,以及常見問題處理。

解決方案

我們的測試環(huán)境為 Kubernetes Cluster v1.16 版本。

第一步、環(huán)境檢查

Metrics Server 對網(wǎng)絡和集群有特殊要求。這樣要求在某些集群里不是默認配置,所以要先確認是否滿足要求。

1)Metrics Server must be reachable from kube-apiserver

2)The kube-apiserver must be correctly configured to enable an aggregation layer
檢查 /etc/kubernetes/manifests/kube-apiserver.yaml 選項,默認已經(jīng)開啟。

3)Nodes must have kubelet authorization configured to match Metrics Server configuration

4)Container runtime must implement a container metrics RPCs

第二步、修改配置信息

下載 components.yaml 文件,并根據(jù)需要進行修改:

1)我們需要修改在 YAML 文件中的鏡像地址,使用私有鏡像倉庫;

默認鏡像屬于 k8s.gcr.io 倉庫,拉取必然失敗,修改為 bitnami/metrics-server:0.4.2

2)添加 --kubelet-preferred-address-types=InternalIP 與 --kubelet-insecure-tls 選項;

第三步、應用配置文件

# kubectl apply -f "/path/to/components.yaml"

# kubectl get -n kube-system pods -l k8s-app=metrics-server
NAME                              READY   STATUS    RESTARTS   AGE
metrics-server-66d4d747c4-nmzs6   1/1     Running   0          8m19s

第四步、查看 Pod 資源占用情況

# kubectl top node --sort-by=cpu
...

# kubectl top pod --all-namespaces --containers
...

常見錯誤匯總

Metrics not available for pod

# kubectl top -n kube-system pod
W0702 10:48:07.400630    6619 top_pod.go:266] Metrics not available for pod kube-system/coredns-58cc8c89f4-6czm4, age: 4267h8m49.400600321s
error: Metrics not available for pod kube-system/coredns-58cc8c89f4-6czm4, age: 4267h8m49.400600321s

通過添加 --kubelet-preferred-address-types=InternalIP 與 --kubelet-insecure-tls 選項解決;

unable to fetch pod metrics for pod

E0702 02:39:09.777832       1 reststorage.go:160] unable to fetch pod metrics for pod default/counter: no metrics known for pod
E0702 02:39:09.777843       1 reststorage.go:160] unable to fetch pod metrics for pod kube-system/etcd-k8s-master-02: no metrics known for pod
E0702 02:39:09.777863       1 reststorage.go:160] unable to fetch pod metrics for pod kube-system/fluentd-p6d29: no metrics known for pod
E0702 02:39:09.777874       1 reststorage.go:160] unable to fetch pod metrics for pod kube-system/kube-proxy-xdh3z: no metrics known for pod
E0702 02:39:09.777885       1 reststorage.go:160] unable to fetch pod metrics for pod kube-system/etcd-k8s-master-01: no metrics known for pod
E0702 02:39:09.777900       1 reststorage.go:160] unable to fetch pod metrics for pod kube-system/kube-proxy-jrpnd: no metrics known for pod

通過添加 --kubelet-preferred-address-types=InternalIP 與 --kubelet-insecure-tls 選項解決

感謝各位的閱讀,以上就是“在Kubernetes Cluster中如何部署Metrics Server服務”的內(nèi)容了,經(jīng)過本文的學習后,相信大家對在Kubernetes Cluster中如何部署Metrics Server服務這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是億速云,小編將為大家推送更多相關知識點的文章,歡迎關注!

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內(nèi)容。

AI