K8S安装Prometheus+Grafana监控组件

一、前置步骤

1、在k8s-master节点安装nfs-server

详见Ubuntu NFS配置笔记_QuancyZhang的博客-CSDN博客

2、配置k8s-master节点nfs服务

mkdir -p /nfs/prometheus/data
echo "/nfs/prometheus/data  192.169.0.140/24(rw,no_root_squash,sync)" >>/etc/exports
systemctl restart nfs
systemctl restart rpcbind

注意:ip地址置换为自己的nfs地址,并且一定要在另一台机器进行mount试验,否则会报错The PersistentVolume "prometheus-data-pv" is invalid: spec.persistentvolumesource: Forbidden 

二、开始安装

安装所需脚本全部都在Prometheus.zip-群集服务文档类资源-CSDN下载

1、在kubernetest集群中创建namespace 

kubectl apply -f namespace.yaml

2、安装node-exporter

在kubernetest集群中部署node-exporter,Node-exporter用于采集kubernetes集群中各个节点的物理指标,比如:Memory、CPU等。

kubectl apply -f node-exporter.yaml

3、部署Prometheus

kubectl apply -f prometheus.yaml 

 4、部署grafana

kubectl apply -f grafana.yaml

 5、检查运行状况

root@k8s-master:~# kubectl get pod -n ns-monitor
NAME                          READY   STATUS    RESTARTS   AGE
grafana-6d6cc9dc-s2hr9        1/1     Running   0          18h
node-exporter-krghv           1/1     Running   0          19h
node-exporter-px77p           1/1     Running   0          19h
node-exporter-q7j4m           1/1     Running   0          19h
node-exporter-sc562           1/1     Running   0          19h
node-exporter-w8j29           1/1     Running   0          19h
node-exporter-xggmw           1/1     Running   0          19h
prometheus-5f7cb6d955-d7h25   1/1     Running   0          18h

 5、配置grafana数据源

把prometheus配置成数据源 :http://prometheus-service.ns-monitor:9090

6.导入Dashboard

把 kubernetes的Dashboard的模板导入进来,直接把JSON格式内容复制进来。

效果图:

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值