使用helm在k8s集群上部署Prometheus和grafana监控集群

一、helm部署Prometheus

artifacthub上查找prometheus的helm部署包

 在k8s集群添加Prometheus的repo仓库

helm repo add prometheus-community https://prometheus-community.github.io/helm-charts

拉取Prometheus压缩包

helm pull prometheus-community/prometheus

解压压缩包

 tar -zxvf prometheus-26.0.1.tgz

修改prometheus目录下values.yaml,添加storageClass,如何创建nfs的storageClass,请参考这里:k8s使用nfs创建storageClass

vim prometheus/values.yaml

继续修改altermanager下的values.yaml

vim prometheus/charts/alertmanager/values.yaml

 

 

 执行helm安装Prometheus,并创建prometheus命名空间

helm install prometheus prometheus/ --version 26.0.1 --namespace prometheus --create-namespace

 

此外方便外部对其访问,将prometheus-server的service改为NodePort类型

修改完毕后对Prometheus进行upgrade升级

 

 helm upgrade prometheus prometheus -n prometheus

使用集群任意ip+NodePort暴露的端口访问

 

 

 二、helm部署grafana

同样在hub上搜索grafana

添加仓库

helm repo add grafana https://grafana.github.io/helm-charts

搜索grafana

helm search repo grafana

 拉取仓库部署包

helm pull grafana/grafana

解压压缩包

tar -zxvf grafana-8.8.2.tgz

修改values.yaml,service的类型设置为NodePort,便于外部对其访问

执行helm安装,并创建grafana命名空间

helm install grafana grafana --namespace grafana --create-namespace --version 8.8.2

 

web访问,用户名默认:admin,密码获取使用下面命令

kubectl get secret --namespace grafana grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo

 

使用集群ip+NodePort暴露的端口访问,输入上面的密钥

 

三、配置grafana监控集群健康

添加数据源,由于grafana与prometheus在同一个集群内,可以使用service_name.namespace加上内部80端口访问 ,也可使用集群ip+NodePort访问

测试正常

 

导入dashboard

 

输入id,也可自行去https://grafana.com/找自己喜欢的dashboard

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值