K8s部署prometheus监控K8s细节

此文章使用k8s集群搭建了prometheus监控,并且监控了k8s node节点 等一些细节部分。
本文格式类似于随笔格式,没有详细描述。
基础篇文章可以查看我以前的博客
博客地址:https://blog.csdn.net/zeorg/article/details/112075071
prometheus 最好搭建在k8s集群里面(也就是docker里)。

prometheus 一些配置文件可以再github上找到。

https://github.com/coreos/kube-prometheus

部署/root/kube-prometheus/manifests 目录下所有文件
kubectl apply -f /root/kube-prometheus/manifests/
部署/root/kube-prometheus/manifests/setup  目录下所有文件
kubectl apply -f /root/kube-prometheus/manifests/setup/
要注意的是自己要创建一个工作空间
如果报错执行下面语句
kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/release-0.43/example/prometheus-operator-crd/monitoring.coreos.com_alertmanagerconfigs.yaml
kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/release-0.43/example/prometheus-operator-crd/monitoring.coreos.com_alertmanagers.yaml
kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/release-0.43/example/prometheus-operator-crd/monitoring.coreos.com_podmonitors.yaml
kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/release-0.43/example/prometheus-operator-crd/monitoring.coreos.com_probes.yaml
kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/release-0.43/example/prometheus-operator-crd/monitoring.coreos.com_prometheuses.yaml
kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/release-0.43/example/prometheus-operator-crd/monitoring.coreos.com_prometheusrules.yaml
kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/release-0.43/example/prometheus-operator-crd/monitoring.coreos.com_servicemonitors.yaml
kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/release-0.43/example/prometheus-operator-crd/monitoring.coreos.com_thanosrulers.yaml


部署完之后可以执行下面命令查看状态
kubectl get pod -n monitoring 

kubectl get svc -n monitoring 

kubectl top node  (如果不部署setup下的环境这里会出错)

环境部署成功了
grafana 默认账号密码都是admin

K8s部署prometheus监控K8s细节_第1张图片

你可能感兴趣的:(运维监控,docker,运维,容器,linux)