Skip to content

Commit

Permalink
Update zabbix-agent chart
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiorauber committed Oct 22, 2024
1 parent af1e62f commit 192e829
Show file tree
Hide file tree
Showing 5 changed files with 159 additions and 54 deletions.
9 changes: 5 additions & 4 deletions charts/zabbix-agent/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
apiVersion: v1
appVersion: 4.0
description: Zabbix monitoring agent for cluster-wide deployment
apiVersion: v2
name: zabbix-agent
version: 0.2.1
description: Zabbix monitoring agent for cluster-wide deployment
type: application
version: 0.3.0
appVersion: ubuntu-4.0-latest
icon: https://assets.zabbix.com/img/logo.svg
53 changes: 53 additions & 0 deletions charts/zabbix-agent/questions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
labels:
io.cattle.role: project
categories:
- Monitoring
questions:
- variable: zabbix.serverHost
default: ""
description: "IP Address of your Zabbix Server"
label: Server IP
type: string
required: true
group: Essential
- variable: zabbix.enableRemoteCommands
default: "0"
description: "Whether to allow remote commands from the Zabbix Server to the agent."
type: enum
options:
- "0"
- "1"
required: false
group: Essential
- variable: zabbix.debugLevel
default: 3
label: Agent Debug Level
description: "0-basic info, 1-critical info, 2-error info, 3-warnings, 4-debug, 5-extended debug"
type: int
min: 0
max: 5
group: Advanced
- variable: zabbix.refreshActiveChecks
default: 120
label: Refresh Active Checks
description: "Interval to refresh list of active checks (in seconds)."
type: int
min: 60
max: 3600
group: Advanced
- variable: zabbix.startAgents
default: 10
label: Start Agents
description: "Number of pre-allocated instances of zabbix_agentd for passive checks."
type: int
min: 0
max: 99
group: Advanced
- variable: zabbix.timeout
default: 30
label: "Timeout"
description: "Timeout when fetching values (in seconds). The agent will not abort user parameters execution when reaching this limit!"
type: int
min: 1
max: 255
group: Advanced
61 changes: 46 additions & 15 deletions charts/zabbix-agent/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,61 @@
Expand the name of the chart.
*/}}
{{- define "zabbix-agent.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "zabbix-agent.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "zabbix-agent.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "zabbix-agent.labels" -}}
helm.sh/chart: {{ include "zabbix-agent.chart" . }}
{{ include "zabbix-agent.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "zabbix-agent.selectorLabels" -}}
app.kubernetes.io/name: {{ include "zabbix-agent.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "zabbix-agent.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "zabbix-agent.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
52 changes: 30 additions & 22 deletions charts/zabbix-agent/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,35 @@ kind: DaemonSet
metadata:
name: {{ include "zabbix-agent.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "zabbix-agent.name" . }}
helm.sh/chart: {{ include "zabbix-agent.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}

{{- include "zabbix-agent.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
app.kubernetes.io/name: {{ include "zabbix-agent.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- include "zabbix-agent.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
app.kubernetes.io/name: {{ include "zabbix-agent.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- include "zabbix-agent.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
hostPID: true
hostIPC: true
hostNetwork: true
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- resources:
limits:
cpu: 100m
memory: 54Mi
requests:
cpu: 100m
memory: 54Mi
- name: {{ .Chart.Name }}
securityContext:
privileged: true
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: 10050
env:
Expand All @@ -51,8 +51,6 @@ spec:
value: "{{ .Values.zabbix.startAgents }}"
- name: ZBX_TIMEOUT
value: "{{ .Values.zabbix.timeout }}"
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
name: {{ .Chart.Name }}
volumeMounts:
- name: proc
mountPath: /data/proc
Expand All @@ -62,13 +60,23 @@ spec:
mountPath: /data/dev
- name: dockersock
mountPath: /var/run/docker.sock
{{- with .Values.tolerations }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
volumes:
- name: proc
hostPath:
hostPath:
path: /proc
- name: sys
hostPath:
Expand Down
38 changes: 25 additions & 13 deletions charts/zabbix-agent/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

image:
repository: zabbix/zabbix-agent
tag: ubuntu-4.0-latest
pullPolicy: IfNotPresent

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

zabbix:
debugLevel: 3
enableRemoteCommands: 0
Expand All @@ -15,21 +18,29 @@ zabbix:
timeout: 30
serverHost: localhost

resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
podAnnotations: {}


securityContext:
privileged: true
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000

resources:
limits:
cpu: 200m
memory: 100Mi
requests:
cpu: 50m
memory: 54Mi

nodeSelector: {}

tolerations:
tolerations:
- effect: NoSchedule
key: node-role.kubernetes.io/controlplane
value: "true"
Expand All @@ -44,4 +55,5 @@ tolerations:
key: node-role.kubernetes.io/lb
operator: Equal
value: "true"

affinity: {}

0 comments on commit 192e829

Please sign in to comment.