123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287 |
- {{/* vim: set filetype=mustache: */}}
- {{/*
- Expand the name of the chart.
- */}}
- {{- define "prometheus.name" -}}
- {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
- {{- end -}}
- {{/*
- Create chart name and version as used by the chart label.
- */}}
- {{- define "prometheus.chart" -}}
- {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
- {{- end -}}
- {{/*
- Create unified labels for prometheus components
- */}}
- {{- define "prometheus.common.matchLabels" -}}
- app: {{ template "prometheus.name" . }}
- release: {{ .Release.Name }}
- {{- end -}}
- {{- define "prometheus.common.metaLabels" -}}
- chart: {{ template "prometheus.chart" . }}
- heritage: {{ .Release.Service }}
- {{- end -}}
- {{- define "prometheus.alertmanager.labels" -}}
- {{ include "prometheus.alertmanager.matchLabels" . }}
- {{ include "prometheus.common.metaLabels" . }}
- {{- end -}}
- {{- define "prometheus.alertmanager.matchLabels" -}}
- component: {{ .Values.alertmanager.name | quote }}
- {{ include "prometheus.common.matchLabels" . }}
- {{- end -}}
- {{- define "prometheus.nodeExporter.labels" -}}
- {{ include "prometheus.nodeExporter.matchLabels" . }}
- {{ include "prometheus.common.metaLabels" . }}
- {{- end -}}
- {{- define "prometheus.nodeExporter.matchLabels" -}}
- component: {{ .Values.nodeExporter.name | quote }}
- {{ include "prometheus.common.matchLabels" . }}
- {{- end -}}
- {{- define "prometheus.pushgateway.labels" -}}
- {{ include "prometheus.pushgateway.matchLabels" . }}
- {{ include "prometheus.common.metaLabels" . }}
- {{- end -}}
- {{- define "prometheus.pushgateway.matchLabels" -}}
- component: {{ .Values.pushgateway.name | quote }}
- {{ include "prometheus.common.matchLabels" . }}
- {{- end -}}
- {{- define "prometheus.server.labels" -}}
- {{ include "prometheus.server.matchLabels" . }}
- {{ include "prometheus.common.metaLabels" . }}
- {{- end -}}
- {{- define "prometheus.server.matchLabels" -}}
- component: {{ .Values.server.name | quote }}
- {{ include "prometheus.common.matchLabels" . }}
- {{- 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).
- */}}
- {{- define "prometheus.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 -}}
- {{/*
- Create a fully qualified alertmanager name.
- We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
- */}}
- {{- define "prometheus.alertmanager.fullname" -}}
- {{- if .Values.alertmanager.fullnameOverride -}}
- {{- .Values.alertmanager.fullnameOverride | trunc 63 | trimSuffix "-" -}}
- {{- else -}}
- {{- $name := default .Chart.Name .Values.nameOverride -}}
- {{- if contains $name .Release.Name -}}
- {{- printf "%s-%s" .Release.Name .Values.alertmanager.name | trunc 63 | trimSuffix "-" -}}
- {{- else -}}
- {{- printf "%s-%s-%s" .Release.Name $name .Values.alertmanager.name | trunc 63 | trimSuffix "-" -}}
- {{- end -}}
- {{- end -}}
- {{- end -}}
- {{/*
- Create a fully qualified node-exporter name.
- We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
- */}}
- {{- define "prometheus.nodeExporter.fullname" -}}
- {{- if .Values.nodeExporter.fullnameOverride -}}
- {{- .Values.nodeExporter.fullnameOverride | trunc 63 | trimSuffix "-" -}}
- {{- else -}}
- {{- $name := default .Chart.Name .Values.nameOverride -}}
- {{- if contains $name .Release.Name -}}
- {{- printf "%s-%s" .Release.Name .Values.nodeExporter.name | trunc 63 | trimSuffix "-" -}}
- {{- else -}}
- {{- printf "%s-%s-%s" .Release.Name $name .Values.nodeExporter.name | trunc 63 | trimSuffix "-" -}}
- {{- end -}}
- {{- end -}}
- {{- end -}}
- {{/*
- Create a fully qualified Prometheus server name.
- We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
- */}}
- {{- define "prometheus.server.fullname" -}}
- {{- if .Values.server.fullnameOverride -}}
- {{- .Values.server.fullnameOverride | trunc 63 | trimSuffix "-" -}}
- {{- else -}}
- {{- $name := default .Chart.Name .Values.nameOverride -}}
- {{- if contains $name .Release.Name -}}
- {{- printf "%s-%s" .Release.Name .Values.server.name | trunc 63 | trimSuffix "-" -}}
- {{- else -}}
- {{- printf "%s-%s-%s" .Release.Name $name .Values.server.name | trunc 63 | trimSuffix "-" -}}
- {{- end -}}
- {{- end -}}
- {{- end -}}
- {{/*
- Create a fully qualified pushgateway name.
- We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
- */}}
- {{- define "prometheus.pushgateway.fullname" -}}
- {{- if .Values.pushgateway.fullnameOverride -}}
- {{- .Values.pushgateway.fullnameOverride | trunc 63 | trimSuffix "-" -}}
- {{- else -}}
- {{- $name := default .Chart.Name .Values.nameOverride -}}
- {{- if contains $name .Release.Name -}}
- {{- printf "%s-%s" .Release.Name .Values.pushgateway.name | trunc 63 | trimSuffix "-" -}}
- {{- else -}}
- {{- printf "%s-%s-%s" .Release.Name $name .Values.pushgateway.name | trunc 63 | trimSuffix "-" -}}
- {{- end -}}
- {{- end -}}
- {{- end -}}
- {{/*
- Get KubeVersion removing pre-release information.
- */}}
- {{- define "prometheus.kubeVersion" -}}
- {{- default .Capabilities.KubeVersion.Version (regexFind "v[0-9]+\\.[0-9]+\\.[0-9]+" .Capabilities.KubeVersion.Version) -}}
- {{- end -}}
- {{/*
- Return the appropriate apiVersion for deployment.
- */}}
- {{- define "prometheus.deployment.apiVersion" -}}
- {{- print "apps/v1" -}}
- {{- end -}}
- {{/*
- Return the appropriate apiVersion for daemonset.
- */}}
- {{- define "prometheus.daemonset.apiVersion" -}}
- {{- print "apps/v1" -}}
- {{- end -}}
- {{/*
- Return the appropriate apiVersion for networkpolicy.
- */}}
- {{- define "prometheus.networkPolicy.apiVersion" -}}
- {{- print "networking.k8s.io/v1" -}}
- {{- end -}}
- {{/*
- Return the appropriate apiVersion for poddisruptionbudget.
- */}}
- {{- define "prometheus.podDisruptionBudget.apiVersion" -}}
- {{- if .Capabilities.APIVersions.Has "policy/v1" }}
- {{- print "policy/v1" -}}
- {{- else -}}
- {{- print "policy/v1beta1" -}}
- {{- end -}}
- {{- 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 "prometheus.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 is stable.
- */}}
- {{- define "ingress.isStable" -}}
- {{- eq (include "ingress.apiVersion" .) "networking.k8s.io/v1" -}}
- {{- 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 "prometheus.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 "prometheus.kubeVersion" .))) -}}
- {{- end -}}
- {{/*
- Create the name of the service account to use for the alertmanager component
- */}}
- {{- define "prometheus.serviceAccountName.alertmanager" -}}
- {{- if .Values.serviceAccounts.alertmanager.create -}}
- {{ default (include "prometheus.alertmanager.fullname" .) .Values.serviceAccounts.alertmanager.name }}
- {{- else -}}
- {{ default "default" .Values.serviceAccounts.alertmanager.name }}
- {{- end -}}
- {{- end -}}
- {{/*
- Create the name of the service account to use for the nodeExporter component
- */}}
- {{- define "prometheus.serviceAccountName.nodeExporter" -}}
- {{- if .Values.serviceAccounts.nodeExporter.create -}}
- {{ default (include "prometheus.nodeExporter.fullname" .) .Values.serviceAccounts.nodeExporter.name }}
- {{- else -}}
- {{ default "default" .Values.serviceAccounts.nodeExporter.name }}
- {{- end -}}
- {{- end -}}
- {{/*
- Create the name of the service account to use for the pushgateway component
- */}}
- {{- define "prometheus.serviceAccountName.pushgateway" -}}
- {{- if .Values.serviceAccounts.pushgateway.create -}}
- {{ default (include "prometheus.pushgateway.fullname" .) .Values.serviceAccounts.pushgateway.name }}
- {{- else -}}
- {{ default "default" .Values.serviceAccounts.pushgateway.name }}
- {{- end -}}
- {{- end -}}
- {{/*
- Create the name of the service account to use for the server component
- */}}
- {{- define "prometheus.serviceAccountName.server" -}}
- {{- if .Values.serviceAccounts.server.create -}}
- {{ default (include "prometheus.server.fullname" .) .Values.serviceAccounts.server.name }}
- {{- else -}}
- {{ default "default" .Values.serviceAccounts.server.name }}
- {{- end -}}
- {{- end -}}
- {{/*
- Define the prometheus.namespace template if set with forceNamespace or .Release.Namespace is set
- */}}
- {{- define "prometheus.namespace" -}}
- {{- if .Values.forceNamespace -}}
- {{ printf "namespace: %s" .Values.forceNamespace }}
- {{- else -}}
- {{ printf "namespace: %s" .Release.Namespace }}
- {{- end -}}
- {{- end -}}
|