{{/* vim: set filetype=mustache: */}} {{/* Expand the name of the chart. */}} {{- define "zabbix.name" -}} {{- 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.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 -}} {{/* Fullname suffixed with proxy */}} {{- define "zabbix.proxy.fullname" -}} {{- printf "%s-proxy" (include "zabbix.fullname" .) -}} {{- end }} {{/* Fullname suffixed with proxy */}} {{- define "zabbix.agent.fullname" -}} {{- printf "%s-agent" (include "zabbix.fullname" .) -}} {{- end }} {{/* Create chart name and version as used by the chart label. */}} {{- define "zabbix.chart" -}} {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} {{- end }} {{/* Get KubeVersion removing pre-release information. */}} {{- define "zabbix.kubeVersion" -}} {{- default .Capabilities.KubeVersion.Version (regexFind "v[0-9]+\\.[0-9]+\\.[0-9]+" .Capabilities.KubeVersion.Version) -}} {{- end -}} {{/* Return the appropriate apiVersion for deployment. */}} {{- define "zabbix.deployment.apiVersion" -}} {{- print "apps/v1" -}} {{- end -}} {{/* Return the appropriate apiVersion for daemonset. */}} {{- define "zabbix.daemonset.apiVersion" -}} {{- print "apps/v1" -}} {{- end -}} Return the appropriate apiVersion for rbac. */}} {{- define "rbac.apiVersion" -}} {{- if .Capabilities.APIVersions.Has "rbac.authorization.k8s.io/v1" }} {{- print "rbac.authorization.k8s.io/v1" -}} {{- else -}} {{- print "rbac.authorization.k8s.io/v1beta1" -}} {{- end -}} {{- end -}} {{/* Return the appropriate apiVersion for ingress. */}} {{- define "ingress.apiVersion" -}} {{- if and (.Capabilities.APIVersions.Has "networking.k8s.io/v1") (semverCompare ">= 1.19.x" (include "zabbix.kubeVersion" .)) -}} {{- print "networking.k8s.io/v1" -}} {{- else if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1" -}} {{- print "networking.k8s.io/v1beta1" -}} {{- else -}} {{- print "extensions/v1beta1" -}} {{- end -}} {{- end -}} {{/* Return if ingress supports ingressClassName. */}} {{- define "ingress.supportsIngressClassName" -}} {{- or (eq (include "ingress.isStable" .) "true") (and (eq (include "ingress.apiVersion" .) "networking.k8s.io/v1beta1") (semverCompare ">= 1.18.x" (include "zabbix.kubeVersion" .))) -}} {{- end -}} {{/* Return if ingress supports pathType. */}} {{- define "ingress.supportsPathType" -}} {{- or (eq (include "ingress.isStable" .) "true") (and (eq (include "ingress.apiVersion" .) "networking.k8s.io/v1beta1") (semverCompare ">= 1.18.x" (include "zabbix.kubeVersion" .))) -}} {{- end -}} {{/* Common labels */}} {{- define "zabbix.labels" -}} app.kubernetes.io/name: {{ include "zabbix.name" . }} helm.sh/chart: {{ include "zabbix.chart" . }} app.kubernetes.io/instance: {{ .Release.Name }} {{- if .Chart.AppVersion }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} app.kubernetes.io/managed-by: {{ .Release.Service }} {{- end -}} {{/* Create the name of the service account to use */}} {{- define "zabbix.serviceAccountName" -}} {{- if .Values.serviceAccount.create -}} {{ default (include "zabbix.fullname" .) .Values.serviceAccount.name }} {{- else -}} {{ default "zabbix_default" .Values.serviceAccount.name }} {{- end -}} {{- end -}} {{/* Create the name of the service account for Agent */}} {{- define "zabbix.agent.serviceAccountName" -}} {{- if .Values.serviceAccount.create -}} {{ default (printf "%s-agent" (include "zabbix.serviceAccountName" .)) .Values.zabbixAgent.serviceAccount.name }} {{- else -}} {{ default "zabbix_default" .Values.zabbixAgent.serviceAccount.name }} {{- end -}} {{- end -}}