我是使用k8s中的Prometheus等监视工具的新手。我们有两个单独的集群,一个用于部署应用程序,一个仅用于部署监视,记录工具。
但是我有些困惑如何处理?
1。服务于普罗米修斯的集群如何连接到应用程序集群并能够提取指标?
2。如果要设置网络策略,应该如何指定名称空间?
3。除了导出指标外,我在应用程序侧对头盔图应该怎么做?
# Allow traffic from pods with label app=prometheus in namespace with label name=monitoring
# to any pod in <YOUR_APPLICATION_NAMESPACE>
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: monitoring.prometheus.all
namespace: <YOUR_APPLICATION_NAMESPACE>
spec:
ingress:
- from:
- namespaceSelector:
matchLabels:
name: monitoring
podSelector:
matchLabels:
app: prometheus
podSelector: {}
policyTypes:
- Ingress
您将必须使用LoadBalancer或Ingress或Nodeport在集群外部公开要为其收集度量的所有应用程序,以便可以从运行Prometheus的集群访问它们。在Prometheus scrape配置中,您需要指定那些公开的应用程序度量端点。