mirror of
https://github.com/bitnami/charts.git
synced 2026-03-15 06:47:24 +08:00
251 lines
8.6 KiB
Smarty
251 lines
8.6 KiB
Smarty
{{/* vim: set filetype=mustache: */}}
|
|
{{/*
|
|
Expand the name of the chart.
|
|
*/}}
|
|
{{- define "kafka.name" -}}
|
|
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
|
|
{{- 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 "kafka.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 "kafka.chart" -}}
|
|
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Common labels
|
|
*/}}
|
|
{{- define "kafka.labels" -}}
|
|
app.kubernetes.io/name: {{ include "kafka.name" . }}
|
|
helm.sh/chart: {{ include "kafka.chart" . }}
|
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
|
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Labels to use on deploy.spec.selector.matchLabels and svc.spec.selector
|
|
*/}}
|
|
{{- define "kafka.matchLabels" -}}
|
|
app.kubernetes.io/name: {{ include "kafka.name" . }}
|
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Return the proper Kafka image name
|
|
*/}}
|
|
{{- define "kafka.image" -}}
|
|
{{- $registryName := .Values.image.registry -}}
|
|
{{- $repositoryName := .Values.image.repository -}}
|
|
{{- $tag := .Values.image.tag | toString -}}
|
|
{{/*
|
|
Helm 2.11 supports the assignment of a value to a variable defined in a different scope,
|
|
but Helm 2.9 and 2.10 doesn't support it, so we need to implement this if-else logic.
|
|
Also, we can't use a single if because lazy evaluation is not an option
|
|
*/}}
|
|
{{- if .Values.global }}
|
|
{{- if .Values.global.imageRegistry }}
|
|
{{- printf "%s/%s:%s" .Values.global.imageRegistry $repositoryName $tag -}}
|
|
{{- else -}}
|
|
{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
|
|
{{- end -}}
|
|
{{- else -}}
|
|
{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Return the proper Kafka exporter image name
|
|
*/}}
|
|
{{- define "kafka.metrics.kafka.image" -}}
|
|
{{- $registryName := .Values.metrics.kafka.image.registry -}}
|
|
{{- $repositoryName := .Values.metrics.kafka.image.repository -}}
|
|
{{- $tag := .Values.metrics.kafka.image.tag | toString -}}
|
|
{{/*
|
|
Helm 2.11 supports the assignment of a value to a variable defined in a different scope,
|
|
but Helm 2.9 and 2.10 doesn't support it, so we need to implement this if-else logic.
|
|
Also, we can't use a single if because lazy evaluation is not an option
|
|
*/}}
|
|
{{- if .Values.global }}
|
|
{{- if .Values.global.imageRegistry }}
|
|
{{- printf "%s/%s:%s" .Values.global.imageRegistry $repositoryName $tag -}}
|
|
{{- else -}}
|
|
{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
|
|
{{- end -}}
|
|
{{- else -}}
|
|
{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Return the proper JMX exporter image name
|
|
*/}}
|
|
{{- define "kafka.metrics.jmx.image" -}}
|
|
{{- $registryName := .Values.metrics.jmx.image.registry -}}
|
|
{{- $repositoryName := .Values.metrics.jmx.image.repository -}}
|
|
{{- $tag := .Values.metrics.jmx.image.tag | toString -}}
|
|
{{/*
|
|
Helm 2.11 supports the assignment of a value to a variable defined in a different scope,
|
|
but Helm 2.9 and 2.10 doesn't support it, so we need to implement this if-else logic.
|
|
Also, we can't use a single if because lazy evaluation is not an option
|
|
*/}}
|
|
{{- if .Values.global }}
|
|
{{- if .Values.global.imageRegistry }}
|
|
{{- printf "%s/%s:%s" .Values.global.imageRegistry $repositoryName $tag -}}
|
|
{{- else -}}
|
|
{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
|
|
{{- end -}}
|
|
{{- else -}}
|
|
{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Create a default fully qualified zookeeper name.
|
|
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
|
|
*/}}
|
|
{{- define "kafka.zookeeper.fullname" -}}
|
|
{{- if .Values.zookeeper.fullnameOverride -}}
|
|
{{- .Values.zookeeper.fullnameOverride | trunc 63 | trimSuffix "-" -}}
|
|
{{- else -}}
|
|
{{- $name := default "zookeeper" .Values.zookeeper.nameOverride -}}
|
|
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Return the proper Docker Image Registry Secret Names
|
|
*/}}
|
|
{{- define "kafka.imagePullSecrets" -}}
|
|
{{/*
|
|
Helm 2.11 supports the assignment of a value to a variable defined in a different scope,
|
|
but Helm 2.9 and 2.10 does not support it, so we need to implement this if-else logic.
|
|
Also, we can not use a single if because lazy evaluation is not an option
|
|
*/}}
|
|
{{- if .Values.global }}
|
|
{{- if .Values.global.imagePullSecrets }}
|
|
imagePullSecrets:
|
|
{{- range .Values.global.imagePullSecrets }}
|
|
- name: {{ . }}
|
|
{{- end }}
|
|
{{- else if or .Values.image.pullSecrets .Values.metrics.kafka.image.pullSecrets .Values.metrics.jmx.image.pullSecrets .Values.volumePermissions.image.pullSecrets }}
|
|
imagePullSecrets:
|
|
{{- range .Values.image.pullSecrets }}
|
|
- name: {{ . }}
|
|
{{- end }}
|
|
{{- range .Values.metrics.kafka.image.pullSecrets }}
|
|
- name: {{ . }}
|
|
{{- end }}
|
|
{{- range .Values.metrics.jmx.image.pullSecrets }}
|
|
- name: {{ . }}
|
|
{{- end }}
|
|
{{- range .Values.volumePermissions.image.pullSecrets }}
|
|
- name: {{ . }}
|
|
{{- end }}
|
|
{{- end -}}
|
|
{{- else if or .Values.image.pullSecrets .Values.metrics.kafka.image.pullSecrets .Values.metrics.jmx.image.pullSecrets .Values.volumePermissions.image.pullSecrets }}
|
|
imagePullSecrets:
|
|
{{- range .Values.image.pullSecrets }}
|
|
- name: {{ . }}
|
|
{{- end }}
|
|
{{- range .Values.metrics.kafka.image.pullSecrets }}
|
|
- name: {{ . }}
|
|
{{- end }}
|
|
{{- range .Values.metrics.jmx.image.pullSecrets }}
|
|
- name: {{ . }}
|
|
{{- end }}
|
|
{{- range .Values.volumePermissions.image.pullSecrets }}
|
|
- name: {{ . }}
|
|
{{- end }}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Return the proper image name (for the init container volume-permissions image)
|
|
*/}}
|
|
{{- define "kafka.volumePermissions.image" -}}
|
|
{{- $registryName := .Values.volumePermissions.image.registry -}}
|
|
{{- $repositoryName := .Values.volumePermissions.image.repository -}}
|
|
{{- $tag := .Values.volumePermissions.image.tag | toString -}}
|
|
{{/*
|
|
Helm 2.11 supports the assignment of a value to a variable defined in a different scope,
|
|
but Helm 2.9 and 2.10 doesn't support it, so we need to implement this if-else logic.
|
|
Also, we can't use a single if because lazy evaluation is not an option
|
|
*/}}
|
|
{{- if .Values.global }}
|
|
{{- if .Values.global.imageRegistry }}
|
|
{{- printf "%s/%s:%s" .Values.global.imageRegistry $repositoryName $tag -}}
|
|
{{- else -}}
|
|
{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
|
|
{{- end -}}
|
|
{{- else -}}
|
|
{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Return the proper Storage Class
|
|
*/}}
|
|
{{- define "kafka.storageClass" -}}
|
|
{{/*
|
|
Helm 2.11 supports the assignment of a value to a variable defined in a different scope,
|
|
but Helm 2.9 and 2.10 does not support it, so we need to implement this if-else logic.
|
|
*/}}
|
|
{{- if .Values.global -}}
|
|
{{- if .Values.global.storageClass -}}
|
|
{{- if (eq "-" .Values.global.storageClass) -}}
|
|
{{- printf "storageClassName: \"\"" -}}
|
|
{{- else }}
|
|
{{- printf "storageClassName: %s" .Values.global.storageClass -}}
|
|
{{- end -}}
|
|
{{- else -}}
|
|
{{- if .Values.persistence.storageClass -}}
|
|
{{- if (eq "-" .Values.persistence.storageClass) -}}
|
|
{{- printf "storageClassName: \"\"" -}}
|
|
{{- else }}
|
|
{{- printf "storageClassName: %s" .Values.persistence.storageClass -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- else -}}
|
|
{{- if .Values.persistence.storageClass -}}
|
|
{{- if (eq "-" .Values.persistence.storageClass) -}}
|
|
{{- printf "storageClassName: \"\"" -}}
|
|
{{- else }}
|
|
{{- printf "storageClassName: %s" .Values.persistence.storageClass -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Renders a value that contains template.
|
|
Usage:
|
|
{{ include "kafka.tplValue" ( dict "value" .Values.path.to.the.Value "context" $) }}
|
|
*/}}
|
|
{{- define "kafka.tplValue" -}}
|
|
{{- if typeIs "string" .value }}
|
|
{{- tpl .value .context }}
|
|
{{- else }}
|
|
{{- tpl (.value | toYaml) .context }}
|
|
{{- end }}
|
|
{{- end -}}
|