github.com/1aal/kubeblocks@v0.0.0-20231107070852-e1c03e598921/deploy/kafka/scripts/kafka-env.sh (about) 1 #!/bin/bash 2 # 3 # Environment configuration for kafka 4 5 # The values for all environment variables will be set in the below order of precedence 6 # 1. Custom environment variables defined below after Bitnami defaults 7 # 2. Constants defined in this file (environment variables with no default), i.e. BITNAMI_ROOT_DIR 8 # 3. Environment variables overridden via external files using *_FILE variables (see below) 9 # 4. Environment variables set externally (i.e. current Bash context/Dockerfile/userdata) 10 11 # Load logging library 12 # shellcheck disable=SC1090,SC1091 13 . /opt/bitnami/scripts/liblog.sh 14 15 export BITNAMI_ROOT_DIR="/opt/bitnami" 16 export BITNAMI_VOLUME_DIR="/bitnami" 17 18 # Logging configuration 19 export MODULE="${MODULE:-kafka}" 20 export BITNAMI_DEBUG="${BITNAMI_DEBUG:-false}" 21 22 # By setting an environment variable matching *_FILE to a file path, the prefixed environment 23 # variable will be overridden with the value specified in that file 24 kafka_env_vars=( 25 ALLOW_PLAINTEXT_LISTENER 26 KAFKA_INTER_BROKER_USER 27 KAFKA_INTER_BROKER_PASSWORD 28 KAFKA_CERTIFICATE_PASSWORD 29 KAFKA_TLS_TRUSTSTORE_FILE 30 KAFKA_TLS_TYPE 31 KAFKA_TLS_CLIENT_AUTH 32 KAFKA_OPTS 33 KAFKA_CFG_LISTENERS 34 KAFKA_CFG_ADVERTISED_LISTENERS 35 KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP 36 KAFKA_CFG_ZOOKEEPER_CONNECT 37 KAFKA_CFG_SASL_ENABLED_MECHANISMS 38 KAFKA_CFG_SASL_MECHANISM_INTER_BROKER_PROTOCOL 39 KAFKA_CFG_SASL_MECHANISM_CONTROLLER_PROTOCOL 40 KAFKA_CFG_INTER_BROKER_LISTENER_NAME 41 KAFKA_CFG_MAX_REQUEST_SIZE 42 KAFKA_CFG_MAX_PARTITION_FETCH_BYTES 43 KAFKA_ENABLE_KRAFT 44 KAFKA_KRAFT_CLUSTER_ID 45 KAFKA_ZOOKEEPER_PROTOCOL 46 KAFKA_ZOOKEEPER_PASSWORD 47 KAFKA_ZOOKEEPER_USER 48 KAFKA_ZOOKEEPER_TLS_KEYSTORE_PASSWORD 49 KAFKA_ZOOKEEPER_TLS_TRUSTSTORE_PASSWORD 50 KAFKA_ZOOKEEPER_TLS_TRUSTSTORE_FILE 51 KAFKA_ZOOKEEPER_TLS_VERIFY_HOSTNAME 52 KAFKA_ZOOKEEPER_TLS_TYPE 53 KAFKA_CLIENT_USERS 54 KAFKA_CLIENT_PASSWORDS 55 KAFKA_HEAP_OPTS 56 ) 57 for env_var in "${kafka_env_vars[@]}"; do 58 file_env_var="${env_var}_FILE" 59 if [[ -n "${!file_env_var:-}" ]]; then 60 if [[ -r "${!file_env_var:-}" ]]; then 61 export "${env_var}=$(< "${!file_env_var}")" 62 unset "${file_env_var}" 63 else 64 warn "Skipping export of '${env_var}'. '${!file_env_var:-}' is not readable." 65 fi 66 fi 67 done 68 unset kafka_env_vars 69 70 # Paths 71 export KAFKA_BASE_DIR="${BITNAMI_ROOT_DIR}/kafka" 72 export KAFKA_VOLUME_DIR="/bitnami/kafka" 73 export KAFKA_DATA_DIR="${KAFKA_VOLUME_DIR}/data" 74 export KAFKA_CONF_DIR="${KAFKA_BASE_DIR}/config" 75 export KAFKA_CONF_FILE="${KAFKA_CONF_DIR}/server.properties" ## modified by ApeCloud 76 export KAFKA_ZK_CONF_FILE="${KAFKA_CONF_DIR}/server.properties" 77 export KAFKA_MOUNTED_CONF_DIR="${KAFKA_VOLUME_DIR}/config" 78 export KAFKA_CERTS_DIR="${KAFKA_CONF_DIR}/certs" 79 export KAFKA_INITSCRIPTS_DIR="/docker-entrypoint-initdb.d" 80 export KAFKA_LOG_DIR="${KAFKA_BASE_DIR}/logs" 81 export KAFKA_HOME="$KAFKA_BASE_DIR" 82 export PATH="${KAFKA_BASE_DIR}/bin:${BITNAMI_ROOT_DIR}/java/bin:${PATH}" 83 84 # System users (when running with a privileged user) 85 export KAFKA_DAEMON_USER="kafka" 86 export KAFKA_DAEMON_GROUP="kafka" 87 88 # Kafka runtime settings 89 export ALLOW_PLAINTEXT_LISTENER="${ALLOW_PLAINTEXT_LISTENER:-no}" 90 export KAFKA_INTER_BROKER_USER="${KAFKA_INTER_BROKER_USER:-user}" 91 export KAFKA_INTER_BROKER_PASSWORD="${KAFKA_INTER_BROKER_PASSWORD:-bitnami}" 92 export KAFKA_CERTIFICATE_PASSWORD="${KAFKA_CERTIFICATE_PASSWORD:-}" 93 export KAFKA_TLS_TRUSTSTORE_FILE="${KAFKA_TLS_TRUSTSTORE_FILE:-}" 94 export KAFKA_TLS_TYPE="${KAFKA_TLS_TYPE:-JKS}" 95 export KAFKA_TLS_CLIENT_AUTH="${KAFKA_TLS_CLIENT_AUTH:-required}" 96 export KAFKA_OPTS="${KAFKA_OPTS:-}" 97 98 # Kafka configuration overrides 99 export KAFKA_CFG_LISTENERS="${KAFKA_CFG_LISTENERS:-PLAINTEXT://:9092,CONTROLLER://:9093}" 100 #export KAFKA_CFG_ADVERTISED_LISTENERS="${KAFKA_CFG_ADVERTISED_LISTENERS:-PLAINTEXT://:9092}" ## modified by ApeCloud 101 export KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP="${KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP:-}" 102 export KAFKA_CFG_ZOOKEEPER_CONNECT="${KAFKA_CFG_ZOOKEEPER_CONNECT:-}" 103 export KAFKA_CFG_SASL_ENABLED_MECHANISMS="${KAFKA_CFG_SASL_ENABLED_MECHANISMS:-PLAIN,SCRAM-SHA-256,SCRAM-SHA-512}" 104 export KAFKA_CFG_SASL_MECHANISM_INTER_BROKER_PROTOCOL="${KAFKA_CFG_SASL_MECHANISM_INTER_BROKER_PROTOCOL:-}" 105 export KAFKA_CFG_SASL_MECHANISM_CONTROLLER_PROTOCOL="${KAFKA_CFG_SASL_MECHANISM_CONTROLLER_PROTOCOL:-}" 106 export KAFKA_CFG_INTER_BROKER_LISTENER_NAME="${KAFKA_CFG_INTER_BROKER_LISTENER_NAME:-}" 107 export KAFKA_CFG_MAX_REQUEST_SIZE="${KAFKA_CFG_MAX_REQUEST_SIZE:-}" 108 export KAFKA_CFG_MAX_PARTITION_FETCH_BYTES="${KAFKA_CFG_MAX_PARTITION_FETCH_BYTES:-}" 109 export KAFKA_ENABLE_KRAFT="${KAFKA_ENABLE_KRAFT:-yes}" 110 export KAFKA_KRAFT_CLUSTER_ID="${KAFKA_KRAFT_CLUSTER_ID:-}" 111 112 # ZooKeeper connection settings 113 export KAFKA_ZOOKEEPER_PROTOCOL="${KAFKA_ZOOKEEPER_PROTOCOL:-PLAINTEXT}" 114 export KAFKA_ZOOKEEPER_PASSWORD="${KAFKA_ZOOKEEPER_PASSWORD:-}" 115 export KAFKA_ZOOKEEPER_USER="${KAFKA_ZOOKEEPER_USER:-}" 116 export KAFKA_ZOOKEEPER_TLS_KEYSTORE_PASSWORD="${KAFKA_ZOOKEEPER_TLS_KEYSTORE_PASSWORD:-}" 117 export KAFKA_ZOOKEEPER_TLS_TRUSTSTORE_PASSWORD="${KAFKA_ZOOKEEPER_TLS_TRUSTSTORE_PASSWORD:-}" 118 export KAFKA_ZOOKEEPER_TLS_TRUSTSTORE_FILE="${KAFKA_ZOOKEEPER_TLS_TRUSTSTORE_FILE:-}" 119 export KAFKA_ZOOKEEPER_TLS_VERIFY_HOSTNAME="${KAFKA_ZOOKEEPER_TLS_VERIFY_HOSTNAME:-true}" 120 export KAFKA_ZOOKEEPER_TLS_TYPE="${KAFKA_ZOOKEEPER_TLS_TYPE:-JKS}" 121 122 # Authentication 123 export KAFKA_CLIENT_USERS="${KAFKA_CLIENT_USERS:-user}" 124 export KAFKA_CLIENT_PASSWORDS="${KAFKA_CLIENT_PASSWORDS:-bitnami}" 125 126 # Java settings 127 export KAFKA_HEAP_OPTS="${KAFKA_HEAP_OPTS:--Xmx1024m -Xms1024m}" 128 129 # Custom environment variables may be defined below