Thanos 需要在 Service 中将 targetPort 定义为字符串,以便 ServiceMonitor 与之通信。
但是,仅将 targetPort 定义为字符串会导致问题。我相信部署中还需要更多东西。我认为必须在部署中定义 targetPort 'web'。
任何人都可以协助部署的外观吗?
apiVersion: v1
kind: Service
metadata:
name: my-service
labels:
app: my-app
tenant: a
servicemonitor: my-servicemonitor
monitor: "true"
spec:
type: ClusterIP
ports:
- name: web
port: 80
protocol: TCP
targetPort: web
selector:
app: my-app
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
labels:
app: my-app
tenant: a
name: my-monitor
spec:
endpoints:
- port: web
path: /metrics
namespaceSelector:
matchNames:
- my-namespace
selector:
matchLabels:
servicemonitor: my-servicemonitor
monitor: "true"