Install Zabbix On Kubernetes Using Helm

Zabbix is an open-source monitoring tool used to monitor servers, networks, applications, and services. It enables IT administrators to track performance, detect issues, and receive alerts in real-time. This is an installation of Zabbix monitoring in a Kubernetes cluster. This installation uses Helm and And ensure that the Ingress NGINX Controller is installed on the Kubernetes cluster.

First, install Helm on the Kubernetes cluster. Here’s a step-by-step guide from Helm Documentation.

After installing Helm, create a namespace for Zabbix using the following command:

$ sudo kubectl create ns zabbix

Next, create PV and PVC for Zabbix server and PostgreSQL.


$ sudo vi pv-pvc-zabbix-server.yml apiVersion: v1 kind: PersistentVolume metadata: name: pv-zabbix-server spec: capacity: storage: 10Gi accessModes: - ReadWriteOnce hostPath: path: "" persistentVolumeReclaimPolicy: Retain --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: pvc-zabbix-server namespace: zabbix spec: accessModes: - ReadWriteOnce resources: requests: storage: 10Gi $ sudo vi pv-pvc-postgresql.yml apiVersion: v1 kind: PersistentVolume metadata: name: pv-zabbix-postgresql spec: capacity: storage: 10Gi accessModes: - ReadWriteOnce hostPath: path: "" persistentVolumeReclaimPolicy: Retain --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: pvc-zabbix-postgresql namespace: zabbix spec: accessModes: - ReadWriteOnce resources: requests: storage: 10Gi

Then apply the PV and PVC for Zabbix server and PostgreSQL

$ sudo kubectl apply -f pv-pvc-zabbix-server.yml $ sudo kubectl apply -f pv-pvc-postgresql.yml

Then, create a values.yml file. The values.yml file is a configuration file used to set deployment parameters for Zabbix in Kubernetes, especially when using Helm for deployment. If this configuration is executed through Helm, the values.yml file will be used to customize the Zabbix installation according to requirements, particularly concerning persistent storage for the Zabbix server component and the PostgreSQL database.

$ sudo vi values.yml zabbixServer: persistence: enabled: true existingClaim: pvc-zabbix-server accessModes: - ReadWriteOnce size: 10Gi storageClass: "" postgresql: primary: persistence: enabled: true existingClaim: pvc-zabbix-postgresql accessModes: - ReadWriteOnce size: 10Gi storageClass: ""

Now, download the Zabbix repository from Helm and begin the installation of Zabbix.


$ sudo helm repo add bitnami https://charts.bitnami.com/bitnami $ sudo helm repo update $ sudo helm search repo zabbix $ sudo helm install zabbix zabbix/zabbix -n zabbix values.yml

Then, apply the patch to the Zabbix server and PostgreSQL. This patch aims to ensure that the data for Zabbix and PostgreSQL is stored persistently, so it remains intact even during restarts or pod migrations, which is crucial for maintaining the application's continuity.


for zabbix server: $ sudo kubectl patch deployment zabbix-zabbix-server -n zabbix --patch ' spec: template: spec: volumes: - name: zabbix-server-volume persistentVolumeClaim: claimName: pvc-zabbix-server containers: - name: zabbix-server volumeMounts: - name: zabbix-server-volume mountPath: /var/lib/zabbix ' for zabbix-postgresql: $ sudo kubectl patch statefulset zabbix-postgresql -n zabbix --patch ' spec: template: spec: volumes: - name: postgresql-volume persistentVolumeClaim: claimName: pvc-zabbix-postgresql containers: - name: postgresql volumeMounts: - name: postgresql-volume mountPath: /var/lib/postgresql/data '

Next, create a secret for SSL and configure the ingress as a load balancer.


$ sudo kubectl create secret tls zabbix-tls --namespace zabbix --key inetmede.key --cert inetmede.crt

secret project zabbix

$ vi ingress-zabbix.yml apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: zabbix-ingress namespace: zabbix annotations: nginx.ingress.kubernetes.io/ssl-passthrough: "true" nginx.ingress.kubernetes.io/secure-backends: "true" spec: ingressClassName: nginx tls: - hosts: - zabbix.inetmede.com secretName: zabbix-tls rules: - host: zabbix.inetmede.com http: paths: - path: / pathType: Prefix backend: service: name: zabbix-zabbix-web port: number: 80

Then apply the Zabbix ingress.


$ sudo kubectl apply -f ingress-zabbix.yml

After applying the Ingress, check the installed Zabbix pods, services and ingress.


$ sudo kubectl get pods,svc,ing -n zabbix -owide

status project zabbix

Access your Zabbix server from browser https://your-domain.com, default username Admin and password zabbix.

secret project zabbix