values部署代码
# Global overrides
nameOverride: ""
fullnameOverride: ""
## Global Service Account Configuration
serviceAccount:
create: true
name: "zabbix-global-service-account"
annotations: {}
automountServiceAccountToken: true
## Kubernetes Metrics
kubeStateMetrics:
enabled: true
## RBAC Configuration
rbac:
create: true
additionalRulesForClusterRole: []
pspEnabled: false # 明确禁用PSP
## Zabbix Proxy Configuration
zabbixProxy:
enabled: true
containerSecurityContext: {}
resources:
limits:
memory: "512Mi"
cpu: "500m"
requests:
memory: "256Mi"
cpu: "200m"
image:
repository: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/zabbix/zabbix-proxy-mysql
tag: alpine-7.2-latest
pullPolicy: IfNotPresent
pullSecrets: []
env:
- name: ZBX_PROXYMODE
value: "0"
- name: ZBX_HOSTNAME
value: "zabbix-proxy-rke2"
- name: ZBX_DBTLSSKIP_VERIFY_HOST
value: "false"
- name: ZBX_DBTLS_CONNECT
value: "disabled"
# 使用DNS解析Zabbix Server
- name: ZBX_SERVER_HOST
value: "zabbix-server.zabbix.svc.cluster.local"
- name: DEBUG_MODE
value: "true"
- name: ZBX_DEBUGLEVEL
value: "5"
- name: ZBX_CACHESIZE
value: "128M"
- name: ZBX_STARTJAVAPOLLERS
value: "0"
# 数据库连接配置 - 使用DNS解析
- name: ZBX_DBUSER
value: "zabbix"
- name: ZBX_DBPASSWORD
value: "Admin123"
- name: ZBX_DBNAME
value: "zabbix_proxy"
- name: DB_SERVER_HOST
value: "localhost"
- name: MYSQL_ROOT_PASSWORD
value: Admin123
livenessProbe:
enabled: true
tcpSocket:
port: zabbix-proxy
initialDelaySeconds: 60
timeoutSeconds: 5
failureThreshold: 3
periodSeconds: 15
readinessProbe:
enabled: true
tcpSocket:
port: zabbix-proxy
initialDelaySeconds: 30
timeoutSeconds: 5
failureThreshold: 3
periodSeconds: 10
startupProbe:
enabled: true
tcpSocket:
port: zabbix-proxy
initialDelaySeconds: 180 # 延长启动等待时间
timeoutSeconds: 5
failureThreshold: 10 # 增加失败阈值
periodSeconds: 15
service:
type: ClusterIP
port: 25111
targetPort: 25111
name: zabbix-proxy
persistentVolume:
enabled: false # 启用持久化存储
accessModes: [ReadWriteOnce]
mountPath: /var/lib/zabbix
size: 2Gi
storageClass: "standard"
## Zabbix Agent Configuration
zabbixAgent:
enabled: true
resources:
limits:
memory: "128Mi"
cpu: "200m"
requests:
memory: "64Mi"
cpu: "100m"
securityContext: {}
containerSecurityContext: {}
# 使用Pod网络
hostNetwork: false
hostPID: false
hostRootFsMount: true
# DNS优化配置
dnsConfig:
options:
- name: ndots
value: "2"
image:
repository: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/zabbix/zabbix-agent2
tag: alpine-7.2-latest
pullPolicy: IfNotPresent
env:
- name: ZBX_LISTENPORT
value: "25110"
- name: ZBX_HOSTNAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
# 使用DNS解析Zabbix Proxy
- name: ZBX_SERVER_HOST
value: "192.168.1.133"
- name: ZBX_SERVER_PORT
value: "25111"
- name: ZBX_PASSIVE_ALLOW
value: "true"
- name: ZBX_ACTIVE_ALLOW
value: "false"
- name: ZBX_DEBUGLEVEL
value: "3"
- name: ZBX_TIMEOUT
value: "4"
livenessProbe:
enabled: true
tcpSocket:
port: zabbix-agent
initialDelaySeconds: 30
timeoutSeconds: 5
failureThreshold: 3
periodSeconds: 15
readinessProbe:
enabled: true
tcpSocket:
port: zabbix-agent
initialDelaySeconds: 30
timeoutSeconds: 5
failureThreshold: 3
periodSeconds: 10
startupProbe:
enabled: true
tcpSocket:
port: zabbix-agent
initialDelaySeconds: 60
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 6
nodeSelector:
kubernetes.io/os: linux
tolerations:
- effect: NoSchedule
key: node-role.kubernetes.io/control-plane
operator: Exists
- effect: NoSchedule
key: node-role.kubernetes.io/master
operator: Exists
serviceAccount:
create: true
name: "zabbix-agent-service-account"
automountServiceAccountToken: false # 增强安全
service:
type: ClusterIP
port: 25110
targetPort: 25110
portName: zabbix-agent
rbac:
create: true
pspEnabled: false
pspAnnotations: {}
## Zabbix Java Gateway Configuration
zabbixJavaGateway:
enabled: false
报错代码
[root@master zabbix-helm-chrt]# kubectl logs -n monitoring zabbix-proxy-665fcd6946-79jlx
+ ZABBIX_INTERNAL_ENC_DIR=/var/lib/zabbix/enc_internal
+ : utf8mb4
+ : utf8mb4_bin
+ '[' /usr/sbin/zabbix_proxy '!=' /usr/sbin/zabbix_proxy ']'
+ '[' /usr/sbin/zabbix_proxy == /usr/sbin/zabbix_proxy ']'
+ prepare_proxy
+ echo '** Preparing Zabbix proxy'
+ prepare_db
+ echo '** Preparing database'
+ check_variables_mysql
+ '[' '!' -n '' ']'
+ : localhost
+ : 3306
+ USE_DB_ROOT_USER=false
+ CREATE_ZBX_DB_USER=false
+ file_env MYSQL_USER
+ local var=MYSQL_USER
+ local fileVar=MYSQL_USER_FILE
+ local defaultValue=
+ '[' '' ']'
+ local val=
+ '[' '' ']'
+ '[' '' ']'
+ export MYSQL_USER=
+ MYSQL_USER=
+ unset MYSQL_USER_FILE
+ file_env MYSQL_PASSWORD
+ local var=MYSQL_PASSWORD
+ local fileVar=MYSQL_PASSWORD_FILE
+ local defaultValue=
+ '[' '' ']'
** Preparing Zabbix proxy
** Preparing database
+ local val=
+ '[' '' ']'
+ '[' '' ']'
+ export MYSQL_PASSWORD=
+ MYSQL_PASSWORD=
+ unset MYSQL_PASSWORD_FILE
+ file_env MYSQL_ROOT_USER
+ local var=MYSQL_ROOT_USER
+ local fileVar=MYSQL_ROOT_USER_FILE
+ local defaultValue=
+ '[' '' ']'
+ local val=
+ '[' '' ']'
+ '[' '' ']'
+ export MYSQL_ROOT_USER=
+ MYSQL_ROOT_USER=
+ unset MYSQL_ROOT_USER_FILE
+ file_env MYSQL_ROOT_PASSWORD
+ local var=MYSQL_ROOT_PASSWORD
+ local fileVar=MYSQL_ROOT_PASSWORD_FILE
+ local defaultValue=
+ '[' Admin123 ']'
+ '[' '' ']'
+ local val=
+ '[' Admin123 ']'
+ val=Admin123
+ echo '** Using MYSQL_ROOT_PASSWORD variable from ENV'
+ export MYSQL_ROOT_PASSWORD=Admin123
+ MYSQL_ROOT_PASSWORD=Admin123
+ unset MYSQL_ROOT_PASSWORD_FILE
+ '[' '!' -n '' ']'
+ '[' '' == true ']'
+ '[' '!' -n '' ']'
+ '[' '!' -n Admin123 ']'
+ '[' '' == true ']'
+ '[' -n Admin123 ']'
+ USE_DB_ROOT_USER=true
+ DB_SERVER_ROOT_USER=root
+ DB_SERVER_ROOT_PASS=Admin123
+ '[' -n '' ']'
+ DB_SERVER_ROOT_USER=root
+ '[' '' == true ']'
+ DB_SERVER_ROOT_PASS=Admin123
+ DB_SERVER_ZBX_USER=zabbix
+ DB_SERVER_ZBX_PASS=zabbix
+ DB_SERVER_DBNAME=zabbix_proxy
+ '[' '!' -n '' ']'
+ mysql_connect_args='-h localhost -P 3306'
+ check_db_connect_mysql
+ echo '********************'
+ '[' '!' -n '' ']'
+ echo '* DB_SERVER_HOST: localhost'
+ echo '* DB_SERVER_PORT: 3306'
+ echo '* DB_SERVER_DBNAME: zabbix_proxy'
+ '[' true == true ']'
+ '[' true == true ']'
+ echo '* DB_SERVER_ROOT_USER: root'
+ echo '* DB_SERVER_ROOT_PASS: Admin123'
+ echo '* DB_SERVER_ZBX_USER: zabbix'
+ echo '* DB_SERVER_ZBX_PASS: zabbix'
+ echo '********************'
+ WAIT_TIMEOUT=5
++ db_tls_params
++ local result=
++ '[' -n '' ']'
++ echo
** Using MYSQL_ROOT_PASSWORD variable from ENV
********************
* DB_SERVER_HOST: localhost
* DB_SERVER_PORT: 3306
* DB_SERVER_DBNAME: zabbix_proxy
* DB_SERVER_ROOT_USER: root
* DB_SERVER_ROOT_PASS: Admin123
* DB_SERVER_ZBX_USER: zabbix
* DB_SERVER_ZBX_PASS: zabbix
********************
+ ssl_opts=
+ export MYSQL_PWD=Admin123
+ MYSQL_PWD=Admin123
++ mariadb-admin ping -h localhost -P 3306 -u root --silent --skip-ssl-verify-server-cert --connect_timeout=10
+ '[' '!' '' ']'
+ echo '**** MySQL server is not available. Waiting 5 seconds...'
+ sleep 5
**** MySQL server is not available. Waiting 5 seconds...
++ mariadb-admin ping -h localhost -P 3306 -u root --silent --skip-ssl-verify-server-cert --connect_timeout=10
+ '[' '!' '' ']'
+ echo '**** MySQL server is not available. Waiting 5 seconds...'
+ sleep 5
**** MySQL server is not available. Waiting 5 seconds...
++ mariadb-admin ping -h localhost -P 3306 -u root --silent --skip-ssl-verify-server-cert --connect_timeout=10
**** MySQL server is not available. Waiting 5 seconds...
+ '[' '!' '' ']'
+ echo '**** MySQL server is not available. Waiting 5 seconds...'
+ sleep 5
++ mariadb-admin ping -h localhost -P 3306 -u root --silent --skip-ssl-verify-server-cert --connect_timeout=10
+ '[' '!' '' ']'
+ echo '**** MySQL server is not available. Waiting 5 seconds...'
+ sleep 5
**** MySQL server is not available. Waiting 5 seconds...
++ mariadb-admin ping -h localhost -P 3306 -u root --silent --skip-ssl-verify-server-cert --connect_timeout=10
+ '[' '!' '' ']'
+ echo '**** MySQL server is not available. Waiting 5 seconds...'
+ sleep 5
**** MySQL server is not available. Waiting 5 seconds...