我需要使用 Prometheus Operator 监控多个 ubuntu 服务器。这些服务器位于运行我的 prometheus 操作员的 kubernetes 集群之外。下面的清单用于监控其中一台具有 IP 的服务器aaa.bbb.ccc.ddd
。如何添加多个 IP 作为端点进行监控?或者我是否需要为每台服务器创建一个端点/服务?
apiVersion: v1
kind: Service
metadata:
name: external-server
namespace: monitoring
labels:
k8s-app: external-server
spec:
type: ExternalName
externalName: aaa.bbb.ccc.ddd
clusterIP: ""
ports:
- name: metrics
port: 9100
protocol: TCP
targetPort: 9100
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: external-server
labels:
k8s-app: external-server
spec:
endpoints:
- port: metrics
interval: 30s
honorLabels: true
path: /metrics
selector:
matchLabels:
k8s-app: external-server
namespaceSelector:
matchNames:
- monitoring
apiVersion: v1
kind: Endpoints
metadata:
name: external-server
labels:
k8s-app: external-server
subsets:
- addresses:
- ip: aaa.bbb.ccc.ddd
ports:
- name: metrics
port: 9100
protocol: TCP