github.com/verrazzano/verrazzano@v1.7.0/platform-operator/thirdparty/charts/prometheus-community/prometheus-pushgateway/templates/_helpers.tpl (about) 1 {{/* vim: set filetype=mustache: */}} 2 {{/* 3 Expand the name of the chart. 4 */}} 5 {{- define "prometheus-pushgateway.name" -}} 6 {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} 7 {{- end }} 8 9 {{/* 10 Namespace to set on the resources 11 */}} 12 {{- define "prometheus-pushgateway.namespace" -}} 13 {{- if .Values.namespaceOverride -}} 14 {{- .Values.namespaceOverride -}} 15 {{- else -}} 16 {{- .Release.Namespace -}} 17 {{- end -}} 18 {{- end -}} 19 20 {{/* 21 Create a default fully qualified app name. 22 We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). 23 If release name contains chart name it will be used as a full name. 24 */}} 25 {{- define "prometheus-pushgateway.fullname" -}} 26 {{- if .Values.fullnameOverride }} 27 {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} 28 {{- else }} 29 {{- $name := default .Chart.Name .Values.nameOverride }} 30 {{- if contains $name .Release.Name }} 31 {{- .Release.Name | trunc 63 | trimSuffix "-" }} 32 {{- else }} 33 {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} 34 {{- end }} 35 {{- end }} 36 {{- end }} 37 38 {{/* 39 Create chart name and version as used by the chart label. 40 */}} 41 {{- define "prometheus-pushgateway.chart" -}} 42 {{ printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} 43 {{- end }} 44 45 {{/* 46 Create the name of the service account to use 47 */}} 48 {{- define "prometheus-pushgateway.serviceAccountName" -}} 49 {{- if .Values.serviceAccount.create }} 50 {{- default (include "prometheus-pushgateway.fullname" .) .Values.serviceAccount.name }} 51 {{- else }} 52 {{- default "default" .Values.serviceAccount.name }} 53 {{- end }} 54 {{- end }} 55 56 {{/* 57 Create default labels 58 */}} 59 {{- define "prometheus-pushgateway.defaultLabels" -}} 60 helm.sh/chart: {{ include "prometheus-pushgateway.chart" . }} 61 {{ include "prometheus-pushgateway.selectorLabels" . }} 62 {{- if .Chart.AppVersion }} 63 app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} 64 {{- end }} 65 app.kubernetes.io/managed-by: {{ .Release.Service }} 66 {{- with .Values.podLabels }} 67 {{ toYaml . }} 68 {{- end }} 69 {{- end }} 70 71 {{/* 72 Selector labels 73 */}} 74 {{- define "prometheus-pushgateway.selectorLabels" -}} 75 app.kubernetes.io/name: {{ include "prometheus-pushgateway.name" . }} 76 app.kubernetes.io/instance: {{ .Release.Name }} 77 {{- end }} 78 79 {{/* 80 Return the appropriate apiVersion for networkpolicy. 81 */}} 82 {{- define "prometheus-pushgateway.networkPolicy.apiVersion" -}} 83 {{- if semverCompare ">=1.4-0, <1.7-0" .Capabilities.KubeVersion.GitVersion }} 84 {{- print "extensions/v1beta1" }} 85 {{- else if semverCompare "^1.7-0" .Capabilities.KubeVersion.GitVersion }} 86 {{- print "networking.k8s.io/v1" }} 87 {{- end }} 88 {{- end }} 89 90 {{/* 91 Define PDB apiVersion 92 */}} 93 {{- define "prometheus-pushgateway.pdb.apiVersion" -}} 94 {{- if $.Capabilities.APIVersions.Has "policy/v1/PodDisruptionBudget" }} 95 {{- print "policy/v1" }} 96 {{- else }} 97 {{- print "policy/v1beta1" }} 98 {{- end }} 99 {{- end }} 100 101 {{/* 102 Define Ingress apiVersion 103 */}} 104 {{- define "prometheus-pushgateway.ingress.apiVersion" -}} 105 {{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion }} 106 {{- print "networking.k8s.io/v1" }} 107 {{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion }} 108 {{- print "networking.k8s.io/v1beta1" }} 109 {{- else }} 110 {{- print "extensions/v1beta1" }} 111 {{- end }} 112 {{- end }} 113 114 {{/* 115 Returns pod spec 116 */}} 117 {{- define "prometheus-pushgateway.podSpec" -}} 118 serviceAccountName: {{ include "prometheus-pushgateway.serviceAccountName" . }} 119 {{- with .Values.priorityClassName }} 120 priorityClassName: {{ . | quote }} 121 {{- end }} 122 {{- with .Values.imagePullSecrets }} 123 imagePullSecrets: 124 {{- toYaml . | nindent 2 }} 125 {{- end }} 126 {{- with .Values.extraInitContainers }} 127 initContainers: 128 {{- toYaml . | nindent 2 }} 129 {{- end }} 130 containers: 131 {{- with .Values.extraContainers }} 132 {{- toYaml . | nindent 2 }} 133 {{- end }} 134 - name: pushgateway 135 image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" 136 imagePullPolicy: {{ .Values.image.pullPolicy }} 137 {{- with .Values.extraVars }} 138 env: 139 {{- toYaml . | nindent 6 }} 140 {{- end }} 141 {{- with .Values.extraArgs }} 142 args: 143 {{- toYaml . | nindent 6 }} 144 {{- end }} 145 ports: 146 - name: metrics 147 containerPort: 9091 148 protocol: TCP 149 {{- if .Values.liveness.enabled }} 150 livenessProbe: 151 {{- toYaml .Values.liveness.probe | nindent 6 }} 152 {{- end }} 153 {{- if .Values.readiness.enabled }} 154 readinessProbe: 155 {{- toYaml .Values.readiness.probe | nindent 6 }} 156 {{- end }} 157 {{- with .Values.resources }} 158 resources: 159 {{- toYaml . | nindent 6 }} 160 {{- end }} 161 {{- with .Values.containerSecurityContext }} 162 securityContext: 163 {{- toYaml . | nindent 6 }} 164 {{- end }} 165 volumeMounts: 166 - name: storage-volume 167 mountPath: "{{ .Values.persistentVolume.mountPath }}" 168 subPath: "{{ .Values.persistentVolume.subPath }}" 169 {{- with .Values.extraVolumeMounts }} 170 {{- toYaml . | nindent 6 }} 171 {{- end }} 172 {{- with .Values.nodeSelector }} 173 nodeSelector: 174 {{- toYaml . | nindent 2 }} 175 {{- end }} 176 {{- with .Values.tolerations }} 177 tolerations: 178 {{- toYaml . | nindent 2 }} 179 {{- end }} 180 {{- with .Values.affinity }} 181 affinity: 182 {{- toYaml . | nindent 2 }} 183 {{- end }} 184 {{- with .Values.topologySpreadConstraints }} 185 topologySpreadConstraints: 186 {{- toYaml . | nindent 2 }} 187 {{- end }} 188 {{- with .Values.securityContext }} 189 securityContext: 190 {{- toYaml . | nindent 2 }} 191 {{- end }} 192 volumes: 193 {{- $storageVolumeAsPVCTemplate := and .Values.runAsStatefulSet .Values.persistentVolume.enabled -}} 194 {{- if not $storageVolumeAsPVCTemplate }} 195 - name: storage-volume 196 {{- if .Values.persistentVolume.enabled }} 197 persistentVolumeClaim: 198 claimName: {{ if .Values.persistentVolume.existingClaim }}{{ .Values.persistentVolume.existingClaim }}{{- else }}{{ include "prometheus-pushgateway.fullname" . }}{{- end }} 199 {{- else }} 200 emptyDir: {} 201 {{- end }} 202 {{- end }} 203 {{- if .Values.extraVolumes }} 204 {{- toYaml .Values.extraVolumes | nindent 2 }} 205 {{- else if $storageVolumeAsPVCTemplate }} 206 [] 207 {{- end }} 208 {{- end }}