Skip to content

Commit

Permalink
fix kafka subchart nameoverride
Browse files Browse the repository at this point in the history
Signed-off-by: Dirk Van Haerenborgh <[email protected]>
  • Loading branch information
vhdirk committed Dec 12, 2022
1 parent 0df4918 commit 3380233
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 37 deletions.
44 changes: 22 additions & 22 deletions charts/hono/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
Expand the name of the chart.
*/}}
{{- define "hono.name" -}}
{{- $nameOverride := .Values.global.hono.nameOverride -}}
{{- empty $nameOverride | ternary .Chart.Name (tpl $nameOverride $) | trunc 63 | trimSuffix "-" -}}
{{- $nameOverride := .dot.Values.nameOverride -}}
{{- empty $nameOverride | ternary .dot.Chart.Name (tpl $nameOverride .dot ) | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Expand All @@ -26,16 +26,16 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
If release name contains chart name it will be used as a full name.
*/}}
{{- define "hono.fullname" -}}
{{- $fullnameOverride := .Values.global.hono.fullnameOverride -}}
{{- $fullnameOverride := .dot.Values.fullnameOverride -}}
{{- if $fullnameOverride -}}
{{- (tpl $fullnameOverride $) | trunc 63 | trimSuffix "-" -}}
{{- (tpl $fullnameOverride .dot) | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $nameOverride := .Values.global.hono.nameOverride -}}
{{- $name := empty $nameOverride | ternary .Chart.Name (tpl $nameOverride $) -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- $nameOverride := .dot.Values.nameOverride -}}
{{- $name := empty $nameOverride | ternary .dot.Chart.Name (tpl $nameOverride .dot) -}}
{{- if contains $name .dot.Release.Name -}}
{{- .dot.Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- printf "%s-%s" .dot.Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}
Expand All @@ -44,7 +44,7 @@ If release name contains chart name it will be used as a full name.
Create chart name and version as used by the chart label.
*/}}
{{- define "hono.chart" }}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- printf "%s-%s" .dot.Chart.Name .dot.Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Expand Down Expand Up @@ -91,9 +91,9 @@ Add standard labels for resources as recommended by Helm best practices.
{{- define "hono.std.labels" -}}
app.kubernetes.io/name: {{ include "hono.name" . | quote }}
helm.sh/chart: {{ include "hono.chart" . | quote }}
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
app.kubernetes.io/instance: {{ .Release.Name | quote }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
app.kubernetes.io/managed-by: {{ .dot.Release.Service | quote }}
app.kubernetes.io/instance: {{ .dot.Release.Name | quote }}
app.kubernetes.io/version: {{ .dot.Chart.AppVersion | quote }}
{{- end }}
Expand All @@ -105,11 +105,11 @@ The scope passed in is expected to be a dict with keys
- "component": the value to use for the "app.kubernetes.io/component" label
*/}}
{{- define "hono.metadata" -}}
name: {{ printf "%s-%s" (include "hono.fullname" .dot ) .name | quote }}
name: {{ printf "%s-%s" (include "hono.fullname" . ) .name | quote }}
namespace: {{ .dot.Release.Namespace | quote }}
labels:
app.kubernetes.io/name: {{ include "hono.name" .dot | quote }}
helm.sh/chart: {{ include "hono.chart" .dot | quote }}
app.kubernetes.io/name: {{ include "hono.name" . | quote }}
helm.sh/chart: {{ include "hono.chart" . | quote }}
app.kubernetes.io/managed-by: {{ .dot.Release.Service | quote }}
app.kubernetes.io/instance: {{ .dot.Release.Name | quote }}
app.kubernetes.io/version: {{ .dot.Chart.AppVersion | quote }}
Expand All @@ -125,7 +125,7 @@ The scope passed in is expected to be a dict with keys
- "component": the value of the "app.kubernetes.io/component" label to match
*/}}
{{- define "hono.matchLabels" -}}
app.kubernetes.io/name: {{ include "hono.name" .dot | quote }}
app.kubernetes.io/name: {{ include "hono.name" . | quote }}
app.kubernetes.io/instance: {{ .dot.Release.Name | quote }}
app.kubernetes.io/component: {{ .component | quote }}
{{- end }}
Expand Down Expand Up @@ -266,7 +266,7 @@ The scope passed in is expected to be a dict with keys
kafka:
{{- if .dot.Values.kafkaMessagingClusterExample.enabled }}
commonClientConfig:
{{- $bootstrapServers := printf "%[1]s-%[2]s-0.%[1]s-%[2]s-headless:%d" ( include "hono.fullname" .dot ) .dot.Values.kafka.nameOverride ( .dot.Values.kafka.service.ports.client | int ) }}
{{- $bootstrapServers := printf "%[1]s-%[2]s-0.%[1]s-%[2]s-headless:%d" ( include "hono.fullname" . ) .dot.Values.kafka.nameOverride ( .dot.Values.kafka.service.ports.client | int ) }}
bootstrap.servers: {{ $bootstrapServers | quote }}
{{- if eq .dot.Values.kafka.auth.clientProtocol "sasl_tls" }}
security.protocol: "SASL_SSL"
Expand Down Expand Up @@ -607,22 +607,22 @@ The scope passed in is expected to be a dict with keys
{{- if ( ne $keySecretName "none" ) }}
- name: "tls-keys"
secret:
secretName: {{ ternary ( printf "%s-%s-example-keys" ( include "hono.fullname" .dot ) .name ) $keySecretName ( eq $keySecretName "example" ) | quote }}
secretName: {{ ternary ( printf "%s-%s-example-keys" ( include "hono.fullname" . ) .name ) $keySecretName ( eq $keySecretName "example" ) | quote }}
{{- end }}
{{- $trustStoreConfigMapName := ( default "none" .componentConfig.tlsTrustStoreConfigMap | toString ) }}
{{- if ( ne $trustStoreConfigMapName "none" ) }}
- name: "tls-trust-store"
configMap:
name: {{ ternary ( printf "%s-example-trust-store" ( include "hono.fullname" .dot )) $trustStoreConfigMapName ( eq $trustStoreConfigMapName "example" ) | quote }}
name: {{ ternary ( printf "%s-example-trust-store" ( include "hono.fullname" . )) $trustStoreConfigMapName ( eq $trustStoreConfigMapName "example" ) | quote }}
{{- end }}
- name: "default-logging-config"
configMap:
name: {{ printf "%s-default-logging-config" ( include "hono.fullname" .dot ) | quote }}
name: {{ printf "%s-default-logging-config" ( include "hono.fullname" . ) | quote }}
optional: true
{{- $volumeName := printf "%s-conf" .name }}
- name: {{ $volumeName | quote }}
secret:
secretName: {{ printf "%s-%s" ( include "hono.fullname" .dot ) $volumeName | quote }}
secretName: {{ printf "%s-%s" ( include "hono.fullname" . ) $volumeName | quote }}
{{- if and .dot.Values.otelCollectorAgentConfigMap ( not .dot.Values.jaegerBackendExample.enabled ) }}
- name: "otel-collector-config"
configMap:
Expand Down
4 changes: 2 additions & 2 deletions charts/hono/templates/example-data-grid/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ metadata:
{{- include "hono.metadata" $args | nindent 2 }}
spec:
replicas: 1
serviceName: {{ printf "%s-%s" (include "hono.fullname" .) $args.name }}
serviceName: {{ printf "%s-%s" (include "hono.fullname" $args) $args.name }}
selector:
matchLabels:
{{- include "hono.matchLabels" $args | nindent 6 }}
Expand All @@ -43,7 +43,7 @@ spec:
- name: JDK_JAVA_OPTIONS
value: "-XX:MinRAMPercentage=85 -XX:MaxRAMPercentage=85"
- name: JAVA_OPTIONS
value: {{ printf "-Djgroups.dns.query=%s-%s" (include "hono.fullname" .) $args.name }}
value: {{ printf "-Djgroups.dns.query=%s-%s" (include "hono.fullname" $args) $args.name }}
ports:
- name: hotrod
containerPort: 11222
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ metadata:
{{- include "hono.metadata" $args | nindent 2 }}
data:
add_example_data_device_registry.sh: |
{{- tpl (.Files.Get "example/add_example_data_device_registry.sh") . | nindent 4 }}
{{- $_ := set $ "dot" $args.dot }}
{{- tpl (.Files.Get "example/add_example_data_device_registry.sh") $ | nindent 4 }}
example-tenants.sh: |
{{ .Files.Get "example/example-tenants.sh" | nindent 4 }}
example-devices.sh: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ metadata:
spec:
template:
metadata:
name: {{ printf "%s-%s" ( include "hono.fullname" . ) "post-install" | quote }}
name: {{ printf "%s-%s" ( include "hono.fullname" $args ) "post-install" | quote }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
Expand All @@ -48,6 +48,6 @@ spec:
volumes:
- name: post-install-data
configMap:
name: {{ printf "%s-post-install-device-registry-conf" ( include "hono.fullname" . ) }}
name: {{ printf "%s-post-install-device-registry-conf" ( include "hono.fullname" $args ) }}
defaultMode: 0555
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ stringData:
{{- if .Values.deviceRegistryExample.hono.auth }}
{{- .Values.deviceRegistryExample.hono.auth | toYaml | nindent 8 }}
{{- else }}
host: {{ printf "%s-service-auth" ( include "hono.fullname" . ) | quote }}
host: {{ printf "%s-service-auth" ( include "hono.fullname" $args ) | quote }}
port: 5671
trustStorePath: "/opt/hono/tls/ca.crt"
hostnameVerificationRequired: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,5 @@ spec:
{{- include "hono.pod.volumes" ( dict "dot" $args.dot "name" $args.name "componentConfig" .Values.deviceRegistryExample ) | indent 6 }}
- name: "registry"
persistentVolumeClaim:
claimName: {{ printf "%s-%s" ( include "hono.fullname" . ) $args.name | quote }}
claimName: {{ printf "%s-%s" ( include "hono.fullname" $args ) $args.name | quote }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ stringData:
{{- if .Values.deviceRegistryExample.hono.auth }}
{{- .Values.deviceRegistryExample.hono.auth | toYaml | nindent 8 }}
{{- else }}
host: {{ printf "%s-service-auth" ( include "hono.fullname" . ) | quote }}
host: {{ printf "%s-service-auth" ( include "hono.fullname" $args ) | quote }}
port: 5671
trustStorePath: "/opt/hono/tls/ca.crt"
hostnameVerificationRequired: false
Expand Down
2 changes: 1 addition & 1 deletion charts/hono/templates/kafka/kafka-example-keys.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
apiVersion: v1
kind: Secret
metadata:
{{- $args := dict "dot" . "component" "kafka" "name" "kafka-example-keys" }}
{{- $args := dict "dot" (. | deepCopy | merge (dict "Values" (pick .Values.kafka "nameOverride" "fullnameOverride"))) "component" "kafka" "name" "kafka-example-keys" }}
{{- include "hono.metadata" $args | nindent 2 }}
type: Opaque
data:
Expand Down
8 changes: 3 additions & 5 deletions charts/hono/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
# Default values for eclipse-hono.
# Declare variables to be passed into your templates.

global:
hono:
nameOverride: ""
fullnameOverride: ""
nameOverride: ""
fullnameOverride: ""

# honoImagesTag contains the (common) tag name of the Hono component
# container images to deploy.
Expand Down Expand Up @@ -1687,7 +1685,7 @@ kafka:
type: "pem"
pemChainIncluded: true
existingSecrets:
- "{{ include \"hono.fullname\" . }}-kafka-example-keys"
- "{{ include \"hono.fullname\" (dict \"dot\" .) }}-kafka-example-keys"

service:
ports:
Expand Down
3 changes: 2 additions & 1 deletion packages/cloud2edge/templates/post-install-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ spec:
secret:
secretName: {{ printf "%s-%s" .Release.Name "ditto-gateway-secret" }}
{{- if and .Values.hono.kafkaMessagingClusterExample .Values.hono.kafkaMessagingClusterExample.enabled }}
{{- $args := dict "dot" (. | deepCopy | merge (dict "Values" (pick .Values.kafka "nameOverride" "fullnameOverride"))) }}
- name: kafka-connection-cert
secret:
secretName: {{ printf "%s-%s" .Release.Name "kafka-example-keys" }}
secretName: {{ printf "%s-%s" (include "hono.fullname" $args) "kafka-example-keys" }}
{{- end}}

0 comments on commit 3380233

Please sign in to comment.