prometheus 监控K8S集群
prometheus 监控k8s集群介绍名称配置版本系统版本master4核8G1.20.1centos7.6node12核4G1.20.1centos7.6node22核4G1.20.1centos7.6node32核4G1.20.1centos7.6prometheus-operator-v0.9.0-prometheus-operator下载地址prometheus-镜像下载地址promet
·
prometheus 监控k8s集群
介绍
名称 | 配置 | 版本 | 系统版本 |
---|---|---|---|
master | 4核8G | 1.20.1 | centos7.6 |
node1 | 2核4G | 1.20.1 | centos7.6 |
node2 | 2核4G | 1.20.1 | centos7.6 |
node3 | 2核4G | 1.20.1 | centos7.6 |
prometheus-operator | - | v0.9.0 | - |
镜像下载
下载镜像
docker pull newrain857/prometheus:alertmanager
docker pull newrain857/prometheus:blackbox-exporter
docker pull newrain857/prometheus:configmap-reload
docker pull newrain857/prometheus:kube-rbac-proxy
docker pull newrain857/prometheus:grafana
docker pull newrain857/prometheus:kube-state-metrics
docker pull newrain857/prometheus:node-exporter
docker pull newrain857/prometheus:prometheus-adapter
docker pull newrain857/prometheus:prometheus
docker pull newrain857/prometheus:prometheus-operator
修改镜像名称
docker tag newrain857/prometheus:alertmanager quay.io/prometheus/alertmanager:v0.22.2
docker tag newrain857/prometheus:blackbox-exporter quay.io/prometheus/blackbox-exporter:v0.19.0
docker tag newrain857/prometheus:configmap-reload jimmidyson/configmap-reload:v0.5.0
docker tag newrain857/prometheus:kube-rbac-proxy quay.io/brancz/kube-rbac-proxy:v0.11.0
docker tag newrain857/prometheus:grafana grafana/grafana:8.1.1
docker tag newrain857/prometheus:kube-state-metrics bitnami/kube-state-metrics:v2.1.1
docker tag newrain857/prometheus:node-exporter quay.io/prometheus/node-exporter:v1.2.2
docker tag newrain857/prometheus:prometheus-adapter k8s.gcr.io/prometheus-adapter/prometheus-adapter:v0.9.0
docker tag newrain857/prometheus:prometheus quay.io/prometheus/prometheus:v2.29.1
docker tag newrain857/prometheus:prometheus-operator quay.io/prometheus-operator/prometheus-operator:v0.49.0
服务安装
[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
修改yaml文件
文件名称 alertmanager-service.yaml grafana-service.yaml promethes--service.yaml
apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/component: prometheus
app.kubernetes.io/name: prometheus
app.kubernetes.io/part-of: kube-prometheus
app.kubernetes.io/version: 2.26.0
prometheus: k8s
name: prometheus-k8s
namespace: monitoring
spec:
type: NodePort #新增
ports:
- name: web
port: 9090
targetPort: web
nodePort: 30090 #新增 alertmanager-service.yaml=>30093 grafana-service.yaml=>30095 promethes--service.yaml=>30090
selector:
app: prometheus
app.kubernetes.io/component: prometheus
app.kubernetes.io/name: prometheus
app.kubernetes.io/part-of: kube-prometheus
安装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
查看custom metrics api
[root@k8s-master ~]# kubectl get apiservices -n monitoring | grep metrics
v1beta1.metrics.k8s.io monitoring/prometheus-adapter True 3h52m
获取prometheus端口
[root@k8s-master ~]# kubectl get svc -n monitoring | grep NodePort
alertmanager-main NodePort 10.101.12.122 <none> 9093:30093/TCP 3h50m
grafana NodePort 10.109.2.214 <none> 3000:30095/TCP 3h50m
prometheus-k8s NodePort 10.105.121.223 <none> 9090:30090/TCP 3h50m
ip:30093/#/status 查看报警配置
ip:30090 查看prometheus
ip:30095 查看grafana模版
页面展示
30090
30093
30095
导入grafana仪表盘
仪表盘id 13105 、8919
13105
8919
更多推荐
已为社区贡献2条内容
所有评论(0)