3 # Copyright 2016 Confluent Inc.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 . /etc/confluent/docker/bash-config
19 dub ensure KAFKA_ZOOKEEPER_CONNECT
20 dub ensure KAFKA_ADVERTISED_LISTENERS
22 # By default, LISTENERS is derived from ADVERTISED_LISTENERS by replacing
23 # hosts with 0.0.0.0. This is good default as it ensures that the broker
24 # process listens on all ports.
25 if [[ -z "${KAFKA_LISTENERS-}" ]]
27 export KAFKA_LISTENERS
28 KAFKA_LISTENERS=$(cub listeners "$KAFKA_ADVERTISED_LISTENERS")
31 dub path /etc/kafka/ writable
33 if [[ -z "${KAFKA_LOG_DIRS-}" ]]
36 KAFKA_LOG_DIRS="/var/lib/kafka/data"
39 # advertised.host, advertised.port, host and port are deprecated. Exit if these properties are set.
40 if [[ -n "${KAFKA_ADVERTISED_PORT-}" ]]
42 echo "advertised.port is deprecated. Please use KAFKA_ADVERTISED_LISTENERS instead."
46 if [[ -n "${KAFKA_ADVERTISED_HOST-}" ]]
48 echo "advertised.host is deprecated. Please use KAFKA_ADVERTISED_LISTENERS instead."
52 if [[ -n "${KAFKA_HOST-}" ]]
54 echo "host is deprecated. Please use KAFKA_ADVERTISED_LISTENERS instead."
58 if [[ -n "${KAFKA_PORT-}" ]]
60 echo "port is deprecated. Please use KAFKA_ADVERTISED_LISTENERS instead."
64 # Set if ADVERTISED_LISTENERS has SSL:// or SASL_SSL:// endpoints.
65 if [[ $KAFKA_ADVERTISED_LISTENERS == *"SSL://"* ]]
67 echo "SSL is enabled."
69 dub ensure KAFKA_SSL_KEYSTORE_FILENAME
70 export KAFKA_SSL_KEYSTORE_LOCATION="/etc/kafka/secrets/$KAFKA_SSL_KEYSTORE_FILENAME"
71 dub path "$KAFKA_SSL_KEYSTORE_LOCATION" exists
73 dub ensure KAFKA_SSL_KEY_CREDENTIALS
74 KAFKA_SSL_KEY_CREDENTIALS_LOCATION="/etc/kafka/secrets/$KAFKA_SSL_KEY_CREDENTIALS"
75 dub path "$KAFKA_SSL_KEY_CREDENTIALS_LOCATION" exists
76 export KAFKA_SSL_KEY_PASSWORD
77 KAFKA_SSL_KEY_PASSWORD=$(cat "$KAFKA_SSL_KEY_CREDENTIALS_LOCATION")
79 dub ensure KAFKA_SSL_KEYSTORE_CREDENTIALS
80 KAFKA_SSL_KEYSTORE_CREDENTIALS_LOCATION="/etc/kafka/secrets/$KAFKA_SSL_KEYSTORE_CREDENTIALS"
81 dub path "$KAFKA_SSL_KEYSTORE_CREDENTIALS_LOCATION" exists
82 export KAFKA_SSL_KEYSTORE_PASSWORD
83 KAFKA_SSL_KEYSTORE_PASSWORD=$(cat "$KAFKA_SSL_KEYSTORE_CREDENTIALS_LOCATION")
85 if [[ -n "${KAFKA_SSL_CLIENT_AUTH-}" ]] && ( [[ $KAFKA_SSL_CLIENT_AUTH == *"required"* ]] || [[ $KAFKA_SSL_CLIENT_AUTH == *"requested"* ]] )
87 dub ensure KAFKA_SSL_TRUSTSTORE_FILENAME
88 export KAFKA_SSL_TRUSTSTORE_LOCATION="/etc/kafka/secrets/$KAFKA_SSL_TRUSTSTORE_FILENAME"
89 dub path "$KAFKA_SSL_TRUSTSTORE_LOCATION" exists
91 dub ensure KAFKA_SSL_TRUSTSTORE_CREDENTIALS
92 KAFKA_SSL_TRUSTSTORE_CREDENTIALS_LOCATION="/etc/kafka/secrets/$KAFKA_SSL_TRUSTSTORE_CREDENTIALS"
93 dub path "$KAFKA_SSL_TRUSTSTORE_CREDENTIALS_LOCATION" exists
94 export KAFKA_SSL_TRUSTSTORE_PASSWORD
95 KAFKA_SSL_TRUSTSTORE_PASSWORD=$(cat "$KAFKA_SSL_TRUSTSTORE_CREDENTIALS_LOCATION")
100 # Set if KAFKA_ADVERTISED_LISTENERS has SASL_PLAINTEXT:// or SASL_SSL:// endpoints.
101 if [[ $KAFKA_ADVERTISED_LISTENERS =~ .*SASL_.*://.* ]]
103 echo "SASL" is enabled.
105 dub ensure KAFKA_OPTS
107 if [[ ! $KAFKA_OPTS == *"java.security.auth.login.config"* ]]
109 echo "KAFKA_OPTS should contain 'java.security.auth.login.config' property."
113 if [[ -n "${KAFKA_JMX_OPTS-}" ]]
115 if [[ ! $KAFKA_JMX_OPTS == *"com.sun.management.jmxremote.rmi.port"* ]]
117 echo "KAFKA_OPTS should contain 'com.sun.management.jmxremote.rmi.port' property. It is required for accessing the JMX metrics externally."
121 dub template "/etc/confluent/docker/${COMPONENT}.properties.template" "/etc/${COMPONENT}/${COMPONENT}.properties"
122 dub template "/etc/confluent/docker/log4j.properties.template" "/etc/${COMPONENT}/log4j.properties"
123 dub template "/etc/confluent/docker/tools-log4j.properties.template" "/etc/${COMPONENT}/tools-log4j.properties"