2021-04-22 09:59:18 +00:00
|
|
|
{{/*
|
|
|
|
Expand the name of the chart.
|
|
|
|
*/}}
|
|
|
|
{{- define "nats.name" -}}
|
|
|
|
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
|
|
|
|
{{- end -}}
|
|
|
|
|
|
|
|
|
|
|
|
{{- define "nats.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 "nats.chart" -}}
|
|
|
|
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
|
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
{{/*
|
|
|
|
Common labels
|
|
|
|
*/}}
|
|
|
|
{{- define "nats.labels" -}}
|
|
|
|
helm.sh/chart: {{ include "nats.chart" . }}
|
2021-07-22 20:15:12 +00:00
|
|
|
{{- range $name, $value := .Values.commonLabels }}
|
|
|
|
{{ $name }}: {{ $value }}
|
|
|
|
{{- end }}
|
2021-04-22 09:59:18 +00:00
|
|
|
{{ include "nats.selectorLabels" . }}
|
|
|
|
{{- if .Chart.AppVersion }}
|
|
|
|
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
|
|
|
|
{{- end }}
|
|
|
|
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
{{/*
|
|
|
|
Selector labels
|
|
|
|
*/}}
|
|
|
|
{{- define "nats.selectorLabels" -}}
|
|
|
|
app.kubernetes.io/name: {{ include "nats.name" . }}
|
|
|
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
|
|
|
|
{{/*
|
|
|
|
Return the proper NATS image name
|
|
|
|
*/}}
|
|
|
|
{{- define "nats.clusterAdvertise" -}}
|
2021-07-22 20:15:12 +00:00
|
|
|
{{- printf "$(POD_NAME).%s.$(POD_NAMESPACE).svc.%s." (include "nats.fullname" . ) $.Values.k8sClusterDomain }}
|
2021-04-22 09:59:18 +00:00
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
{{/*
|
|
|
|
Return the NATS cluster routes.
|
|
|
|
*/}}
|
|
|
|
{{- define "nats.clusterRoutes" -}}
|
2021-07-22 20:15:12 +00:00
|
|
|
{{- $name := (include "nats.fullname" . ) -}}
|
2021-04-22 09:59:18 +00:00
|
|
|
{{- range $i, $e := until (.Values.cluster.replicas | int) -}}
|
2021-07-22 20:15:12 +00:00
|
|
|
{{- printf "nats://%s-%d.%s.%s.svc.%s.:6222," $name $i $name $.Release.Namespace $.Values.k8sClusterDomain -}}
|
2021-04-22 09:59:18 +00:00
|
|
|
{{- end -}}
|
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
|
|
|
|
{{- define "nats.tlsConfig" -}}
|
|
|
|
tls {
|
|
|
|
{{- if .cert }}
|
|
|
|
cert_file: {{ .secretPath }}/{{ .secret.name }}/{{ .cert }}
|
|
|
|
{{- end }}
|
|
|
|
{{- if .key }}
|
|
|
|
key_file: {{ .secretPath }}/{{ .secret.name }}/{{ .key }}
|
|
|
|
{{- end }}
|
|
|
|
{{- if .ca }}
|
|
|
|
ca_file: {{ .secretPath }}/{{ .secret.name }}/{{ .ca }}
|
|
|
|
{{- end }}
|
|
|
|
{{- if .insecure }}
|
|
|
|
insecure: {{ .insecure }}
|
|
|
|
{{- end }}
|
|
|
|
{{- if .verify }}
|
|
|
|
verify: {{ .verify }}
|
|
|
|
{{- end }}
|
|
|
|
{{- if .verifyAndMap }}
|
|
|
|
verify_and_map: {{ .verifyAndMap }}
|
|
|
|
{{- end }}
|
|
|
|
{{- if .curvePreferences }}
|
|
|
|
curve_preferences: {{ .curvePreferences }}
|
|
|
|
{{- end }}
|
|
|
|
{{- if .timeout }}
|
|
|
|
timeout: {{ .timeout }}
|
|
|
|
{{- end }}
|
|
|
|
}
|
2021-07-22 20:15:12 +00:00
|
|
|
{{- end }}
|