我正在尝试部署一个可以使用prometheus进行监视的nginx入口控制器,但是我遇到了一个问题,似乎没有像我在网上找到的大多数帖子和文档一样创建任何指标pod。
我正在使用Helm部署入口控制器,并使用CLI争论来启用指标。
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
# add an annotation indicating the issuer to use.
kubernetes.io/ingress.class: "nginx"
cert-manager.io/cluster-issuer: "letsencrypt-dev"
# needed to allow the front end to talk to the back end
nginx.ingress.kubernetes.io/cors-allow-origin: "https://app.domain.com"
nginx.ingress.kubernetes.io/cors-allow-credentials: "true"
nginx.ingress.kubernetes.io/enable-cors: "true"
nginx.ingress.kubernetes.io/cors-allow-methods: "GET, PUT, POST, DELETE, PATCH, OPTIONS"
# needed for monitoring
prometheus.io/scrape: "true"
prometheus.io/port: "10254"
name: dev-ingress
namespace: development
spec:
rules:
- host: api.<domain>.com
http:
paths:
- backend:
serviceName: api
servicePort: 8090
path: /
tls: # < placing a host in the TLS config will indicate a certificate should be created
- hosts:
- api.<domai>.com
secretName: dev-ingress-cert # < cert-manager will store the created certificate in this secre
这是我的入口文件
helm install monitoring stable/prometheus-operator --namespace=monitoring
如果这有所作为,我将通过以下命令使用prometheus运算符舵图。
{{1}}
所有名称空间已经存在,因此不应该成为问题,因为我在很多地方看到的开发与监视名称空间都是可以接受的,因此我着手进行处理以使事情更容易弄清正在发生的事情。
答案 0 :(得分:2)
我将遵循此guide来设置对Nginx入口控制器的监视。我相信您缺少的是prometheus.yaml,它为Nginx入口控制器定义了scrape配置,为RBAC定义了Prometheus以便能够刮除Nginx入口控制器指标。
编辑:为Nginx Ingress控制器容器添加注释
kubectl annotate pods nginx-ingress-controller-pod prometheus.io/scrape=true -n ingress-nginx --overwrite
kubectl annotate pods nginx-ingress-controller-pod prometheus.io/port=10254 -n ingress-nginx --overwrite