【发布时间】:2021-10-13 03:42:02
【问题描述】:
我有一个带有 nginx 容器的简单 pod,它在路径 / 上返回文本 healthy。我有普罗米修斯在路径/ 上抓取端口 80。当我在 prometheus 仪表板中运行 up == 0 时,它显示了这个 pod,这意味着这个 pod 不健康。但我尝试 ssh 进入容器,它运行良好,我在 nginx 日志中看到 prometheus 正在 ping / 并得到 200 响应。知道为什么吗?
deployment.yml
apiVersion: apps/v1
kind: Deployment
metadata:
...
spec:
...
template:
metadata:
labels:
...
annotations:
prometheus.io/scrape: "true"
prometheus.io/path: "/"
prometheus.io/port: "80"
spec:
containers:
- name: nginx
image: nginx
volumeMounts:
- name: nginx-conf
mountPath: /etc/nginx
readOnly: true
ports:
- containerPort: 80
volumes:
- name: nginx-conf
configMap:
name: nginx-conf
items:
- key: nginx.conf
path: nginx.conf
nginx.conf
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-conf
data:
nginx.conf: |
http {
server {
listen 80;
location / {
return 200 'healthy\n';
}
}
}
nginx访问日志
192.168.88.81 - - [xxx +0000] "GET / HTTP/1.1" 200 8 "-" "Prometheus/2.26.0"
192.168.88.81 - - [xxx +0000] "GET / HTTP/1.1" 200 8 "-" "Prometheus/2.26.0"
192.168.88.81 - - [xxx +0000] "GET / HTTP/1.1" 200 8 "-" "Prometheus/2.26.0"
【问题讨论】:
标签: kubernetes prometheus