Helm chart to install components for the Kubernetes cluster monitoring
Source
1
+
{{/* vim: set filetype=mustache: */}}
2
+
{{/*
3
+
Expand the name of the chart.
4
+
*/}}
5
+
{{- define "zabbix.name" -}}
6
+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7
+
{{- end }}
8
+
9
+
{{/*
10
+
Create a default fully qualified app name.
11
+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
12
+
If release name contains chart name it will be used as a full name.
13
+
*/}}
14
+
{{- define "zabbix.fullname" -}}
15
+
{{- if .Values.fullnameOverride -}}
16
+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
17
+
{{- else -}}
18
+
{{- $name := default .Chart.Name .Values.nameOverride -}}
19
+
{{- if contains $name .Release.Name -}}
20
+
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
21
+
{{- else -}}
22
+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
23
+
{{- end -}}
24
+
{{- end -}}
25
+
{{- end -}}
26
+
27
+
{{/* Fullname suffixed with proxy */}}
28
+
{{- define "zabbix.proxy.fullname" -}}
29
+
{{- printf "%s-proxy" (include "zabbix.fullname" .) -}}
30
+
{{- end }}
31
+
32
+
{{/* Fullname suffixed with proxy */}}
33
+
{{- define "zabbix.agent.fullname" -}}
34
+
{{- printf "%s-agent" (include "zabbix.fullname" .) -}}
35
+
{{- end }}
36
+
37
+
{{/*
38
+
Create chart name and version as used by the chart label.
39
+
*/}}
40
+
{{- define "zabbix.chart" -}}
41
+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
42
+
{{- end }}
43
+
44
+
{{/*
45
+
Get KubeVersion removing pre-release information.
46
+
*/}}
47
+
{{- define "zabbix.kubeVersion" -}}
48
+
{{- default .Capabilities.KubeVersion.Version (regexFind "v[0-9]+\\.[0-9]+\\.[0-9]+" .Capabilities.KubeVersion.Version) -}}
49
+
{{- end -}}
50
+
51
+
{{/*
52
+
Return the appropriate apiVersion for deployment.
53
+
*/}}
54
+
{{- define "zabbix.deployment.apiVersion" -}}
55
+
{{- print "apps/v1" -}}
56
+
{{- end -}}
57
+
{{/*
58
+
Return the appropriate apiVersion for daemonset.
59
+
*/}}
60
+
{{- define "zabbix.daemonset.apiVersion" -}}
61
+
{{- print "apps/v1" -}}
62
+
{{- end -}}
63
+
Return the appropriate apiVersion for rbac.
64
+
*/}}
65
+
{{- define "rbac.apiVersion" -}}
66
+
{{- if .Capabilities.APIVersions.Has "rbac.authorization.k8s.io/v1" }}
67
+
{{- print "rbac.authorization.k8s.io/v1" -}}
68
+
{{- else -}}
69
+
{{- print "rbac.authorization.k8s.io/v1beta1" -}}
70
+
{{- end -}}
71
+
{{- end -}}
72
+
73
+
{{/*
74
+
Return the appropriate apiVersion for ingress.
75
+
*/}}
76
+
{{- define "ingress.apiVersion" -}}
77
+
{{- if and (.Capabilities.APIVersions.Has "networking.k8s.io/v1") (semverCompare ">= 1.19.x" (include "zabbix.kubeVersion" .)) -}}
78
+
{{- print "networking.k8s.io/v1" -}}
79
+
{{- else if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1" -}}
80
+
{{- print "networking.k8s.io/v1beta1" -}}
81
+
{{- else -}}
82
+
{{- print "extensions/v1beta1" -}}
83
+
{{- end -}}
84
+
{{- end -}}
85
+
86
+
{{/*
87
+
Return if ingress supports ingressClassName.
88
+
*/}}
89
+
{{- define "ingress.supportsIngressClassName" -}}
90
+
{{- or (eq (include "ingress.isStable" .) "true") (and (eq (include "ingress.apiVersion" .) "networking.k8s.io/v1beta1") (semverCompare ">= 1.18.x" (include "zabbix.kubeVersion" .))) -}}
91
+
{{- end -}}
92
+
{{/*
93
+
Return if ingress supports pathType.
94
+
*/}}
95
+
{{- define "ingress.supportsPathType" -}}
96
+
{{- or (eq (include "ingress.isStable" .) "true") (and (eq (include "ingress.apiVersion" .) "networking.k8s.io/v1beta1") (semverCompare ">= 1.18.x" (include "zabbix.kubeVersion" .))) -}}
97
+
{{- end -}}
98
+
99
+
{{/*
100
+
Common labels
101
+
*/}}
102
+
{{- define "zabbix.labels" -}}
103
+
app.kubernetes.io/name: {{ include "zabbix.name" . }}
104
+
helm.sh/chart: {{ include "zabbix.chart" . }}
105
+
app.kubernetes.io/instance: {{ .Release.Name }}
106
+
{{- if .Chart.AppVersion }}
107
+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
108
+
{{- end }}
109
+
app.kubernetes.io/managed-by: {{ .Release.Service }}
110
+
{{- end -}}
111
+
112
+
{{/*
113
+
Create the name of the service account to use
114
+
*/}}
115
+
{{- define "zabbix.serviceAccountName" -}}
116
+
{{- if .Values.serviceAccount.create -}}
117
+
{{ default (include "zabbix.fullname" .) .Values.serviceAccount.name }}
118
+
{{- else -}}
119
+
{{ default "zabbix_default" .Values.serviceAccount.name }}
120
+
{{- end -}}
121
+
{{- end -}}
122
+
123
+
{{/*
124
+
Create the name of the service account for Agent
125
+
*/}}
126
+
{{- define "zabbix.agent.serviceAccountName" -}}
127
+
{{- if .Values.serviceAccount.create -}}
128
+
{{ default (printf "%s-agent" (include "zabbix.serviceAccountName" .)) .Values.zabbixAgent.serviceAccount.name }}
129
+
{{- else -}}
130
+
{{ default "zabbix_default" .Values.zabbixAgent.serviceAccount.name }}
131
+
{{- end -}}
132
+
{{- end -}}