Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Deployment of zabbix monitoring system in K8s

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Introduction to zabbix

Zabbix is a network monitoring and management system based on Server-Client architecture. Can be used to monitor the status of various network services, servers, network machines, and so on. Zabbix uses MySQL, PostgreSQL, SQLite, Oracle, or IBM DB2 to store data. The Server end is based on C language, and the Web front end is based on PHP. Zabbix can be monitored in a number of ways. You can only use Simple Check without installing Client, and you can also do life or death monitoring based on various protocols such as SMTP or HTTP. After installing Zabbix Agent in clients such as UNIX and Windows, you can monitor CPU load, network usage, hard disk capacity, and so on. Even if Agent is not installed in the monitoring object, Zabbix can be checked by SNMP, TCP, ICMP, as well as using IPMI, SSH, telnet to monitor the target. In addition, Zabbix includes various Item warning functions such as XMPP.

Zabbix characteristics

Simple installation and deployment

Web visual management interface

Open source

Distributed system

Real-time drawing

Experimental environment

Kubernetes version 1.16.0

Zabbix version 4.4.5 (official image)

Mysql version 8.0.19 (official image)

(guess you like it: use zabbix to monitor the solution of abnormal POD in K8s)

Zabbix K8s deployment

Deploy mysql (using hostpath for data persistence)

1. Create pv

Vim mysql-pv.yamlkind: PersistentVolumeapiVersion: v1metadata: name: mysql-pv-volume labels: type: localspec: storageClassName: manual capacity: storage: 20Gi accessModes:-ReadWriteOnce hostPath: path: "/ mnt/data"-apiVersion: v1kind: PersistentVolumeClaimmetadata: name: mysql-pv-claimspec: storageClassName: manual accessModes:-ReadWriteOnce resources: requests: storage: 20Gi

two。 Create a mysql profile (configMap)

(guess you like it: the solution of zabbix monitoring pod error status appearing in K8s)

Vim mysql-config.yamlapiVersion: v1kind: ConfigMapmetadata: name: mysql-configdata: custom.cnf: | [mysqld] default_storage_engine=innodb skip_external_locking skip_host_cache skip_name_resolve default_authentication_plugin=mysql_native_password

3. Create a mysql password (secret)

[root@k8s-master-01 mysql] # echo-n password | base64cGFzc3dvcmQ=vim mysql-secret.yamlapiVersion: v1kind: Secretmetadata: name: mysql-user-pwddata: mysql-root-pwd: cGFzc3dvcmQ=

4. Create a mysql deployment file

Vim mysql-deploy.yamlapiVersion: v1kind: Servicemetadata: name: mysqlspec: type: NodePort ports:-port: 3306 nodePort: 30006 protocol: TCP targetPort: 3306 selector: app: mysql---apiVersion: apps/v1kind: Deploymentmetadata: name: mysqlspec: replicas: 1 selector: matchLabels: app: mysql strategy: type: Recreate template: metadata: labels: app: mysqlspec: containers:-image: mysql Name: mysql imagePullPolicy: IfNotPresent env:-name: MYSQL_ROOT_PASSWORD valueFrom: secretKeyRef: name: mysql-user-pwd key: mysql-root-pwd ports:-containerPort: 3306 name: mysql volumeMounts:-name: mysql-config mountPath: / etc/mysql/conf.d/ -name: mysql-persistent-storage mountPath: / var/lib/mysql-name: timezone mountPath: / etc/localtime volumes:-name: mysql-config configMap: name: mysql-config-name: timezone hostPath: path: / usr/share/zoneinfo/Asia/Shanghai-name: mysql-persistent-storage persistentVolumeClaim: claimName: mysql-pv-claim

5. Deploy mysql using the kubectl command and the above yaml file

[root@k8s-master-01 mysql] # kubectl apply-f. / configmap/mysql-config createdservice/mysql createddeployment.apps/mysql createdpersistentvolume/mysql-pv-volume createdpersistentvolumeclaim/mysql-pv-claim createdsecret/mysql-user-pwd created

Deploy zabbix-server

Vim zabbix-server-deploy.yamlapiVersion: v1kind: Servicemetadata: name: zabbixserverspec: type: NodePort ports:-port: 10051 nodePort: 30051 protocol: TCP targetPort: 10051 selector: app: zabbix-server---apiVersion: apps/v1kind: Deploymentmetadata: name: zabbix-serverspec: replicas: 1 selector: matchLabels: app: zabbix-server template: metadata: labels: app: zabbix-serverspec: containers:- Name: zabbix-server image: zabbix/zabbix-server-mysql imagePullPolicy: IfNotPresent ports:-containerPort: 10051 name: server protocol: TCP readinessProbe: tcpSocket: port: server initialDelaySeconds: 5 periodSeconds: 10 livenessProbe: tcpSocket: port: server InitialDelaySeconds: 15 periodSeconds: 20 env:-name: DB_SERVER_HOST value: "mysql"-name: MYSQL_USER value: "zabbix"-name: MYSQL_PASSWORD value: "zabbix"-name: MYSQL_DATABASE value: "zabbix"-name: ZBX_CACHESIZE value: "1024M"-name: ZBX_TRENDCACHESIZE value: "1024M"-name: ZBX_HISTORYCACHESIZE value: "2048M"-name: ZBX_HISTORYINDEXCACHESIZE value: "1024M"-name: ZBX_STARTTRAPPERS value: "5"-name: ZBX_STARTPREPROCESSORS value: "10"-name: ZBX_STARTDBSYNCERS value: "10"-name: DB_SERVER_PORT value: "3306"-name: zabbix-agent image: zabbix/zabbix-agent imagePullPolicy: Always ports:-containerPort: 10050 name: zabbix-agent env:-name: ZBX_HOSTNAME Value: "Zabbix server"-name: ZBX_SERVER_HOST value: "127.0.0.1"-name: ZBX_PASSIVE_ALLOW value: "true"-name: ZBX_STARTAGENTS value: "3"-name: ZBX_TIMEOUT value: "10" securityContext: privileged: true

Deploy zabbix-web

Vim zabbix-web.yamlapiVersion: v1kind: Servicemetadata: name: zabbix-webspec: type: NodePort ports:-port: 80 protocol: TCP nodePort: 30080 targetPort: 80 selector: app: zabbix-web---apiVersion: apps/v1kind: Deploymentmetadata: name: zabbix-webspec: replicas: 2 selector: matchLabels: app: zabbix-web template: metadata: labels: app: zabbix-webspec: containers:-image: Zabbix/zabbix-web-nginx-mysql name: zabbix-web imagePullPolicy: IfNotPresent ports:-containerPort: 80 name: web protocol: TCP env:-name: DB_SERVER_HOST value: "mysql"-name: ZBX_SERVER_HOST value: "zabbixserver"-name: MYSQL_USER value: "zabbix" -name: MYSQL_PASSWORD value: "zabbix"-name: TZ value: "Asia/Shanghai"

Deploy using the kubectl command and the above yaml file

[root@k8s-master-01 zabbix] # kubectl apply-f. / service/zabbixserver createddeployment.apps/zabbix-server createdservice/zabbix-web createddeployment.apps/zabbix-web created

View the status of deployed components

[root@k8s-master-01 zabbix] # kubectl get deploy,pod,svc,cm,secret,pv Pvc-o wideNAME READY UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTORdeployment.apps/mysql 1max 1 1 15m mysql mysql App=mysqldeployment.apps/zabbix-server 1/1 1 1 3m23s zabbix-server Zabbix-agent zabbix/zabbix-server-mysql Zabbix/zabbix-agent app=zabbix-serverdeployment.apps/zabbix-web 2/2 2 2 3m23s zabbix-web zabbix/zabbix-web-nginx-mysql app=zabbix-webNAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATESpod/mysql-ffcc44677-g2tlr 1 Running 0 15m 10.244.0.126 k8s-node-01 pod/zabbix-server-75cdd8865-rnxhx 2 Running 0 3m24s 10.244.0.127 k8s-node-01 pod/zabbix-web-856989975-8k45c 1 Running 0 3m23s 10.244.0.128 k8s-node-01 Pod/zabbix-web-856989975-hxdfl 1 Running 0 3m24s 10.244.1.118 k8s-node-02 NAME TYPE CLUSTER-IP EXTERNAL-IP PORT (S) AGE SELECTORservice/kubernetes ClusterIP 10.0.0.1 443/TCP 88d service/mysql NodePort 10.0.0.15 3306:30006/TCP 15m app=mysqlservice/zabbix-web NodePort 10.0.0.189 80:30080/TCP 3m23s app=zabbix-webservice/zabbixserver NodePort 10.0.0.234 10051:30051/TCP 3m23s app=zabbix-serverNAME DATA AGEconfigmap/mysql-config 1 15mNAME TYPE DATA AGEsecret/default-token-7qhlz kubernetes.io/service-account-token 3 88dsecret/mysql-user-pwd Opaque 1 15msecret/tls-secret kubernetes.io/tls 2 61dNAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE VOLUMEMODEpersistentvolume/mysql-pv-volume 20Gi RWO Retain Bound default/mysql-pv-claim manual 15m FilesystemNAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE VOLUMEMODEpersistentvolumeclaim/mysql-pv-claim Bound mysql-pv-volume 20Gi RWO manual 15m Filesystem

Access the test through a browser

Enter the ip:30080 of any node node in the browser address bar

Enter user name and password for access

Default user: Admin default password: zabbix

At this point, the zabbix-server test for K8s deployment is complete.

This article will not explain the deployment of the K8s basic environment for the time being, but will make a special explanation on the deployment of the K8s basic environment later.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 278

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report