#一、metrics-server簡(jiǎn)介
自kubernetes 1.8開(kāi)始,資源使用指標(biāo)(如容器 CPU 和內(nèi)存使用率)通過(guò) Metrics API 在 Kubernetes 中獲取,metrics-server 替代了heapster。Metrics Server 實(shí)現(xiàn)了Resource Metrics API,Metrics Server 是集群范圍資源使用數(shù)據(jù)的聚合器。
Metrics Server 從每個(gè)節(jié)點(diǎn)上的 Kubelet 公開(kāi)的 Summary API 中采集指標(biāo)信息。
創(chuàng)新互聯(lián)堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:成都做網(wǎng)站、網(wǎng)站設(shè)計(jì)、外貿(mào)營(yíng)銷(xiāo)網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶(hù)于互聯(lián)網(wǎng)時(shí)代的鳳山網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!
Kubernetes中有些組件依賴(lài)資源指標(biāo)API(metric API)的功能 ,如kubectl top 、hpa。如果沒(méi)有資源指標(biāo)API接口,這些組件無(wú)法運(yùn)行。在之前使用的是Heapster,Heapster廢棄后改用metrics-server。
kubernetes metrics server 參考文檔 https://github.com/kubernetes-incubator/metrics-server
#二、安裝metrics-server
1、下載所需文件
# mkdir ./metrics-server
# cd metrics-server/
# for file in aggregated-metrics-reader.yaml auth-delegator.yaml auth-reader.yaml metrics-apiservice.yaml metrics-server-deployment.yaml metrics-server-service.yaml resource-reader.yaml; do wget https://raw.githubusercontent.com/kubernetes-incubator/metrics-server/master/deploy/1.8%2B/$file;done
2、這里需要改2個(gè)地方,一個(gè)是鏡像的問(wèn)題,一個(gè)是服務(wù)啟動(dòng)的問(wèn)題。
# 在所有Node節(jié)點(diǎn)上執(zhí)行。先把鏡像國(guó)通阿里云的鏡像源下載下來(lái)。再改個(gè)名字。
docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/metrics-server-amd64:v0.3.3
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/metrics-server-amd64:v0.3.3 k8s.gcr.io/metrics-server-amd64:v0.3.3
# 修改metrics-server-deployment.yaml,增加一個(gè)imagePullPolicy,增加command內(nèi)容,否則會(huì)報(bào)錯(cuò)no metrics known for node。相關(guān)問(wèn)題原因自行百度。
# vim metrics-server-deployment.yaml
30 containers:
31 - name: metrics-server
32 image: k8s.gcr.io/metrics-server-amd64:v0.3.3
33 imagePullPolicy: IfNotPresent
34 command:
35 - /metrics-server
36 - --kubelet-preferred-address-types=InternalIP,Hostname,InternalDNS,ExternalDNS,ExternalIP
37 - --kubelet-insecure-tls
38 volumeMounts:
39 - name: tmp-dir
40 mountPath: /tmp
# kubectl apply -f ./
clusterrole.rbac.authorization.k8s.io/system:aggregated-metrics-reader created
clusterrolebinding.rbac.authorization.k8s.io/metrics-server:system:auth-delegator created
rolebinding.rbac.authorization.k8s.io/metrics-server-auth-reader created
apiservice.apiregistration.k8s.io/v1beta1.metrics.k8s.io created
serviceaccount/metrics-server created
deployment.extensions/metrics-server created
service/metrics-server created
clusterrole.rbac.authorization.k8s.io/system:metrics-server created
clusterrolebinding.rbac.authorization.k8s.io/system:metrics-server created
3、查看pod狀態(tài)
metrics-server-55898485b6-pdhnz 1/1 Running 0 93m 10.244.4.2 huoban-k8s-node01
4、查看node資源使用情況( 一定要等幾分鐘,采集數(shù)據(jù)需要時(shí)間)
kubectl top node
NAME CPU(cores) CPU% MEMORY(bytes) MEMORY%
huoban-k8s-master01 72m 3% 612Mi 16%
huoban-k8s-master02 93m 4% 713Mi 19%
huoban-k8s-master03 108m 5% 674Mi 18%
huoban-k8s-node01 26m 1% 334Mi 9%
huoban-k8s-node02 26m 1% 339Mi 9%
5、查看pod資源使用情況
# kubectl top pods -n kube-system
NAME CPU(cores) MEMORY(bytes)
coredns-6967fb4995-4qlfb 1m 13Mi
coredns-6967fb4995-frv2p 1m 12Mi
etcd-huoban-k8s-master01 22m 358Mi
etcd-huoban-k8s-master02 25m 364Mi
etcd-huoban-k8s-master03 23m 381Mi
kube-apiserver-huoban-k8s-master01 15m 267Mi
kube-apiserver-huoban-k8s-master02 13m 255Mi
kube-apiserver-huoban-k8s-master03 17m 249Mi
kube-controller-manager-huoban-k8s-master01 7m 69Mi
kube-controller-manager-huoban-k8s-master02 0m 14Mi
kube-controller-manager-huoban-k8s-master03 0m 14Mi
kube-flannel-ds-amd64-6bp76 1m 21Mi
kube-flannel-ds-amd64-nrvvz 1m 15Mi
kube-flannel-ds-amd64-shv4n 1m 16Mi
kube-flannel-ds-amd64-t77n4 1m 15Mi
kube-proxy-8d522 1m 19Mi
kube-proxy-9ng4j 1m 18Mi
kube-proxy-htw7p 1m 20Mi
kube-proxy-n9r48 1m 17Mi
kube-proxy-nsqgh 1m 17Mi
kube-scheduler-huoban-k8s-master01 1m 27Mi
kube-scheduler-huoban-k8s-master02 0m 16Mi
kube-scheduler-huoban-k8s-master03 0m 13Mi
kubernetes-dashboard-86844cc55f-sz4gn 0m 13Mi
metrics-server-d9d75756b-l75wj 1m 17Mi
新聞標(biāo)題:Kubernetes安裝和部署metrics-server
瀏覽路徑:http://vcdvsql.cn/article24/pepjce.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)建站、網(wǎng)頁(yè)設(shè)計(jì)公司、虛擬主機(jī)、品牌網(wǎng)站設(shè)計(jì)、商城網(wǎng)站、網(wǎng)站制作
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)