From ca6a38ff9b251f8935405d2a8868d382cfc32c8a Mon Sep 17 00:00:00 2001 From: Nguyen Le Vu Long Date: Sat, 3 Aug 2019 02:29:53 +0700 Subject: [PATCH] [incubator/kafka] Fix offsets.topic.replication.factor to be derived from .Values.replicas (#14996) * Fix offsets.topic.replication.factor to be derived from .Values.replicas Signed-off-by: Nguyen Le Vu Long * Use template to derive offsets.topic.replication.factor Signed-off-by: Nguyen Le Vu Long --- incubator/kafka/Chart.yaml | 2 +- incubator/kafka/README.md | 2 +- incubator/kafka/templates/_helpers.tpl | 8 ++++++++ incubator/kafka/templates/statefulset.yaml | 2 ++ incubator/kafka/values.yaml | 1 - 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/incubator/kafka/Chart.yaml b/incubator/kafka/Chart.yaml index 7cf28b24c4..e78275af69 100755 --- a/incubator/kafka/Chart.yaml +++ b/incubator/kafka/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v1 description: Apache Kafka is publish-subscribe messaging rethought as a distributed commit log. name: kafka -version: 0.16.2 +version: 0.16.3 appVersion: 5.0.1 keywords: - kafka diff --git a/incubator/kafka/README.md b/incubator/kafka/README.md index d34da48e69..304e2faae6 100644 --- a/incubator/kafka/README.md +++ b/incubator/kafka/README.md @@ -85,7 +85,7 @@ following configurable parameters: | `podAnnotations` | Annotation to be added to Kafka pods | `{}` | | `podLabels` | Labels to be added to Kafka pods | `{}` | | `envOverrides` | Add additional Environment Variables in the dictionary format | `{ zookeeper.sasl.enabled: "False" }` | -| `configurationOverrides` | `Kafka ` [configuration setting][brokerconfigs] overrides in the dictionary format | `{ offsets.topic.replication.factor: 3 }` | +| `configurationOverrides` | `Kafka ` [configuration setting][brokerconfigs] overrides in the dictionary format | `{ "confluent.support.metrics.enable": false }` | | `secrets` | Pass any secrets to the kafka pods. Each secret will be passed as an environment variable by default. The secret can also be mounted to a specific path if required. Environment variable names are generated as: `_` (All upper case) | `{}` | | `additionalPorts` | Additional ports to expose on brokers. Useful when the image exposes metrics (like prometheus, etc.) through a javaagent instead of a sidecar | `{}` | | `readinessProbe.initialDelaySeconds` | Number of seconds before probe is initiated. | `30` | diff --git a/incubator/kafka/templates/_helpers.tpl b/incubator/kafka/templates/_helpers.tpl index 22846779d7..7d67a7f0cb 100644 --- a/incubator/kafka/templates/_helpers.tpl +++ b/incubator/kafka/templates/_helpers.tpl @@ -52,6 +52,14 @@ else use user-provided URL {{- end -}} {{- end -}} +{{/* +Derive offsets.topic.replication.factor in following priority order: configurationOverrides, replicas +*/}} +{{- define "kafka.replication.factor" }} +{{- $replicationFactorOverride := index .Values "configurationOverrides" "offsets.topic.replication.factor" }} +{{- default .Values.replicas $replicationFactorOverride }} +{{- end -}} + {{/* Create chart name and version as used by the chart label. */}} diff --git a/incubator/kafka/templates/statefulset.yaml b/incubator/kafka/templates/statefulset.yaml index 31478113e3..9e658b0a1d 100644 --- a/incubator/kafka/templates/statefulset.yaml +++ b/incubator/kafka/templates/statefulset.yaml @@ -158,6 +158,8 @@ spec: fieldPath: metadata.namespace - name: KAFKA_HEAP_OPTS value: {{ .Values.kafkaHeapOptions }} + - name: KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR + value: {{ include "kafka.replication.factor" . | quote }} {{- if not (hasKey .Values.configurationOverrides "zookeeper.connect") }} - name: KAFKA_ZOOKEEPER_CONNECT value: {{ include "zookeeper.url" . | quote }} diff --git a/incubator/kafka/values.yaml b/incubator/kafka/values.yaml index 307a2461a1..36281c68bc 100644 --- a/incubator/kafka/values.yaml +++ b/incubator/kafka/values.yaml @@ -169,7 +169,6 @@ podLabels: {} ## ref: https://kafka.apache.org/documentation/#brokerconfigs ## configurationOverrides: - "offsets.topic.replication.factor": 3 "confluent.support.metrics.enable": false # Disables confluent metric submission # "auto.leader.rebalance.enable": true # "auto.create.topics.enable": true