github.com/verrazzano/verrazzano@v1.7.0/platform-operator/thirdparty/charts/prometheus-community/prometheus-node-exporter/templates/_helpers.tpl (about) 1 {{/* vim: set filetype=mustache: */}} 2 {{/* 3 Expand the name of the chart. 4 */}} 5 {{- define "prometheus-node-exporter.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 "prometheus-node-exporter.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 {{/* 28 Create chart name and version as used by the chart label. 29 */}} 30 {{- define "prometheus-node-exporter.chart" -}} 31 {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} 32 {{- end }} 33 34 {{/* 35 Common labels 36 */}} 37 {{- define "prometheus-node-exporter.labels" -}} 38 helm.sh/chart: {{ include "prometheus-node-exporter.chart" . }} 39 app.kubernetes.io/managed-by: {{ .Release.Service }} 40 app.kubernetes.io/component: metrics 41 app.kubernetes.io/part-of: {{ include "prometheus-node-exporter.name" . }} 42 {{ include "prometheus-node-exporter.selectorLabels" . }} 43 {{- with .Chart.AppVersion }} 44 app.kubernetes.io/version: {{ . | quote }} 45 {{- end }} 46 {{- with .Values.podLabels }} 47 {{ toYaml . }} 48 {{- end }} 49 {{- if .Values.releaseLabel }} 50 release: {{ .Release.Name }} 51 {{- end }} 52 {{- end }} 53 54 {{/* 55 Selector labels 56 */}} 57 {{- define "prometheus-node-exporter.selectorLabels" -}} 58 app.kubernetes.io/name: {{ include "prometheus-node-exporter.name" . }} 59 app.kubernetes.io/instance: {{ .Release.Name }} 60 {{- end }} 61 62 63 {{/* 64 Create the name of the service account to use 65 */}} 66 {{- define "prometheus-node-exporter.serviceAccountName" -}} 67 {{- if .Values.serviceAccount.create }} 68 {{- default (include "prometheus-node-exporter.fullname" .) .Values.serviceAccount.name }} 69 {{- else }} 70 {{- default "default" .Values.serviceAccount.name }} 71 {{- end }} 72 {{- end }} 73 74 {{/* 75 The image to use 76 */}} 77 {{- define "prometheus-node-exporter.image" -}} 78 {{- if .Values.image.sha }} 79 {{- fail "image.sha forbidden. Use image.digest instead" }} 80 {{- else if .Values.image.digest }} 81 {{- if .Values.global.imageRegistry }} 82 {{- printf "%s/%s:%s@%s" .Values.global.imageRegistry .Values.image.repository (default (printf "v%s" .Chart.AppVersion) .Values.image.tag) .Values.image.digest }} 83 {{- else }} 84 {{- printf "%s/%s:%s@%s" .Values.image.registry .Values.image.repository (default (printf "v%s" .Chart.AppVersion) .Values.image.tag) .Values.image.digest }} 85 {{- end }} 86 {{- else }} 87 {{- if .Values.global.imageRegistry }} 88 {{- printf "%s/%s:%s" .Values.global.imageRegistry .Values.image.repository (default (printf "v%s" .Chart.AppVersion) .Values.image.tag) }} 89 {{- else }} 90 {{- printf "%s/%s:%s" .Values.image.registry .Values.image.repository (default (printf "v%s" .Chart.AppVersion) .Values.image.tag) }} 91 {{- end }} 92 {{- end }} 93 {{- end }} 94 95 {{/* 96 Allow the release namespace to be overridden for multi-namespace deployments in combined charts 97 */}} 98 {{- define "prometheus-node-exporter.namespace" -}} 99 {{- if .Values.namespaceOverride }} 100 {{- .Values.namespaceOverride }} 101 {{- else }} 102 {{- .Release.Namespace }} 103 {{- end }} 104 {{- end }} 105 106 {{/* 107 Create the namespace name of the service monitor 108 */}} 109 {{- define "prometheus-node-exporter.monitor-namespace" -}} 110 {{- if .Values.namespaceOverride }} 111 {{- .Values.namespaceOverride }} 112 {{- else }} 113 {{- if .Values.prometheus.monitor.namespace }} 114 {{- .Values.prometheus.monitor.namespace }} 115 {{- else }} 116 {{- .Release.Namespace }} 117 {{- end }} 118 {{- end }} 119 {{- end }} 120 121 {{/* Sets default scrape limits for servicemonitor */}} 122 {{- define "servicemonitor.scrapeLimits" -}} 123 {{- with .sampleLimit }} 124 sampleLimit: {{ . }} 125 {{- end }} 126 {{- with .targetLimit }} 127 targetLimit: {{ . }} 128 {{- end }} 129 {{- with .labelLimit }} 130 labelLimit: {{ . }} 131 {{- end }} 132 {{- with .labelNameLengthLimit }} 133 labelNameLengthLimit: {{ . }} 134 {{- end }} 135 {{- with .labelValueLengthLimit }} 136 labelValueLengthLimit: {{ . }} 137 {{- end }} 138 {{- end }} 139 140 {{/* 141 Formats imagePullSecrets. Input is (dict "Values" .Values "imagePullSecrets" .{specific imagePullSecrets}) 142 */}} 143 {{- define "prometheus-node-exporter.imagePullSecrets" -}} 144 {{- range (concat .Values.global.imagePullSecrets .imagePullSecrets) }} 145 {{- if eq (typeOf .) "map[string]interface {}" }} 146 - {{ toYaml . | trim }} 147 {{- else }} 148 - name: {{ . }} 149 {{- end }} 150 {{- end }} 151 {{- end -}} 152 153 {{/* 154 Create the namespace name of the pod monitor 155 */}} 156 {{- define "prometheus-node-exporter.podmonitor-namespace" -}} 157 {{- if .Values.namespaceOverride }} 158 {{- .Values.namespaceOverride }} 159 {{- else }} 160 {{- if .Values.prometheus.podMonitor.namespace }} 161 {{- .Values.prometheus.podMonitor.namespace }} 162 {{- else }} 163 {{- .Release.Namespace }} 164 {{- end }} 165 {{- end }} 166 {{- end }} 167 168 {{/* Sets default scrape limits for podmonitor */}} 169 {{- define "podmonitor.scrapeLimits" -}} 170 {{- with .sampleLimit }} 171 sampleLimit: {{ . }} 172 {{- end }} 173 {{- with .targetLimit }} 174 targetLimit: {{ . }} 175 {{- end }} 176 {{- with .labelLimit }} 177 labelLimit: {{ . }} 178 {{- end }} 179 {{- with .labelNameLengthLimit }} 180 labelNameLengthLimit: {{ . }} 181 {{- end }} 182 {{- with .labelValueLengthLimit }} 183 labelValueLengthLimit: {{ . }} 184 {{- end }} 185 {{- end }}