【问题标题】:Prometheus unauthorized access to Azure Kubernetes APIPrometheus 未经授权访问 Azure Kubernetes API
【发布时间】:2018-09-21 13:57:02
【问题描述】:

我正在尝试在专用 Linux VM 上设置 Prometheus 监控以获取 Kubernetes 集群指标。

无论我尝试什么,我总是被未授权的好消息阻止...

这是我对 pod 的抓取配置:

- job_name: 'Kubernetes'
scheme: https
tls_config:
  insecure_skip_verify: true
bearer_token: %VeryLongLine%
kubernetes_sd_configs:
- api_server: https://%ClusterName%.hcp.westeurope.azmk8s.io
  tls_config:
    insecure_skip_verify: true
  role: node
  namespaces:
    names: [default]

令牌是正确的,因为来自 PowerShell 的 Invoke-WebRequest 工作正常。

有人有想法吗?

谢谢

【问题讨论】:

    标签: kubernetes prometheus


    【解决方案1】:
    - job_name: 'Kubernetes'
      scheme: https
      tls_config:
       insecure_skip_verify: true
      kubernetes_sd_configs:
      - api_server: https://%ClusterName%.hcp.westeurope.azmk8s.io
        bearer_token: %VeryLongLine%
        role: node
        namespaces:
          names: [default]
    

    不记名令牌在正确的位置,所以在 kubernetes 配置中而不是在作业中

    【讨论】:

      【解决方案2】:

      您的服务帐户似乎缺少 CA:

      - job_name: 'Kubernetes'
        scheme: https
        tls_config:
          insecure_skip_verify: true
          ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
        bearer_token: %VeryLongLine%
        kubernetes_sd_configs:
        - api_server: https://%ClusterName%.hcp.westeurope.azmk8s.io
          role: node
          namespaces:
            names: [default]
      

      希望对你有帮助!

      【讨论】:

      • 最后,bearer_token 行不在正确的位置...但现在我遇到了 pod 问题,我不断收到 Get 10.100.52.68:443/metrics: dial tcp 10.100.52.68:443 :连接:连接被拒绝,这是一个 pod。我无法从我的 vm 中获取有问题的 url,但我可以 ping pod(将网卡添加到 pod 的网络中)
      猜你喜欢
      • 2019-08-13
      • 1970-01-01
      • 2016-08-12
      • 2017-02-26
      • 1970-01-01
      • 2020-05-24
      • 2015-03-05
      • 2013-10-06
      • 2021-01-09
      相关资源
      最近更新 更多