diff --git a/charts/zabbix-agent/Chart.yaml b/charts/zabbix-agent/Chart.yaml index 74742b3..a4f764b 100644 --- a/charts/zabbix-agent/Chart.yaml +++ b/charts/zabbix-agent/Chart.yaml @@ -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 diff --git a/charts/zabbix-agent/questions.yaml b/charts/zabbix-agent/questions.yaml new file mode 100644 index 0000000..543e1e7 --- /dev/null +++ b/charts/zabbix-agent/questions.yaml @@ -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 diff --git a/charts/zabbix-agent/templates/_helpers.tpl b/charts/zabbix-agent/templates/_helpers.tpl index 3d5d777..589da23 100644 --- a/charts/zabbix-agent/templates/_helpers.tpl +++ b/charts/zabbix-agent/templates/_helpers.tpl @@ -3,8 +3,8 @@ 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. @@ -12,21 +12,52 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this 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 }} diff --git a/charts/zabbix-agent/templates/daemonset.yaml b/charts/zabbix-agent/templates/daemonset.yaml index b963075..dbc9f8d 100644 --- a/charts/zabbix-agent/templates/daemonset.yaml +++ b/charts/zabbix-agent/templates/daemonset.yaml @@ -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: @@ -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 @@ -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: diff --git a/charts/zabbix-agent/values.yaml b/charts/zabbix-agent/values.yaml index abcebd6..587e58d 100644 --- a/charts/zabbix-agent/values.yaml +++ b/charts/zabbix-agent/values.yaml @@ -2,9 +2,12 @@ image: repository: zabbix/zabbix-agent - tag: ubuntu-4.0-latest pullPolicy: IfNotPresent +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + zabbix: debugLevel: 3 enableRemoteCommands: 0 @@ -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" @@ -44,4 +55,5 @@ tolerations: key: node-role.kubernetes.io/lb operator: Equal value: "true" + affinity: {}