文章目录
- 一、prometheus中添加ingress-nginx的服务发现配置
- 二、ingress-nginx controller的service添加端口暴露监控指标
- 三、grafana添加ingress-nginx controller的监控模版
ingress-nginx默认是没有开启监控指标的,需要我们在ingress-nginx controller的svc里面开启10254端口来暴露监控指标 然后进行抓取
ps:kubeadm方式和二进制方式部署的k8s集群都可以用此配置监控Ingress-Ningx Controller
一、prometheus中添加ingress-nginx的服务发现配置
prometheus部署链接:https://blog.csdn.net/qq_44930876/article/details/138163947
- job_name: 'kubernetes-ingress-controller'
kubernetes_sd_configs:
- role: endpoints
relabel_configs:
- action: keep
regex: ingress-nginx;ingress-nginx-controller;metrics
source_labels:
- __meta_kubernetes_namespace
- __meta_kubernetes_service_name
- __meta_kubernetes_endpoint_port_name
scheme: http
二、ingress-nginx controller的service添加端口暴露监控指标
apiVersion: v1
kind: Service
...
spec:
ports:
- appProtocol: http
name: http
port: 80
protocol: TCP
targetPort: http
- appProtocol: https
name: https
port: 443
protocol: TCP
targetPort: https
- name: metrics
port: 10254
targetPort: 10254
...
然后重新apply一下使其ingress-controller生效
完成开启10254端口后就可以在prometheus上看到监控的ingress-nginx目标了
三、grafana添加ingress-nginx controller的监控模版
grafana模版中心ingress-nginx监控模版:https://grafana.com/grafana/dashboards/20275-ingress-nginx-dashboard/
或者直接使用我下载好的:
https://download.csdn.net/download/qq_44930876/89871863
或者直接导入 grafana模版中心的ingress-nginx controller监控模板ID:20275