1、情况说明
通过prometheus来监控部署在k8s以外的应用程序,可以通过静态配置文件的方式,创建一个secret文件,然后挂载到prometheus中即可
2、创建静态配置
创建一个静态配置文件:prometheus-additional.yaml
- job_name: 'harbor'
static_configs:
- targets:
- harbor.bgxwz.com:9100
将prometheus-additional.yaml创建成一个secret文件
kubectl create secret generic additional-scrape-configs --from-file=prometheus-additional.yaml -n monitoring
3、挂载静态secret文件
修改prometheus-prometheus.yaml文件,在spec中添加如下内容:
additionalScrapeConfigs:
name: additional-scrape-configs
key: prometheus-additional.yaml
然后更新prometheus
kubectl apply -f prometheus-prometheus.yaml
4、再添加监控对象
修改prometheus-additional.yaml
- job_name: 'harbor'
static_configs:
- targets:
- harbor.bgxwz.com:9100
- job_name: 'gitlab'
static_configs:
- targets:
- gitlab.bgxwz.com:9100
然后重新创建secret文件,并部署
kubectl delete secret additional-scrape-configs -n monitoring
kubectl create secret generic additional-scrape-configs --from-file=prometheus-additional.yaml -n monitoring
评论区