1 {{/* vim: set filetype=mustache: */}}
3 Expand the name of the chart.
5 {{- define "prometheus.name" -}}
6 {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
10 Create chart name and version as used by the chart label.
12 {{- define "prometheus.chart" -}}
13 {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
17 Create unified labels for prometheus components
19 {{- define "prometheus.common.matchLabels" -}}
20 app: {{ template "prometheus.name" . }}
21 release: {{ .Release.Name }}
24 {{- define "prometheus.common.metaLabels" -}}
25 chart: {{ template "prometheus.chart" . }}
26 heritage: {{ .Release.Service }}
29 {{- define "prometheus.alertmanager.labels" -}}
30 {{ include "prometheus.alertmanager.matchLabels" . }}
31 {{ include "prometheus.common.metaLabels" . }}
34 {{- define "prometheus.alertmanager.matchLabels" -}}
35 component: {{ .Values.alertmanager.name | quote }}
36 {{ include "prometheus.common.matchLabels" . }}
39 {{- define "prometheus.nodeExporter.labels" -}}
40 {{ include "prometheus.nodeExporter.matchLabels" . }}
41 {{ include "prometheus.common.metaLabels" . }}
44 {{- define "prometheus.nodeExporter.matchLabels" -}}
45 component: {{ .Values.nodeExporter.name | quote }}
46 {{ include "prometheus.common.matchLabels" . }}
49 {{- define "prometheus.pushgateway.labels" -}}
50 {{ include "prometheus.pushgateway.matchLabels" . }}
51 {{ include "prometheus.common.metaLabels" . }}
54 {{- define "prometheus.pushgateway.matchLabels" -}}
55 component: {{ .Values.pushgateway.name | quote }}
56 {{ include "prometheus.common.matchLabels" . }}
59 {{- define "prometheus.server.labels" -}}
60 {{ include "prometheus.server.matchLabels" . }}
61 {{ include "prometheus.common.metaLabels" . }}
64 {{- define "prometheus.server.matchLabels" -}}
65 component: {{ .Values.server.name | quote }}
66 {{ include "prometheus.common.matchLabels" . }}
70 Create a default fully qualified app name.
71 We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
73 {{- define "prometheus.fullname" -}}
74 {{- if .Values.fullnameOverride -}}
75 {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
77 {{- $name := default .Chart.Name .Values.nameOverride -}}
78 {{- if contains $name .Release.Name -}}
79 {{- .Release.Name | trunc 63 | trimSuffix "-" -}}
81 {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
87 Create a fully qualified alertmanager name.
88 We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
91 {{- define "prometheus.alertmanager.fullname" -}}
92 {{- if .Values.alertmanager.fullnameOverride -}}
93 {{- .Values.alertmanager.fullnameOverride | trunc 63 | trimSuffix "-" -}}
95 {{- $name := default .Chart.Name .Values.nameOverride -}}
96 {{- if contains $name .Release.Name -}}
97 {{- printf "%s-%s" .Release.Name .Values.alertmanager.name | trunc 63 | trimSuffix "-" -}}
99 {{- printf "%s-%s-%s" .Release.Name $name .Values.alertmanager.name | trunc 63 | trimSuffix "-" -}}
105 Create a fully qualified node-exporter name.
106 We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
108 {{- define "prometheus.nodeExporter.fullname" -}}
109 {{- if .Values.nodeExporter.fullnameOverride -}}
110 {{- .Values.nodeExporter.fullnameOverride | trunc 63 | trimSuffix "-" -}}
112 {{- $name := default .Chart.Name .Values.nameOverride -}}
113 {{- if contains $name .Release.Name -}}
114 {{- printf "%s-%s" .Release.Name .Values.nodeExporter.name | trunc 63 | trimSuffix "-" -}}
116 {{- printf "%s-%s-%s" .Release.Name $name .Values.nodeExporter.name | trunc 63 | trimSuffix "-" -}}
122 Create a fully qualified Prometheus server name.
123 We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
125 {{- define "prometheus.server.fullname" -}}
126 {{- if .Values.server.fullnameOverride -}}
127 {{- .Values.server.fullnameOverride | trunc 63 | trimSuffix "-" -}}
129 {{- $name := default .Chart.Name .Values.nameOverride -}}
130 {{- if contains $name .Release.Name -}}
131 {{- printf "%s-%s" .Release.Name .Values.server.name | trunc 63 | trimSuffix "-" -}}
133 {{- printf "%s-%s-%s" .Release.Name $name .Values.server.name | trunc 63 | trimSuffix "-" -}}
139 Create a fully qualified pushgateway name.
140 We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
142 {{- define "prometheus.pushgateway.fullname" -}}
143 {{- if .Values.pushgateway.fullnameOverride -}}
144 {{- .Values.pushgateway.fullnameOverride | trunc 63 | trimSuffix "-" -}}
146 {{- $name := default .Chart.Name .Values.nameOverride -}}
147 {{- if contains $name .Release.Name -}}
148 {{- printf "%s-%s" .Release.Name .Values.pushgateway.name | trunc 63 | trimSuffix "-" -}}
150 {{- printf "%s-%s-%s" .Release.Name $name .Values.pushgateway.name | trunc 63 | trimSuffix "-" -}}
156 Return the appropriate apiVersion for deployment.
158 {{- define "prometheus.deployment.apiVersion" -}}
159 {{- if semverCompare "<1.9-0" .Capabilities.KubeVersion.GitVersion -}}
160 {{- print "extensions/v1beta1" -}}
161 {{- else if semverCompare "^1.9-0" .Capabilities.KubeVersion.GitVersion -}}
162 {{- print "apps/v1" -}}
166 Return the appropriate apiVersion for daemonset.
168 {{- define "prometheus.daemonset.apiVersion" -}}
169 {{- if semverCompare "<1.9-0" .Capabilities.KubeVersion.GitVersion -}}
170 {{- print "extensions/v1beta1" -}}
171 {{- else if semverCompare "^1.9-0" .Capabilities.KubeVersion.GitVersion -}}
172 {{- print "apps/v1" -}}
176 Return the appropriate apiVersion for networkpolicy.
178 {{- define "prometheus.networkPolicy.apiVersion" -}}
179 {{- if semverCompare ">=1.4-0, <1.7-0" .Capabilities.KubeVersion.GitVersion -}}
180 {{- print "extensions/v1beta1" -}}
181 {{- else if semverCompare "^1.7-0" .Capabilities.KubeVersion.GitVersion -}}
182 {{- print "networking.k8s.io/v1" -}}
186 Return the appropriate apiVersion for podsecuritypolicy.
188 {{- define "prometheus.podSecurityPolicy.apiVersion" -}}
189 {{- if semverCompare ">=1.3-0, <1.10-0" .Capabilities.KubeVersion.GitVersion -}}
190 {{- print "extensions/v1beta1" -}}
191 {{- else if semverCompare "^1.10-0" .Capabilities.KubeVersion.GitVersion -}}
192 {{- print "policy/v1beta1" -}}
197 Create the name of the service account to use for the alertmanager component
199 {{- define "prometheus.serviceAccountName.alertmanager" -}}
200 {{- if .Values.serviceAccounts.alertmanager.create -}}
201 {{ default (include "prometheus.alertmanager.fullname" .) .Values.serviceAccounts.alertmanager.name }}
203 {{ default "default" .Values.serviceAccounts.alertmanager.name }}
208 Create the name of the service account to use for the nodeExporter component
210 {{- define "prometheus.serviceAccountName.nodeExporter" -}}
211 {{- if .Values.serviceAccounts.nodeExporter.create -}}
212 {{ default (include "prometheus.nodeExporter.fullname" .) .Values.serviceAccounts.nodeExporter.name }}
214 {{ default "default" .Values.serviceAccounts.nodeExporter.name }}
219 Create the name of the service account to use for the pushgateway component
221 {{- define "prometheus.serviceAccountName.pushgateway" -}}
222 {{- if .Values.serviceAccounts.pushgateway.create -}}
223 {{ default (include "prometheus.pushgateway.fullname" .) .Values.serviceAccounts.pushgateway.name }}
225 {{ default "default" .Values.serviceAccounts.pushgateway.name }}
230 Create the name of the service account to use for the server component
232 {{- define "prometheus.serviceAccountName.server" -}}
233 {{- if .Values.serviceAccounts.server.create -}}
234 {{ default (include "prometheus.server.fullname" .) .Values.serviceAccounts.server.name }}
236 {{ default "default" .Values.serviceAccounts.server.name }}
241 Define the prometheus.namespace template if set with forceNamespace or .Release.Namespace is set
243 {{- define "prometheus.namespace" -}}
244 {{- if .Values.forceNamespace -}}
245 {{ printf "namespace: %s" .Values.forceNamespace }}
247 {{ printf "namespace: %s" .Release.Namespace }}