|
| 1 | +{{/* |
| 2 | +Expand the name of the chart. |
| 3 | +*/}} |
| 4 | +{{- define "helm.name" -}} |
| 5 | +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} |
| 6 | +{{- end }} |
| 7 | + |
| 8 | +{{/* |
| 9 | +Create a default fully qualified app name. |
| 10 | +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). |
| 11 | +If release name contains chart name it will be used as a full name. |
| 12 | +*/}} |
| 13 | +{{- define "helm.fullname" -}} |
| 14 | +{{- if .Values.fullnameOverride }} |
| 15 | +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} |
| 16 | +{{- else }} |
| 17 | +{{- $name := default .Chart.Name .Values.nameOverride }} |
| 18 | +{{- if contains $name .Release.Name }} |
| 19 | +{{- .Release.Name | trunc 63 | trimSuffix "-" }} |
| 20 | +{{- else }} |
| 21 | +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} |
| 22 | +{{- end }} |
| 23 | +{{- end }} |
| 24 | +{{- end }} |
| 25 | + |
| 26 | +{{/* |
| 27 | +Create chart name and version as used by the chart label. |
| 28 | +*/}} |
| 29 | +{{- define "helm.chart" -}} |
| 30 | +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} |
| 31 | +{{- end }} |
| 32 | + |
| 33 | +{{/* |
| 34 | +Common labels |
| 35 | +*/}} |
| 36 | +{{- define "helm.labels" -}} |
| 37 | +helm.sh/chart: {{ include "helm.chart" . }} |
| 38 | +{{ include "helm.selectorLabels" . }} |
| 39 | +{{- if .Chart.AppVersion }} |
| 40 | +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} |
| 41 | +{{- end }} |
| 42 | +app.kubernetes.io/managed-by: {{ .Release.Service }} |
| 43 | +{{- end }} |
| 44 | + |
| 45 | +{{/* |
| 46 | +Selector labels |
| 47 | +*/}} |
| 48 | +{{- define "helm.selectorLabels" -}} |
| 49 | +app.kubernetes.io/name: {{ include "helm.name" . }} |
| 50 | +app.kubernetes.io/instance: {{ .Release.Name }} |
| 51 | +{{- end }} |
| 52 | + |
| 53 | +{{/* |
| 54 | +Create the name of the service account to use |
| 55 | +*/}} |
| 56 | +{{- define "helm.serviceAccountName" -}} |
| 57 | +{{- if .Values.serviceAccount.create }} |
| 58 | +{{- default (include "helm.fullname" .) .Values.serviceAccount.name }} |
| 59 | +{{- else }} |
| 60 | +{{- default "default" .Values.serviceAccount.name }} |
| 61 | +{{- end }} |
| 62 | +{{- end }} |
| 63 | + |
| 64 | +{{- define "helm.exporter.ksmAddress" -}} |
| 65 | +{{- if .Values.settings.ksmAddress }} |
| 66 | +{{- .Values.settings.ksmAddress }} |
| 67 | +{{- else }} |
| 68 | +{{- printf "http://%s-%s:8080" .Release.Name "kube-state-metrics" }} |
| 69 | +{{- end }} |
| 70 | +{{- end }} |
| 71 | + |
| 72 | +{{- define "helm.exporter.dataRetentionTime" -}} |
| 73 | +{{- if .Values.settings.dataRetentionTime }} |
| 74 | +{{- .Values.settings.dataRetentionTime }} |
| 75 | +{{- else }} |
| 76 | +{{- "15m" }} |
| 77 | +{{- end }} |
| 78 | +{{- end }} |
| 79 | + |
| 80 | +{{- define "helm.exporter.remoteLogBatchSize" -}} |
| 81 | +{{- if .Values.settings.remoteLogBatchSize }} |
| 82 | +{{- .Values.settings.remoteLogBatchSize }} |
| 83 | +{{- else }} |
| 84 | +{{- "1000" }} |
| 85 | +{{- end }} |
| 86 | +{{- end }} |
| 87 | + |
| 88 | +{{- define "helm.exporter.remoteLogBatchInterval" -}} |
| 89 | +{{- if .Values.settings.remoteLogBatchInterval }} |
| 90 | +{{- .Values.settings.remoteLogBatchInterval }} |
| 91 | +{{- else }} |
| 92 | +{{- "15s" }} |
| 93 | +{{- end }} |
| 94 | +{{- end }} |
| 95 | + |
| 96 | +{{/* |
| 97 | +For testing purposes, in prod we want to get the actual cluster's UID |
| 98 | +*/}} |
| 99 | +{{- define "helm.exporter.clusterUID" -}} |
| 100 | +{{- if .Values.settings.clusterUID }} |
| 101 | +{{- .Values.settings.clusterUID }} |
| 102 | +{{- else }} |
| 103 | +{{- "" }} |
| 104 | +{{- end }} |
| 105 | +{{- end }} |
| 106 | +
|
| 107 | +{{- define "datadogAD.v1annotations" -}} |
| 108 | +ad.datadoghq.com/{{ .containerName }}.check_names: '["openmetrics"]' |
| 109 | +ad.datadoghq.com/{{ .containerName }}.init_configs: '[{}]' |
| 110 | +ad.datadoghq.com/{{ .containerName }}.instances: | |
| 111 | + [ |
| 112 | + { |
| 113 | + "openmetrics_endpoint": "http://%%host%%:{{ .config.port }}{{ .config.endpoint }}", |
| 114 | + "namespace": "{{ .config.namespace }}", |
| 115 | + {{- if .config.metrics }} |
| 116 | + "metrics": [ |
| 117 | + {{- range $index, $metric := .config.metrics }} |
| 118 | + {{- if $index }},{{ end }} |
| 119 | + {{- if .rename }} |
| 120 | + { |
| 121 | + "{{ .name }}": "{{ .rename }}" |
| 122 | + } |
| 123 | + {{- else }} |
| 124 | + "{{ .name }}" |
| 125 | + {{- end }} |
| 126 | + {{- end }} |
| 127 | + ] |
| 128 | + {{- end }} |
| 129 | + {{- if .config.options }} |
| 130 | + {{- range $key, $value := .config.options }} |
| 131 | + ,"{{ $key }}": {{ $value }} |
| 132 | + {{- end }} |
| 133 | + {{- end }} |
| 134 | + } |
| 135 | + ] |
| 136 | +{{- end }} |
| 137 | + |
| 138 | +{{- define "datadogAD.v2annotations" -}} |
| 139 | +ad.datadoghq.com/{{ .containerName }}.checks: | |
| 140 | + { |
| 141 | + "openmetrics": { |
| 142 | + "init_config": {}, |
| 143 | + "instances": [ |
| 144 | + { |
| 145 | + "openmetrics_endpoint": "http://%%host%%:{{ .config.port }}{{ .config.endpoint }}", |
| 146 | + "namespace": "{{ .config.namespace }}", |
| 147 | + {{- if .config.metrics }} |
| 148 | + "metrics": { |
| 149 | + {{- range $index, $metric := .config.metrics }} |
| 150 | + {{- if $index }},{{ end }} |
| 151 | + {{- if .rename }} |
| 152 | + "{{ .name }}": "{{ .rename }}" |
| 153 | + {{- else }} |
| 154 | + "{{ .name }}": "{{ .name }}" |
| 155 | + {{- end }} |
| 156 | + {{- end }} |
| 157 | + } |
| 158 | + {{- end }} |
| 159 | + {{- if .config.options }} |
| 160 | + {{- range $key, $value := .config.options }} |
| 161 | + ,"{{ $key }}": {{ $value }} |
| 162 | + {{- end }} |
| 163 | + {{- end }} |
| 164 | + } |
| 165 | + ] |
| 166 | + } |
| 167 | + } |
| 168 | +{{- end }} |
0 commit comments