Metricbeat kubernetes 模块无法连接到 kubelet

Metricbeat kubernetes module can’t connect to kubelet

我们有一个设置,其中 Metricbeat 作为 DaemonSet 部署在 Kubernetes 集群上(特别是 -- AWS EKS)。

似乎一切正常,但是 kubelet 连接。

为了澄清,以下模块:

- module: kubernetes
  enabled: true
  metricsets:
    - state_pod
  period: 10s
  hosts: ["kube-state-metrics.system:8080"]

工作正常(事件流入 logstash/elastic)。

但是,此模块配置不适用于主机值的任何变体(localhost/kubernetes.default/无论什么):

- module: kubernetes
  period: 10s
  metricsets:
    - pod
  hosts: ["localhost:10255"]
  enabled: true
  add_metadata: true
  in_cluster: true

NOTE: using cluster IP instead of localhost (so that it goes to control plane) also works (although doesn't retrieve the needed information, of course).

The configuration above was taken directly from the Metricbeat documentation and immediately struck me as odd -- how does localhost get translated (from within Metricbeat docker) to corresponding kubelet?

根据上述情况,正如人们所预料的那样,错误是:

error making http request: Get http://localhost:10255/stats/summary: 
dial tcp [::1]:10255: connect: cannot assign requested address

这表明存在某种连接问题。

但是,当 SSH 连接到部署了 Metricbeat 的任何节点时,http://localhost:10255/stats/summary 提供了正确的输出:

{
  "node": {
   "nodeName": "...",
   "systemContainers": [
    {
     "name": "pods",
     "startTime": "2018-12-06T11:22:07Z",
     "cpu": {
      "time": "2018-12-23T06:54:06Z",
      ...
     },
     "memory": {
      "time": "2018-12-23T06:54:06Z",
      "availableBytes": 17882275840,
      ....

我一定漏掉了一些非常明显的东西。任何建议都可以。

注意:我在 Elasticsearch Forums

上交叉发布了相同的内容(并且几天没有收到回复)

通过 env: 列表中的 valueFrom 提供商注入 Pod 节点的 IP:

env:
- name: HOST_IP
  valueFrom:
    fieldRef: status.hostIP

然后更新 metricbeat 配置文件以使用主机的 IP:

hosts: ["${HOST_IP}:10255"]

哪个 metricbeat 将通过其 environment variable config injection

解析