Traefik 进入普罗米修斯
Traefik ingress to prometheus
我想将传入流量重定向到 myserver.mydomain。com/prometheus 到我的 prometheus pod。这是我尝试实现此目的的 YAML 文件:
这是部署清单:
apiVersion: apps/v1
kind: Deployment
metadata:
name: prometheus-deployment
namespace: monitoring
spec:
replicas: 1
selector:
matchLabels:
app: prometheus-server
template:
metadata:
labels:
app: prometheus-server
spec:
containers:
- name: prometheus
image: prom/prometheus:latest
args:
- "--config.file=/etc/prometheus/prometheus.yml"
- "--storage.tsdb.path=/prometheus/"
- "--web.external-url=http://myserver.mydomain.com/prometheus"
ports:
- containerPort: 9090
volumeMounts:
- name: prometheus-config-volume
mountPath: /etc/prometheus/
- name: prometheus-storage-volume
mountPath: /prometheus/
volumes:
- name: prometheus-config-volume
configMap:
defaultMode: 420
name: prometheus-server-conf
- name: prometheus-storage-volume
persistentVolumeClaim:
claimName: prometheus-local-zfs-pvc
服务清单...
apiVersion: v1
kind: Service
metadata:
name: prometheus-service
namespace: monitoring
annotations:
prometheus.io/scrape: 'true'
prometheus.io/port: '9090'
spec:
selector:
app: prometheus-server
ports:
- name: http
protocol: TCP
port: 80
targetPort: 9090
...以及入口清单...
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: prometheus-ingress
namespace: monitoring
annotations:
kubernetes.io/ingress.class: traefik
spec:
rules:
- host: myserver.mydomain.com
http:
paths:
- path: /prometheus
backend:
serviceName: prometheus-service
servicePort: 80
但是,这个returns一个404。我做错了什么?
编辑:我添加了@coderanger 建议的选项。在应用新部署时我注意到的一件事是,在删除旧 Pod 之前启动新 Pod 时似乎存在锁定问题,日志中的错误是 err="opening storage failed: lock DB directory: resource temporarily unavailable....
您需要在 Prometheus 命令行选项上传递 --web.external-url
,因为您要将其移动到子路径。
我想将传入流量重定向到 myserver.mydomain。com/prometheus 到我的 prometheus pod。这是我尝试实现此目的的 YAML 文件:
这是部署清单:
apiVersion: apps/v1
kind: Deployment
metadata:
name: prometheus-deployment
namespace: monitoring
spec:
replicas: 1
selector:
matchLabels:
app: prometheus-server
template:
metadata:
labels:
app: prometheus-server
spec:
containers:
- name: prometheus
image: prom/prometheus:latest
args:
- "--config.file=/etc/prometheus/prometheus.yml"
- "--storage.tsdb.path=/prometheus/"
- "--web.external-url=http://myserver.mydomain.com/prometheus"
ports:
- containerPort: 9090
volumeMounts:
- name: prometheus-config-volume
mountPath: /etc/prometheus/
- name: prometheus-storage-volume
mountPath: /prometheus/
volumes:
- name: prometheus-config-volume
configMap:
defaultMode: 420
name: prometheus-server-conf
- name: prometheus-storage-volume
persistentVolumeClaim:
claimName: prometheus-local-zfs-pvc
服务清单...
apiVersion: v1
kind: Service
metadata:
name: prometheus-service
namespace: monitoring
annotations:
prometheus.io/scrape: 'true'
prometheus.io/port: '9090'
spec:
selector:
app: prometheus-server
ports:
- name: http
protocol: TCP
port: 80
targetPort: 9090
...以及入口清单...
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: prometheus-ingress
namespace: monitoring
annotations:
kubernetes.io/ingress.class: traefik
spec:
rules:
- host: myserver.mydomain.com
http:
paths:
- path: /prometheus
backend:
serviceName: prometheus-service
servicePort: 80
但是,这个returns一个404。我做错了什么?
编辑:我添加了@coderanger 建议的选项。在应用新部署时我注意到的一件事是,在删除旧 Pod 之前启动新 Pod 时似乎存在锁定问题,日志中的错误是 err="opening storage failed: lock DB directory: resource temporarily unavailable....
您需要在 Prometheus 命令行选项上传递 --web.external-url
,因为您要将其移动到子路径。