123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228 |
- {{/*
- Expand the name of the chart.
- */}}
- {{- define "opentelemetry-collector.name" -}}
- {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
- {{- end }}
- {{- define "opentelemetry-collector.lowercase_chartname" -}}
- {{- default .Chart.Name | lower }}
- {{- end }}
- {{/*
- Get component name
- */}}
- {{- define "opentelemetry-collector.component" -}}
- {{- if eq .Values.mode "deployment" -}}
- component: standalone-collector
- {{- end -}}
- {{- if eq .Values.mode "daemonset" -}}
- component: agent-collector
- {{- end -}}
- {{- if eq .Values.mode "statefulset" -}}
- component: statefulset-collector
- {{- end -}}
- {{- 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).
- If release name contains chart name it will be used as a full name.
- */}}
- {{- define "opentelemetry-collector.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 chart name and version as used by the chart label.
- */}}
- {{- define "opentelemetry-collector.chart" -}}
- {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
- {{- end }}
- {{/*
- Common labels
- */}}
- {{- define "opentelemetry-collector.labels" -}}
- helm.sh/chart: {{ include "opentelemetry-collector.chart" . }}
- {{ include "opentelemetry-collector.selectorLabels" . }}
- {{- if .Chart.AppVersion }}
- app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
- {{- end }}
- app.kubernetes.io/managed-by: {{ .Release.Service }}
- {{ include "opentelemetry-collector.additionalLabels" . }}
- {{- end }}
- {{/*
- Selector labels
- */}}
- {{- define "opentelemetry-collector.selectorLabels" -}}
- app.kubernetes.io/name: {{ include "opentelemetry-collector.name" . }}
- app.kubernetes.io/instance: {{ .Release.Name }}
- {{- end }}
- {{/*
- Create the name of the service account to use
- */}}
- {{- define "opentelemetry-collector.serviceAccountName" -}}
- {{- if .Values.serviceAccount.create }}
- {{- default (include "opentelemetry-collector.fullname" .) .Values.serviceAccount.name }}
- {{- else }}
- {{- default "default" .Values.serviceAccount.name }}
- {{- end }}
- {{- end }}
- {{/*
- Create the name of the clusterRole to use
- */}}
- {{- define "opentelemetry-collector.clusterRoleName" -}}
- {{- default (include "opentelemetry-collector.fullname" .) .Values.clusterRole.name }}
- {{- end }}
- {{/*
- Create the name of the clusterRoleBinding to use
- */}}
- {{- define "opentelemetry-collector.clusterRoleBindingName" -}}
- {{- default (include "opentelemetry-collector.fullname" .) .Values.clusterRole.clusterRoleBinding.name }}
- {{- end }}
- {{- define "opentelemetry-collector.podAnnotations" -}}
- {{- if .Values.podAnnotations }}
- {{- tpl (.Values.podAnnotations | toYaml) . }}
- {{- end }}
- {{- end }}
- {{- define "opentelemetry-collector.podLabels" -}}
- {{- if .Values.podLabels }}
- {{- tpl (.Values.podLabels | toYaml) . }}
- {{- end }}
- {{- end }}
- {{- define "opentelemetry-collector.additionalLabels" -}}
- {{- if .Values.additionalLabels }}
- {{- tpl (.Values.additionalLabels | toYaml) . }}
- {{- end }}
- {{- end }}
- {{/*
- Return the appropriate apiVersion for podDisruptionBudget.
- */}}
- {{- define "podDisruptionBudget.apiVersion" -}}
- {{- if and (.Capabilities.APIVersions.Has "policy/v1") (semverCompare ">= 1.21-0" .Capabilities.KubeVersion.Version) -}}
- {{- print "policy/v1" -}}
- {{- else -}}
- {{- print "policy/v1beta1" -}}
- {{- end -}}
- {{- end -}}
- {{/*
- Compute Service creation on mode
- */}}
- {{- define "opentelemetry-collector.serviceEnabled" }}
- {{- $serviceEnabled := true }}
- {{- if not (eq (toString .Values.service.enabled) "<nil>") }}
- {{- $serviceEnabled = .Values.service.enabled -}}
- {{- end }}
- {{- if and (eq .Values.mode "daemonset") (not .Values.service.enabled) }}
- {{- $serviceEnabled = false -}}
- {{- end }}
- {{- print $serviceEnabled }}
- {{- end -}}
- {{/*
- Compute InternalTrafficPolicy on Service creation
- */}}
- {{- define "opentelemetry-collector.serviceInternalTrafficPolicy" }}
- {{- if and (eq .Values.mode "daemonset") (eq .Values.service.enabled true) }}
- {{- print (.Values.service.internalTrafficPolicy | default "Local") -}}
- {{- else }}
- {{- print (.Values.service.internalTrafficPolicy | default "Cluster") -}}
- {{- end }}
- {{- end -}}
- {{/*
- Allow the release namespace to be overridden
- */}}
- {{- define "opentelemetry-collector.namespace" -}}
- {{- if .Values.namespaceOverride -}}
- {{- .Values.namespaceOverride -}}
- {{- else -}}
- {{- .Release.Namespace -}}
- {{- end -}}
- {{- end -}}
- {{/*
- This helper converts the input value of memory to Bytes.
- Input needs to be a valid value as supported by k8s memory resource field.
- */}}
- {{- define "opentelemetry-collector.convertMemToBytes" }}
- {{- $mem := lower . -}}
- {{- if hasSuffix "e" $mem -}}
- {{- $mem = mulf (trimSuffix "e" $mem | float64) 1e18 -}}
- {{- else if hasSuffix "ei" $mem -}}
- {{- $mem = mulf (trimSuffix "e" $mem | float64) 0x1p60 -}}
- {{- else if hasSuffix "p" $mem -}}
- {{- $mem = mulf (trimSuffix "p" $mem | float64) 1e15 -}}
- {{- else if hasSuffix "pi" $mem -}}
- {{- $mem = mulf (trimSuffix "pi" $mem | float64) 0x1p50 -}}
- {{- else if hasSuffix "t" $mem -}}
- {{- $mem = mulf (trimSuffix "t" $mem | float64) 1e12 -}}
- {{- else if hasSuffix "ti" $mem -}}
- {{- $mem = mulf (trimSuffix "ti" $mem | float64) 0x1p40 -}}
- {{- else if hasSuffix "g" $mem -}}
- {{- $mem = mulf (trimSuffix "g" $mem | float64) 1e9 -}}
- {{- else if hasSuffix "gi" $mem -}}
- {{- $mem = mulf (trimSuffix "gi" $mem | float64) 0x1p30 -}}
- {{- else if hasSuffix "m" $mem -}}
- {{- $mem = mulf (trimSuffix "m" $mem | float64) 1e6 -}}
- {{- else if hasSuffix "mi" $mem -}}
- {{- $mem = mulf (trimSuffix "mi" $mem | float64) 0x1p20 -}}
- {{- else if hasSuffix "k" $mem -}}
- {{- $mem = mulf (trimSuffix "k" $mem | float64) 1e3 -}}
- {{- else if hasSuffix "ki" $mem -}}
- {{- $mem = mulf (trimSuffix "ki" $mem | float64) 0x1p10 -}}
- {{- end }}
- {{- $mem }}
- {{- end }}
- {{- define "opentelemetry-collector.gomemlimit" }}
- {{- $memlimitBytes := include "opentelemetry-collector.convertMemToBytes" . | mulf 0.8 -}}
- {{- printf "%dMiB" (divf $memlimitBytes 0x1p20 | floor | int64) -}}
- {{- end }}
- {{/*
- Get HPA kind from mode.
- The capitalization is important for StatefulSet.
- */}}
- {{- define "opentelemetry-collector.hpaKind" -}}
- {{- if eq .Values.mode "deployment" -}}
- {{- print "Deployment" -}}
- {{- end -}}
- {{- if eq .Values.mode "statefulset" -}}
- {{- print "StatefulSet" -}}
- {{- end -}}
- {{- end }}
- {{/*
- Get ConfigMap name if existingName is defined, otherwise use default name for generated config.
- */}}
- {{- define "opentelemetry-collector.configName" -}}
- {{- if .Values.configMap.existingName -}}
- {{- .Values.configMap.existingName }}
- {{- else }}
- {{- printf "%s%s" (include "opentelemetry-collector.fullname" .) (.configmapSuffix) }}
- {{- end -}}
- {{- end }}
|