k8s监控组件heapster安装部署
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了k8s监控组件heapster安装部署相关的知识,希望对你有一定的参考价值。
k8s监控组件heapster安装部署
参考文档
https://github.com/kubernetes/heapster/tree/master/deploy
k8s集群安装部署
http://jerrymin.blog.51cto.com/3002256/1898243
k8s集群RC、SVC、POD部署
http://jerrymin.blog.51cto.com/3002256/1900260
k8s集群组件kubernetes-dashboard和kube-dns部署
http://jerrymin.blog.51cto.com/3002256/1900508
k8s集群监控组件heapster部署
http://jerrymin.blog.51cto.com/3002256/1904460
k8s集群反向代理负载均衡组件部署
http://jerrymin.blog.51cto.com/3002256/1904463
部署步骤:
1,下载组件heapster源代码
由于我安装了2个版本的所以都记录了下:
版本一:
https://github.com/kubernetes/heapster
发现要在k8s集群上跑heapster,需要安装InfluxDB与Google Cloud Monitoring and GoogleCloud Logging
这是分开安装的资料,下面有个kube.sh脚本可以直接安装这两个相关组件
安装influxdb资料
https://github.com/kubernetes/heapster/tree/master/deploy/kube-config/influxdb
安装google云监控和日志
https://github.com/kubernetes/heapster/blob/master/docs/google.md
git clonehttps://github.com/kubernetes/heapster
cd heapster/deploy/
注意修改一个配置,这样没有https认证时才能和dashboard连接起来
vimdeploy/kube-config/influxdb/heapster-deployment.yaml
- /heapster
---source=kubernetes:http://172.17.3.20:8080?inClusterConfig=false
---sink=influxdb:http://monitoring-influxdb:8086
./kube.sh start
这里是自带监控脚本安装,安装完成后会生成
[[email protected] deploy]# kubectl get pods -o wide --namespace=kube-system
NAME READY STATUS RESTARTS AGE IP NODE
heapster-791010959-npzc9 1/1 Running 0 21s 10.1.8.7 k8s-node2
kube-dns-3019842428-tqjg8 3/3 Running 6 1d 10.1.8.10 k8s-node2
kube-dns-autoscaler-2715466192-gs937 1/1 Running 2 22h 10.1.8.5 k8s-node2
kubernetes-dashboard-47555765-szbw6 1/1 Running 1 3h 10.1.8.11 k8s-node2
monitoring-grafana-3730655072-s466b 1/1 Running 0 21s 10.1.89.2 k8s-node1
monitoring-influxdb-957705310-5rswg 1/1 Running 0 21s 10.1.89.6 k8s-node1
[[email protected] deploy]# kubectl logs -f heapster-791010959-npzc9 -n kube-system
I0223 06:37:52.935620 1 heapster.go:71] /heapster--source=kubernetes:http://172.17.3.20:8080?inClusterConfig=false--sink=influxdb:http://monitoring-influxdb:8086
I0223 06:37:52.935815 1 heapster.go:72] Heapster versionv1.3.0-beta.1
I0223 06:37:52.935957 1 configs.go:61] Using Kubernetes clientwith master "http://172.17.3.20:8080" and version v1
I0223 06:37:52.935976 1 configs.go:62] Using kubelet port10255
版本二:
[[email protected] ~]# wgethttps://github.com/kubernetes/heapster/archive/v1.2.0.tar.gz
[[email protected] ~]# tar zxvfv1.2.0.tar.gz
[[email protected] ~]# cdheapster-1.2.0/
[[email protected] ~]# cddeploy/
[[email protected] ~]# catkube.sh
[[email protected] influxdb]#vim heapster-controller.yaml
[[email protected] influxdb]#pwd
/root/heapster-1.2.0/deploy/kube-config/influxdb
2,提前在节点上pull需要的镜像
[email protected]:~# dockerimages|grep heapster
docker.io/kubernetes/heapster canary 0a56f7040da5 8 weeks ago 971.2 MB
gcr.io/google_containers/heapster_grafana v2.6.0-2 b43443930626 12 months ago 230 MB
docker.io/kubernetes/heapster_influxdb v0.5 a47993810aac 17 months ago 251 MB
3,按照ReadME介绍方法安装部署
[[email protected] influxdb]#pwd
/root/heapster-1.2.0/deploy/kube-config/influxdb
主要修改下面几行,由于镜像比较大,pull策略推荐使用本地的
[[email protected] influxdb]#vim heapster-controller.yaml
image: kubernetes/heapster:canary
imagePullPolicy: IfNotPresent
command:
- /heapster
---source=kubernetes:http://172.17.3.20:8080?inClusterConfig=false
- --sink=influxdb:http://monitoring-influxdb:8086
开始创建svc和pod
[[email protected] influxdb]#kubectl create -f ./
service"monitoring-grafana" created
replicationcontroller"heapster" created
service "heapster"created
replicationcontroller"influxdb-grafana" created
service"monitoring-influxdb" created
[[email protected] influxdb]#kubectl get pods -n kube-system
NAME READY STATUS RESTARTS AGE
heapster-r2mpn 1/1 Running 0 8m
influxdb-grafana-dcn6q 2/2 Running 0 8m
kube-dns-3019842428-fkgh5 3/3 Running 0 3d
kube-dns-autoscaler-2715466192-q0t0c 1/1 Running 0 3d
kubernetes-dashboard-47555765-2w64l 1/1 Running 0 3d
[[email protected] influxdb]#kubectl get svc -n kube-system
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
heapster 10.254.174.207 <none> 80/TCP 10m
kube-dns 10.254.0.10 <none> 53/UDP,53/TCP 3d
kubernetes-dashboard 10.254.8.93 <nodes> 80:30531/TCP 3d
monitoring-grafana 10.254.142.142 <none> 80/TCP 10m
monitoring-influxdb 10.254.183.9 <none> 8083/TCP,8086/TCP 10m
4,测试验证效果
注意可以用grafana查看效果,需要用nodeport发布出来这样连接节点的IP加端口就可以访问了
dashboard地址如下:
http://172.17.3.7:30531/#/node?namespace=kube-system
grafana地址如下:
5,排错dashboard不出监控图(网友Moc<[email protected]>指导)
连续试了好几个heapster版本,都是这里不出图,后来经网友指导dashboard是通过apiserver api接口去取的监控数据,kube-apiserver安装在k8s-master节点,
该节点没有安装网络组件,由于单独安装flanneld,不用覆盖docker0,所以只需要一条命令启动,下面这个配置文件是做成开机启动的。
(前期一直没有查看dashboard日志,只是在heapster,influxdb,grafana查找所以一直没有找到原因。)
[[email protected] system]# cat/usr/lib/systemd/system/flanneld.service
[Unit]
Description=Flanneld overlayaddress etcd agent
After=network.target
After=network-online.target
Wants=network-online.target
#After=etcd.service
#Before=docker.service
[Service]
Type=notify
EnvironmentFile=/etc/sysconfig/flanneld
EnvironmentFile=-/etc/sysconfig/docker-network
ExecStart=/usr/local/bin/flanneld-etcd-endpoints=http://172.17.3.20:2379 -etcd-prefix=/k8s/network
Restart=on-failure
[Install]
WantedBy=multi-user.target
RequiredBy=docker.service
本文出自 “jerrymin” 博客,请务必保留此出处http://jerrymin.blog.51cto.com/3002256/1904460
以上是关于k8s监控组件heapster安装部署的主要内容,如果未能解决你的问题,请参考以下文章
使用Heapster和Splunk监控Kubernetes运行性能