目录
1、主机清单
2、拉取镜像
3、服务安装
4、安装prometheus-operator
5、查看custom metrics api
6、获取prometheus端口
7、将 alertmanager-main 、grafana、prometheus-k8s的端口暴露出来
8、再次查看prometheus端口
9、浏览器访问IP:31940
部署k8集群参考使用kubeadm方式部署集群-CSDN博客
1、主机清单
名称 | 配置 | 版本 | 系统版本 |
---|---|---|---|
master | 4核8G | 1.20.1 | centos7.9 |
node1 | 2核4G | 1.20.1 | centos7.9 |
node2 | 2核4G | 1.20.1 | centos7.9 |
2、拉取镜像
在k8s中部署prometheus所需的镜像已打包上传
prometheus-operator下载地址
prometheus-镜像下载地址
prometheus-包下载
docker pull quay.io/prometheus/alertmanager:v0.21.0
docker pull quay.io/prometheus/blackbox-exporter:v0.18.0
docker pull jimmidyson/configmap-reload:v0.5.0
docker pull quay.io/brancz/kube-rbac-proxy:v0.9.0
docker pull grafana/grafana:7.5.4
docker pull k8s.gcr.io/kube-state-metrics/kube-state-metrics:v2.1.1
docker pull quay.io/prometheus/node-exporter:v1.1.2
docker pull k8s.gcr.io/prometheus-adapter/prometheus-adapter:v0.9.0
docker pull quay.io/prometheus/prometheus:v2.26.0
docker pull quay.io/prometheus-operator/prometheus-operator:v0.47.0
3、服务安装
[root@k8s-master ~]# wget https://codeload.github.com/prometheus-operator/kube-prometheus/tar.gz/refs/tags/v0.9.0
[root@k8s-master ~]# tar xf v0.9.0
[root@k8s-master ~]# cd kube-prometheus-0.9.0/manifests
4、安装prometheus-operator
[root@k8s-master ~]# kubectl apply -f setup/
[root@k8s-master ~]# kubectl get pods -n monitoring # 查看pod全部RUNNING之后再执行后面指令
[root@k8s-master ~]# kubectl apply -f .
[root@k8s-master ~]# kubectl get pods -n monitoring # 等待podRUNNING
5、查看custom metrics api
[root@k8s-master ~]# kubectl get apiservices -n monitoring | grep metrics
v1beta1.metrics.k8s.io monitoring/prometheus-adapter True 3h52m
6、获取prometheus端口
7、将 alertmanager-main 、grafana、prometheus-k8s的端口暴露出来
[root@kube-master manifests]# kubectl edit svc -n monitoring alertmanager-main
同样的方法将grafana、prometheus-k8s也修改
8、再次查看prometheus端口
端口已暴露
9、浏览器访问IP:31940
导入监控模板