[英]Zabbix 6.0 Agent doesn't collect metrics in Kubernetes and can't talk with server
在過去的幾天里,我一直在 kubernetes 中設置 Zabbix Agent,但我一直堅持我認為最基本的事情。 我已經創建了一個全新的命名空間,在那里設置了 MySQL 並對其進行了配置,具有 zabbixUser、pass 和所有內容,我已經從這個Helm Chart 設置了 Zabbix Server。
這是它的值文件
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
注意:它托管在我公司的內部域中,MySQL 也用於測試目的,因此沒有產品憑據。
我也配置了 DNS,所以一切如您所見。
現在我想從這個官方 helm chart 設置 Zabbix agent。
這里還有一個有用的鏈接,顯示准備好的模板以幫助從 GKE 集群獲取指標——但是,請注意,當您從 helm chart 設置 Zabbix 服務器時,他會內置它們。 所以我想如果你有一個舊版本並且在 VM 上,它會很有用。
這是代理的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
現在我們來解決我遇到的問題
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>
來自 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"
那是什么意思呢? 在 zabbix-agent values.yaml
我寫到 zabbix server host 是
- name: ZBX_SERVER_HOST
value: 10.190.40.58
但是 zabbix-agent 字面上說它自己的 IP 不能被列入白名單? 這是什么意思呢?
另外,這些是來自 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.
正如在頁面底部的 Zabbix Setup 中的說明中所寫的那樣。 另外,我更不知道的是這里的 Zabbix 配置部分 所有這些 {$KUBE.API.ENDPOINT.URL}
它們應該指向什么?
你們會給我任何提示讓我開心,比如為什么看不到節點,為什么代理顯然不能與服務器對話,以及我是否應該更改{$KUBE.API.ENDPOINT.URL}
或保留它具有默認值。
{$KUBE.API.ENDPOINT.URL}
這應該指向https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_SERVICE_PORT
。
我從正在運行的 pod 中獲取值。 但是,我沒有嘗試在 Zabbix 中作為 env 值。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.