K8S-使用Prometheus以安全的方式监视另一个Prometheus实例

我已经在群集 A (主舞会)上安装了Prometheus operator 0.34(按预期工作) 现在,我想使用federation选项,我的意思是从其他K8S集群 B

上的其他Prometheus收集指标

Secnario:

  
      
  1. 位于群集 A 中主要prometheus operator v0.34 config
  2.   
  3. 我在集群 B 中从prometheus 2.13.1 config
  4.   

两者都通过头盔成功安装,我可以通过port-forwarding访问localhost并查看每个群集上的抓取结果。

我执行了以下步骤

在操作员上使用(主群集A)additionalScrapeconfig 我已将以下内容添加到values.yaml文件中,并通过头盔对其进行了更新。

additionalScrapeConfigs:
 - job_name: 'federate'  
   honor_labels: true
   metrics_path: /federate
   params:
     match[]:
       - '{job="prometheus"}'
       - '{__name__=~"job:.*"}'
   static_configs:
     - targets:
       - 101.62.201.122:9090 # The External-IP and port from the target prometheus on Cluster B

我的目标如下:

我在集群B 中的普罗米修斯(我要从中收集数据)上使用:

kubectl get svc -n monitoring

并获得以下条目:

使用EXTERNAL-IP并将其放入additionalScrapeConfigs配置条目中。

现在,我切换到群集A并运行kubectl port-forward svc/mon-prometheus-operator-prometheus 9090:9090 -n monitoring

使用localhost:9090打开浏览器,查看图表,然后单击Status,然后单击Targets

然后查看作业federate的新目标

K8S-使用Prometheus以安全的方式监视另一个Prometheus实例

现在我的主要问题/差距。 (安全和验证)

  1. 为了能够以绿色看到目标state(请参见图片),我在集群B中配置了Prometheus服务器,而不是使用type:NodePort来使用type:LoadBalacer将指标暴露在外部,这对于测试很有用,但是我需要确保其安全,该如何完成? 如何使e2e以安全的方式 ...
  2. 工作

tls https://prometheus.io/docs/prometheus/1.8/configuration/configuration/#tls_config

集群A 内部(主集群),我们将证书用于istio的出站服务,如下面所述的那样工作

tls:
   mode: SIMPLE
   privateKey: /etc/istio/oss-tls/tls.key
   serverCertificate: /etc/istio/oss-tls/tls.crt

我看到文档中有一个配置选项

    additionalScrapeConfigs:
     - job_name: 'federate'  
       honor_labels: true
       metrics_path: /federate
       params:
         match[]:
           - '{job="prometheus"}'
           - '{__name__=~"job:.*"}'
       static_configs:
         - targets:
           - 101.62.201.122:9090 # The External-IP and port from the target
#        tls_config:
#          ca_file: /opt/certificate-authority-data.pem
#          cert_file: /opt/client-certificate-data.pem
#          key_file: /sfp4/client-key-data.pem
#          insecure_skip_verify: true

但是不确定在prometheus运算符config中需要使用哪个证书,主要prometheus A或从属B的证书?

A19900919woaijisuanj 回答:K8S-使用Prometheus以安全的方式监视另一个Prometheus实例

  1. 您应该考虑使用Additional Scrape Configuration
  

AdditionalScrapeConfigs允许指定密钥的密钥   包含其他Prometheus抓取配置。刮   指定的配置将附加到生成的配置中   由Prometheus运算符提供。

  1. 我很抱歉,这没有得到正式支持。但是,您可以在Helm图表中更新prometheus.yml部分。如果您想了解更多信息,请查看this blog

  2. 我在这里看到两个选项:

  

与Prometheus及其出口商的连接未加密,并且   默认情况下经过身份验证。 This is one way of fixing that with TLS certificates and stunnel

或指定Secrets,您可以将其添加到抓取配置中。

请让我知道是否有帮助。

,

想到几个选择:

  1. 将两个群集放在相同的网络空间中,并在它们前面放置防火墙
  2. 群集之间的VPN隧道。
  3. 使用istio多集群路由(但这可能会变得很复杂):https://istio.io/docs/setup/install/multicluster
本文链接:https://www.f2er.com/3056248.html

大家都在问