From d4be57fa067bbf52cb6f09203e1a3c1ddb31d691 Mon Sep 17 00:00:00 2001 From: Tim Curtin Date: Thu, 14 Jun 2018 05:27:28 +1000 Subject: [PATCH] Kafka release name check (#5770) * Add default function from chart template to check release name match * Increment chart version * Update to latest _helpers.tpl * Unset deprecated port created by kubernetes * Revert change to zookeeper.fullname for KAFKA_ZOOKEEPER_CONNECT var * Update readme to clarify limitation * Increment version number * Bump chart version, not appversion * Alter maintainers to have github username for CI --- incubator/kafka/Chart.yaml | 8 ++++---- incubator/kafka/README.md | 2 +- incubator/kafka/templates/_helpers.tpl | 16 ++++++++++++++++ incubator/kafka/templates/statefulset.yaml | 1 + 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/incubator/kafka/Chart.yaml b/incubator/kafka/Chart.yaml index 00fcc645a8..e115a55a98 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.7.3 +version: 0.7.4 appVersion: 4.0.1 keywords: - kafka @@ -15,10 +15,10 @@ sources: - https://github.com/confluentinc/cp-docker-images - https://github.com/apache/kafka maintainers: -- name: Faraaz Khan +- name: faraazkhan email: faraaz@rationalizeit.us -- name: Marc Villacorta +- name: h0tbird email: marc.villacorta@gmail.com -- name: Ben Goldberg +- name: benjigoldberg email: ben@spothero.com icon: https://kafka.apache.org/images/logo.png diff --git a/incubator/kafka/README.md b/incubator/kafka/README.md index fc7edeac46..4531c1ff50 100644 --- a/incubator/kafka/README.md +++ b/incubator/kafka/README.md @@ -187,7 +187,7 @@ such port at a time, setting the range at every Kafka pod is a reasonably safe c * Topic creation is not automated * Only supports storage options that have backends for persistent volume claims (tested mostly on AWS) -* There must not exist a service called `kafka` in the same namespace +* KAFKA_PORT will be created as an envvar and brokers will fail to start when there is a service named `kafka` in the same namespace. We work around this be unsetting that envvar `unset KAFKA_PORT`. [brokerconfigs]: https://kafka.apache.org/documentation/#brokerconfigs diff --git a/incubator/kafka/templates/_helpers.tpl b/incubator/kafka/templates/_helpers.tpl index cac6e1961c..cb0d3002ea 100644 --- a/incubator/kafka/templates/_helpers.tpl +++ b/incubator/kafka/templates/_helpers.tpl @@ -9,11 +9,20 @@ Expand the name of the chart. {{/* 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 a default fully qualified zookeeper name. @@ -38,3 +47,10 @@ else use user-provided URL {{- default $zookeeperConnect $zookeeperConnectOverride }} {{- 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 -}} \ No newline at end of file diff --git a/incubator/kafka/templates/statefulset.yaml b/incubator/kafka/templates/statefulset.yaml index c764bfc01e..458518a358 100644 --- a/incubator/kafka/templates/statefulset.yaml +++ b/incubator/kafka/templates/statefulset.yaml @@ -159,6 +159,7 @@ spec: - sh - -exc - | + unset KAFKA_PORT && \ export KAFKA_BROKER_ID=${HOSTNAME##*-} && \ export KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://${POD_IP}:9092{{ if kindIs "string" $advertisedListenersOverride }}{{ printf ",%s" $advertisedListenersOverride }}{{ end }} && \ exec /etc/confluent/docker/run