简体   繁体   English

Zabbix 6.0 Agent 不在 Kubernetes 中收集指标并且无法与服务器通信

[英]Zabbix 6.0 Agent doesn't collect metrics in Kubernetes and can't talk with server

I've been setting up Zabbix Agent in kubernetes the past few days and I'm stuck on what I think is the most basic thing.在过去的几天里,我一直在 kubernetes 中设置 Zabbix Agent,但我一直坚持我认为最基本的事情。 I've created a brand new namespace, setup MySQL there and configured it, has the zabbixUser, pass and everything, I've setup Zabbix Server from this Helm Chart.我已经创建了一个全新的命名空间,在那里设置了 MySQL 并对其进行了配置,具有 zabbixUser、pass 和所有内容,我已经从这个Helm Chart 设置了 Zabbix Server。

Here are the values files for it这是它的值文件

zabbixserver:
  image:
    #repository: zabbix/zabbix-server-pgsql
    repository: "zabbix/zabbix-server-mysql" #https://hub.docker.com/r/zabbix/zabbix-server-pgsql
    tag: "ubuntu-6.0.3"

  DB_SERVER_HOST: "zabbix-mysql"
  DB_SERVER_PORT: "3306"

  # -- Extra environment variables. A list of additional environment variables. See example: https://github.com/cetic/helm-zabbix/blob/master/docs/example/kind/values.yaml
  #  taken from mysql config
  extraEnv:
    - name: "MYSQL_USER"
      value: "zabbixUser"
    - name: "MYSQL_PASSWORD"
      value: "zabbixPass"
    - name: "MYSQL_ROOT_PASSWORD"
      value: "dyEMnUK69d"
    - name: "MYSQL_DATABASE"
      value: "zabbix"

postgresql:
  enabled: false

zabbixproxy:
  enabled: false
    #  # The variable is used to specify debug level, from 0 to 5
    #  ZBX_DEBUGLEVEL: 3
    #  ZBX_PROXYMODE: 1
    #  ZBX_SERVER_HOST: 10.190.8.122

# Installs zabbix agent next on the same pod as server
zabbixagent:
  enabled: true
  env:
    - name: ZBX_DEBUGLEVEL
      value: 4


zabbixweb:
  image:
    repository: "zabbix/zabbix-web-nginx-mysql" #https://hub.docker.com/r/zabbix/zabbix-web-nginx-mysql
    #repository: zabbix/zabbix-web-nginx-psql #https://hub.docker.com/r/zabbix/zabbix-web-nginx-pgsql
    tag: "ubuntu-6.0.3"

# kubectl get services
  ZBX_SERVER_HOST: zabbix-server-zabbix-server
  DB_SERVER_HOST: zabbix-mysql
  DB_SERVER_PORT: 3306

  extraEnv:
    - name: "MYSQL_USER"
      value: "zabbixUser"
    - name: "MYSQL_PASSWORD"
      value: "zabbixPass"
    - name: "MYSQL_ROOT_PASSWORD"
      value: "dyEMnUK69d"
    - name: "MYSQL_DATABASE"
      value: "zabbix"

ingress:
  enabled: true
  hosts:
    - host: better-zabbix.genesis
      paths:
        - path: /
          pathType: Prefix
  ingressClassName: nginx-internal

NOTE: It's hosted in my company's internal domain, and MySQL is also for testing purposes so no prod credentials.注意:它托管在我公司的内部域中,MySQL 也用于测试目的,因此没有产品凭据。

I configured DNS as well so it all works as you can see.我也配置了 DNS,所以一切如您所见。

在此处输入图像描述

Now I wanted to set up the Zabbix agent fromthis official helm chart.现在我想从这个官方 helm chart 设置 Zabbix agent。

Here is also a useful link showing ready templates to help get metrics from the GKE cluster - however, note that when you set up the Zabbix server from helm chart, he comes with them built-in.这里还有一个有用的链接,显示准备好的模板以帮助从 GKE 集群获取指标——但是,请注意,当您从 helm chart 设置 Zabbix 服务器时,他会内置它们。 So I guess it's useful if you've got an older version and are on VM.所以我想如果你有一个旧版本并且在 VM 上,它会很有用。

Here are my values.yaml for agent这是代理的values.yaml

zabbixAgent:
  image:
    repository: zabbix/zabbix-agent
    tag: alpine-6.0.3
  env:
    - name: ZBX_SERVER_HOST
      value: 10.190.40.58 # after zabbix server was created, this is the IP of his pod
      #value: 127.0.0.1
      #value: "better-zabbix.genesis"

zabbixProxy:
  enabled: false
rbac:
  create: false
serviceAccount:
  create: false

And now we get to the problem I have现在我们来解决我遇到的问题

Every 2.0s: kubectl get pods -o wide                                                                                                       colgate.local: Sat Apr 16 15:54:05 2022

NAME                                               READY   STATUS    RESTARTS   AGE     IP             NODE                                 NOMINATED NODE   READINESS GATES
potato                                             1/1     Running   0          5h26m   10.190.4.102   gke-tools-single-nat-35d661ab-sf1c   <none>           <none>
zabbix-agent-7d4xv                                 1/1     Running   0          3h49m   10.222.0.59    gke-tools-single-nat-d4ec251a-hp7k   <none>           <none>
zabbix-agent-856lm                                 1/1     Running   0          3h46m   10.222.0.39    gke-tools-main-tools-bc42e123-6fpq   <none>           <none>
zabbix-agent-c5xtp                                 1/1     Running   0          3h47m   10.222.0.9     gke-tools-main-tools-bc42e123-ycgx   <none>           <none>
zabbix-agent-dn78k                                 1/1     Running   0          3h49m   10.222.0.98    gke-tools-single-nat-d4ec251a-i0a1   <none>           <none>
zabbix-agent-fbpzn                                 1/1     Running   0          3h49m   10.222.0.54    gke-tools-single-nat-d4ec251a-kxwn   <none>           <none>
zabbix-agent-gsvgt                                 1/1     Running   0          3h47m   10.222.0.51    gke-tools-main-tools-bc42e123-oc1i   <none>           <none>
zabbix-agent-h4bkn                                 1/1     Running   0          3h49m   10.222.0.50    gke-tools-single-nat-2dc0d382-1uv1   <none>           <none>
zabbix-agent-kube-state-metrics-5968c76968-6jb98   1/1     Running   0          3h59m   10.190.1.48    gke-tools-single-nat-d4ec251a-i0a1   <none>           <none>
zabbix-agent-pfs5s                                 1/1     Running   0          3h47m   10.222.0.55    gke-tools-single-nat-d4ec251a-4o43   <none>           <none>
zabbix-agent-plk7s                                 1/1     Running   0          3h46m   10.222.0.49    gke-tools-single-nat-35d661ab-xxsw   <none>           <none>
zabbix-agent-qm5c5                                 1/1     Running   0          3h48m   10.222.0.41    gke-tools-single-nat-35d661ab-m4ct   <none>           <none>
zabbix-agent-wk59p                                 1/1     Running   0          3h48m   10.222.0.5     gke-tools-single-nat-2dc0d382-zp2s   <none>           <none>
zabbix-agent-wl97k                                 1/1     Running   0          3h48m   10.222.0.88    gke-tools-main-tools-89255868-mxfl   <none>           <none>
zabbix-agent-z6vxh                                 1/1     Running   0          3h49m   10.222.0.46    gke-tools-single-nat-35d661ab-sf1c   <none>           <none>
zabbix-mysql-0                                     1/1     Running   0          3h59m   10.190.1.49    gke-tools-single-nat-d4ec251a-i0a1   <none>           <none>
zabbix-mysql-client                                1/1     Running   0          5h7m    10.190.0.215   gke-tools-single-nat-2dc0d382-zp2s   <none>           <none>
zabbix-server-zabbix-server-0                      2/2     Running   0          3h59m   10.190.2.99    gke-tools-single-nat-2dc0d382-1uv1   <none>           <none>
zabbix-server-zabbix-web-665c9b767-ssdt6           1/1     Running   0          3h59m   10.190.4.113   gke-tools-single-nat-35d661ab-sf1c   <none>           <none>

Logs from zabbix-agent pods are like this来自 zabbix-agent pod 的日志是这样的

3438519:20220416:135248.449 failed to accept an incoming connection: connection from "10.222.0.54" rejected, allowed hosts: "10.190.40.58"

So what does it mean?那是什么意思呢? In zabbix-agent values.yaml I wrote that zabbix server host is在 zabbix-agent values.yaml我写到 zabbix server host 是

    - name: ZBX_SERVER_HOST
      value: 10.190.40.58

but the zabbix-agent says literally its own IP cannot be whitelisted?但是 zabbix-agent 字面上说它自己的 IP 不能被列入白名单? what does it all mean?这是什么意思呢?

also, these are the logs from zabbix server另外,这些是来自 zabbix 服务器的日志

   208:20220416:135600.044 [ Kubernetes discovery ] ERROR: Incorrect JSON. Check debug log for more information.
   208:20220416:135600.045 [ Kubernetes discovery ] ERROR: Incorrect JSON. Check debug log for more information.
   226:20220416:135600.045 [ Kubernetes ] ERROR: Error: cannot get URL: Couldn't connect to server.
   208:20220416:135600.047 [ Kubernetes discovery ] ERROR: Incorrect JSON. Check debug log for more information.
   208:20220416:135600.048 [ Kubernetes discovery ] ERROR: Incorrect JSON. Check debug log for more information.
   226:20220416:135600.049 [ Kubernetes ] ERROR: Error: cannot get URL: Couldn't connect to server.
   208:20220416:135600.051 [ Kubernetes discovery ] ERROR: Incorrect JSON. Check debug log for more information.
   208:20220416:135600.052 [ Kubernetes discovery ] ERROR: Incorrect JSON. Check debug log for more information.

The autoregistration I have set up on zabbix-server works我在 zabbix-server 上设置的自动注册有效在此处输入图像描述

and we can see the hosts我们可以看到主机在此处输入图像描述

but the problem stays that agents can't get metrics/data from nodes但问题仍然存在,代理无法从节点获取指标/数据在此处输入图像描述

I'll add that I configured the template with token我要补充一点,我用token配置了模板在此处输入图像描述

As it was written in this instructions in Zabbix Setup at the bottom of the page.正如在页面底部的 Zabbix Setup 中说明中所写的那样。 Also, the one more unknown to me is the Zabbix configuration part from here All these另外,我更不知道的是这里的 Zabbix 配置部分 所有这些在此处输入图像描述 {$KUBE.API.ENDPOINT.URL} what should they point to? {$KUBE.API.ENDPOINT.URL}它们应该指向什么?

You guys would make my day by giving any hint as, why nodes are not seen, why agents apparently can't talk to the server, and whether should I change the {$KUBE.API.ENDPOINT.URL} or leave it as it was with default values.你们会给我任何提示让我开心,比如为什么看不到节点,为什么代理显然不能与服务器对话,以及我是否应该更改{$KUBE.API.ENDPOINT.URL}或保留它具有默认值。

{$KUBE.API.ENDPOINT.URL} this should point to https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_SERVICE_PORT . {$KUBE.API.ENDPOINT.URL}这应该指向https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_SERVICE_PORT

I get the values from a running pod.我从正在运行的 pod 中获取值。 However, I did not try as a env value in Zabbix.但是,我没有尝试在 Zabbix 中作为 env 值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM