您的位置:首页 > 运维架构

Prometheus全方位监控K8S集群,部署太简单了!

2018-11-23 11:24 3771 查看


     

     随着容器技术的迅速发展,Kubernetes 已然成为大家追捧的容器集群管理系统。Prometheus 作为生态圈 Cloud Native Computing Foundation(简称:CNCF)中的重要一员,其活跃度仅次于 Kubernetes, 现已广泛用于 Kubernetes 集群的监控系统中。本文将简要介绍 Prometheus 的组成和相关概念,并实例演示 Prometheus 的安装,配置及使用,以便开发人员和云平台运维人员可以快速的掌握 Prometheus。


Prometheus 是一套开源的系统监控报警框架。它启发于 Google 的 borgmon 监控系统,由工作在 SoundCloud 的 google 前员工在 2012 年创建,作为社区开源项目进行开发,并于 2015 年正式发布。2016 年,Prometheus 正式加入 Cloud Native Computing Foundation,成为受欢迎度仅次于 Kubernetes 的项目。

一、部署准备

安装git,下载yaml文件:

git clone https://github.com/redhatxl/k8s-prometheus-grafana.git

在Node节点下载所需镜像:

docker pull prom/node-exporter
docker pull prom/prometheus:v2.0.0
docker pull grafana/grafana:4.2.0

二、采用daemonset方式部署node-exporter

kubectl create -f  node-exporter.yaml

三、部署Prometheus

3.1 rbac文件
kubectl create -f  k8s-prometheus-grafana/prometheus/rbac-setup.yaml
3.2 以configmap的形式管理prometheus组件的配置文件
kubectl create -f  k8s-prometheus-grafana/prometheus/configmap.yaml
3.3 Prometheus deployment 文件
kubectl create -f  k8s-prometheus-grafana/prometheus/prometheus.deploy.yml
3.4 Prometheus service文件
kubectl create -f  k8s-prometheus-grafana/prometheus/prometheus.svc.yml

四、部署Grafana

4.1 grafana deployment配置文件
kubectl create -f   k8s-prometheus-grafana/grafana/grafana-deploy.yaml
4.2 grafana service配置文件
kubectl create -f   k8s-prometheus-grafana/grafana/grafana-svc.yaml
4.3 grafana ingress配置文件
kubectl create -f   k8s-prometheus-grafana/grafana/grafana-ing.yaml

五、 WEB界面配置

看node-exporter采集的数据:http://47.52.166.125:31672/metrics

prometheus对应的nodeport端口为30003,通过访问http://47.52.166.125:30003/target 可以看到prometheus已经成功连接上了k8s的apiserver


通过端口进行granfa访问,默认用户名密码均为admin:


添加数据源:


导入面板,可以直接输入模板编号315在线导入,或者下载好对应的json模板文件本地导入,面板模板下载地址https:///dashboards/315

查看展示效果:


[p]

[/p]



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息