From f8db2160a53163e401579a23ce90e167c96ed097 Mon Sep 17 00:00:00 2001 From: Ruben Van Wanzeele Date: Wed, 22 May 2024 15:33:11 +0200 Subject: [PATCH] [bitnami/kafka] #25646 Use parameter map for kafka config Allow to use a yaml parameter map next to the flat file for the extraConfig parameter. This is added as a separate parameter extraConfigYaml. This allows for easier overloading both between the default and broker / controller values; and between multiple values.yaml. Signed-off-by: Ruben Van Wanzeele --- bitnami/kafka/CHANGELOG.md | 4 ++++ bitnami/kafka/Chart.yaml | 2 +- bitnami/kafka/README.md | 3 +++ bitnami/kafka/templates/_helpers.tpl | 7 +++++++ bitnami/kafka/templates/broker/configmap.yaml | 5 +++++ .../templates/controller-eligible/configmap.yaml | 5 +++++ bitnami/kafka/values.yaml | 15 +++++++++++++++ 7 files changed, 40 insertions(+), 1 deletion(-) diff --git a/bitnami/kafka/CHANGELOG.md b/bitnami/kafka/CHANGELOG.md index 34ba9ec55f115e..8ba95a705aa234 100644 --- a/bitnami/kafka/CHANGELOG.md +++ b/bitnami/kafka/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 29.1.3 (2024-05-30) + +* [bitnami/kafka] Add support for helm parameter maps for kafka config, closes ([#25646](https://github.com/bitnami/charts/issues/25646)) + ## 29.1.2 (2024-05-29) * [bitnami/kafka] PDB review ([#25938](https://github.com/bitnami/charts/pull/25938)) diff --git a/bitnami/kafka/Chart.yaml b/bitnami/kafka/Chart.yaml index c9230a25e14aca..880b14a96cc0ec 100644 --- a/bitnami/kafka/Chart.yaml +++ b/bitnami/kafka/Chart.yaml @@ -40,4 +40,4 @@ maintainers: name: kafka sources: - https://github.com/bitnami/charts/tree/main/bitnami/kafka -version: 29.1.2 +version: 29.1.3 diff --git a/bitnami/kafka/README.md b/bitnami/kafka/README.md index 5e687e2eb382fc..50214eca351caa 100644 --- a/bitnami/kafka/README.md +++ b/bitnami/kafka/README.md @@ -447,6 +447,7 @@ You can enable this initContainer by setting `volumePermissions.enabled` to `tru | `config` | Configuration file for Kafka, rendered as a template. Auto-generated based on chart values when not specified. | `""` | | `existingConfigmap` | ConfigMap with Kafka Configuration | `""` | | `extraConfig` | Additional configuration to be appended at the end of the generated Kafka configuration file. | `""` | +| `extraConfigYaml` | Additional configuration in yaml format to be appended at the end of the generated Kafka configuration file. | `{}` | | `secretConfig` | Additional configuration to be appended at the end of the generated Kafka configuration file. | `""` | | `existingSecretConfig` | Secret with additonal configuration that will be appended to the end of the generated Kafka configuration file | `""` | | `log4j` | An optional log4j.properties file to overwrite the default of the Kafka brokers | `""` | @@ -551,6 +552,7 @@ You can enable this initContainer by setting `volumePermissions.enabled` to `tru | `controller.config` | Configuration file for Kafka controller-eligible nodes, rendered as a template. Auto-generated based on chart values when not specified. | `""` | | `controller.existingConfigmap` | ConfigMap with Kafka Configuration for controller-eligible nodes. | `""` | | `controller.extraConfig` | Additional configuration to be appended at the end of the generated Kafka controller-eligible nodes configuration file. | `""` | +| `controller.extraConfigYaml` | Additional configuration in yaml format to be appended at the end of the generated Kafka controller-eligible nodes configuration file. | `{}` | | `controller.secretConfig` | Additional configuration to be appended at the end of the generated Kafka controller-eligible nodes configuration file. | `""` | | `controller.existingSecretConfig` | Secret with additonal configuration that will be appended to the end of the generated Kafka controller-eligible nodes configuration file | `""` | | `controller.heapOpts` | Kafka Java Heap size for controller-eligible nodes | `-Xmx1024m -Xms1024m` | @@ -675,6 +677,7 @@ You can enable this initContainer by setting `volumePermissions.enabled` to `tru | `broker.config` | Configuration file for Kafka broker-only nodes, rendered as a template. Auto-generated based on chart values when not specified. | `""` | | `broker.existingConfigmap` | ConfigMap with Kafka Configuration for broker-only nodes. | `""` | | `broker.extraConfig` | Additional configuration to be appended at the end of the generated Kafka broker-only nodes configuration file. | `""` | +| `broker.extraConfigYaml` | Additional configuration in yaml format to be appended at the end of the generated Kafka broker-only nodes configuration file. | `{}` | | `broker.secretConfig` | Additional configuration to be appended at the end of the generated Kafka broker-only nodes configuration file. | `""` | | `broker.existingSecretConfig` | Secret with additonal configuration that will be appended to the end of the generated Kafka broker-only nodes configuration file | `""` | | `broker.heapOpts` | Kafka Java Heap size for broker-only nodes | `-Xmx1024m -Xms1024m` | diff --git a/bitnami/kafka/templates/_helpers.tpl b/bitnami/kafka/templates/_helpers.tpl index cf12a096a34f93..0640e67e189d72 100644 --- a/bitnami/kafka/templates/_helpers.tpl +++ b/bitnami/kafka/templates/_helpers.tpl @@ -1219,3 +1219,10 @@ kafka: Missing KRaft or Zookeeper mode settings Please configure 'kraft.enabled', 'zookeeper.enabled' or `externalZookeeper.servers` before proceeding. {{- end -}} {{- end -}} + +{{/* Render key, value as proprties format */}} +{{- define "common.properties.render" -}} +{{- range $key, $value := . }} +{{ $key }}={{ tpl (toString $value) $ }} +{{- end -}} +{{- end -}} diff --git a/bitnami/kafka/templates/broker/configmap.yaml b/bitnami/kafka/templates/broker/configmap.yaml index 94fef9fa1a8ec8..0a5ad9f9daca0f 100644 --- a/bitnami/kafka/templates/broker/configmap.yaml +++ b/bitnami/kafka/templates/broker/configmap.yaml @@ -44,8 +44,13 @@ data: log.dir={{ printf "%s/data" .Values.broker.persistence.mountPath }} # Kafka application logs directory logs.dir={{ .Values.broker.logPersistence.mountPath }} + + # Common Kafka Configuration {{- include "kafka.commonConfig" . | nindent 4 }} + + # Custom Kafka Configuration {{- include "common.tplvalues.render" ( dict "value" .Values.extraConfig "context" $ ) | nindent 4 }} {{- include "common.tplvalues.render" ( dict "value" .Values.broker.extraConfig "context" $ ) | nindent 4 }} + {{- include "common.properties.render" (merge .Values.broker.extraConfigYaml .Values.extraConfigYaml ) | nindent 4 }} {{- end }} {{- end }} diff --git a/bitnami/kafka/templates/controller-eligible/configmap.yaml b/bitnami/kafka/templates/controller-eligible/configmap.yaml index ed688767cf0bc1..15c7df24953d96 100644 --- a/bitnami/kafka/templates/controller-eligible/configmap.yaml +++ b/bitnami/kafka/templates/controller-eligible/configmap.yaml @@ -43,8 +43,13 @@ data: log.dir={{ printf "%s/data" .Values.controller.persistence.mountPath }} # Kafka application logs directory logs.dir={{ .Values.controller.logPersistence.mountPath }} + + # Common Kafka Configuration {{- include "kafka.commonConfig" . | nindent 4 }} + + # Custom Kafka Configuration {{- include "common.tplvalues.render" ( dict "value" .Values.extraConfig "context" $ ) | nindent 4 }} {{- include "common.tplvalues.render" ( dict "value" .Values.controller.extraConfig "context" $ ) | nindent 4 }} + {{- include "common.properties.render" (merge .Values.controller.extraConfigYaml .Values.extraConfigYaml) | nindent 4 }} {{- end }} {{- end }} diff --git a/bitnami/kafka/values.yaml b/bitnami/kafka/values.yaml index 42553d107a9d3e..ebc65277cfc0ab 100644 --- a/bitnami/kafka/values.yaml +++ b/bitnami/kafka/values.yaml @@ -118,6 +118,13 @@ existingConfigmap: "" ## @param extraConfig Additional configuration to be appended at the end of the generated Kafka configuration file. ## extraConfig: "" +## @param extraConfigYaml Additional configuration in yaml format to be appended at the end of the generated Kafka configuration file. +## +## E.g. +## extraConfigYaml: +## default.replication.factor: 3 +## +extraConfigYaml: {} ## @param secretConfig Additional configuration to be appended at the end of the generated Kafka configuration file. ## This value will be stored in a secret. ## @@ -499,6 +506,10 @@ controller: ## @param controller.extraConfig Additional configuration to be appended at the end of the generated Kafka controller-eligible nodes configuration file. ## extraConfig: "" + ## @param controller.extraConfigYaml Additional configuration in yaml format to be appended at the end of the generated Kafka controller-eligible nodes configuration file. + ## If keys of extraConfigYaml are duplicated here, the value from controller.extraConfigYaml is taken. + ## + extraConfigYaml: {} ## @param controller.secretConfig Additional configuration to be appended at the end of the generated Kafka controller-eligible nodes configuration file. ## This value will be stored in a secret. ## @@ -953,6 +964,10 @@ broker: ## @param broker.extraConfig Additional configuration to be appended at the end of the generated Kafka broker-only nodes configuration file. ## extraConfig: "" + ## @param broker.extraConfigYaml Additional configuration in yaml format to be appended at the end of the generated Kafka broker-only nodes configuration file. + ## If keys of extraConfigYaml are duplicated here, the value from broker.extraConfigYaml is taken. + ## + extraConfigYaml: {} ## @param broker.secretConfig Additional configuration to be appended at the end of the generated Kafka broker-only nodes configuration file. ## This value will be stored in a secret. ##