本篇文章,所使用的任何镜像和yaml我都会发一个网盘链接,供大家下载学习!
github:https://github.com/heyangguang
有任何问题可以直接联系我的Email:heyangev@cn.ibm.com
Heapster是一个收集者,将每个Node上的cAdvisor的数据进行汇总,然后导到第三方工具(如InfluxDB)。
Heapster介绍
架构图:
Heapster首先从K8S Master获取集群中所有Node的信息,然后通过这些Node上的kubelet获取有用数据,而kubelet本身的数据则是从cAdvisor得到。所有获取到的数据都被推到Heapster配置的后端存储中,并还支持数据的可视化。现在后端存储 + 可视化的方法,如InfluxDB + grafana。
部署实施:
下载heapster镜像,上传heapster.yaml、heapster-mod.yaml文件apply就可以了。
k8smaster:
[root@k8smaster ~]# docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/heapster-amd64:v1.5.4
Trying to pull repository registry.cn-hangzhou.aliyuncs.com/google_containers/heapster-amd64 ...
v1.5.4: Pulling from registry.cn-hangzhou.aliyuncs.com/google_containers/heapster-amd64
91380601464e: Pull complete
f351486260ed: Pull complete
Digest: sha256:c4a8d9c0007abb73a1b9e4f9c8bfb044e475aae2b4e6276ab2f8b13959cf6949
Status: Downloaded newer image for registry.cn-hangzhou.aliyuncs.com/google_containers/heapster-amd64:v1.5.4
[root@k8smaster ~]# ls
anaconda-ks.cfg heapster-mod.yaml heapster.yaml images.tar kube-flannel.yml
[root@k8smaster ~]# kubectl apply -f heapster.yaml
serviceaccount/heapster created
clusterrolebinding.rbac.authorization.k8s.io/heapster created
deployment.apps/heapster created
service/heapster created
[root@k8smaster ~]# kubectl apply -f heapster-mod.yaml
Warning: kubectl apply should be used on resource created by either kubectl create --save-config or kubectl apply
clusterrole.rbac.authorization.k8s.io/system:heapster configured
查看状态:
[root@k8smaster ~]# kubectl get pods -n kube-system
NAME READY STATUS RESTARTS AGE
coredns-86c58d9df4-kmfct 1/1 Running 0 23m
coredns-86c58d9df4-qn2k2 1/1 Running 0 23m
etcd-k8smaster 1/1 Running 0 23m
heapster-569b679494-rktzf 1/1 Running 0 18s
kube-apiserver-k8smaster 1/1 Running 1 22m
kube-controller-manager-k8smaster 1/1 Running 0 22m
kube-flannel-ds-amd64-9rmfz 1/1 Running 0 19m
kube-flannel-ds-amd64-vnwtf 1/1 Running 0 15m
kube-flannel-ds-amd64-x7q4s 1/1 Running 0 15m
kube-proxy-7zl9n 1/1 Running 0 22m
kube-proxy-t2sx9 1/1 Running 0 23m
kube-proxy-txsfr 1/1 Running 0 22m
kube-scheduler-k8smaster 1/1 Running 0 23m
稍等一会,使用kubectl top node查看集群状态即可:
[root@k8smaster ~]# kubectl top node
NAME CPU(cores) CPU% MEMORY(bytes) MEMORY%
k8smaster 122m 3% 2848Mi 8%
k8snode-1 27m 0% 603Mi 1%
k8snode-2 26m 0% 582Mi 1%
到这里heapster收集集群数据教程就完成了!
希望大家可以给我指出问题,我们一起前进!
谢谢大家!
有疑问加站长微信联系(非本文作者)