Skip to content

Commit 1758ba0

Browse files
committed
Advertisement can probably never be omitted when using kraft
and we can move it out of the if because init-config without kubectl nerver worked anyway
1 parent 5a07d3c commit 1758ba0

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

kafka/10broker-config.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ data:
1414
LABELS="kafka-broker-id=$KAFKA_BROKER_ID"
1515
ANNOTATIONS=""
1616
17+
[ -z "$ADVERTISE_ADDR" ] && echo "ADVERTISE_ADDR is empty, will advertise detected DNS name"
18+
OUTSIDE_HOST=$(kubectl get node "$NODE_NAME" -o jsonpath='{.status.addresses[?(@.type=="InternalIP")].address}')
19+
OUTSIDE_PORT=$((32400 + ${KAFKA_BROKER_ID}))
20+
SEDS+=("s|#init#advertised.listeners=PLAINTEXT://#init#|advertised.listeners=PLAINTEXT://${ADVERTISE_ADDR}:9092,CONTROLLER://${ADVERTISE_ADDR}:9093,OUTSIDE://${OUTSIDE_HOST}:${OUTSIDE_PORT}|")
21+
ANNOTATIONS="$ANNOTATIONS kafka-listener-outside-host=$OUTSIDE_HOST kafka-listener-outside-port=$OUTSIDE_PORT"
22+
1723
if ! command -v kubectl >/dev/null; then
1824
SEDS+=("s/#init#broker.rack=#init#/#init#broker.rack=# kubectl not found in path/")
1925
else
@@ -25,12 +31,6 @@ data:
2531
LABELS="$LABELS kafka-broker-rack=$ZONE"
2632
fi
2733
28-
[ -z "$ADVERTISE_ADDR" ] && echo "ADVERTISE_ADDR is empty, will advertise detected DNS name"
29-
OUTSIDE_HOST=$(kubectl get node "$NODE_NAME" -o jsonpath='{.status.addresses[?(@.type=="InternalIP")].address}')
30-
OUTSIDE_PORT=$((32400 + ${KAFKA_BROKER_ID}))
31-
SEDS+=("s|#init#advertised.listeners=PLAINTEXT://#init#|advertised.listeners=PLAINTEXT://${ADVERTISE_ADDR}:9092,OUTSIDE://${OUTSIDE_HOST}:${OUTSIDE_PORT}|")
32-
ANNOTATIONS="$ANNOTATIONS kafka-listener-outside-host=$OUTSIDE_HOST kafka-listener-outside-port=$OUTSIDE_PORT"
33-
3434
if [ ! -z "$LABELS" ]; then
3535
kubectl -n $POD_NAMESPACE label pod $POD_NAME $LABELS || echo "Failed to label $POD_NAMESPACE.$POD_NAME - RBAC issue?"
3636
fi
@@ -73,7 +73,7 @@ data:
7373
7474
############################# Socket Server Settings #############################
7575
76-
# The address the socket server listens on. It will get the value returned from
76+
# The address the socket server listens on. It will get the value returned from
7777
# java.net.InetAddress.getCanonicalHostName() if not configured.
7878
# FORMAT:
7979
# listeners = listener_name://host_name:port
@@ -82,7 +82,7 @@ data:
8282
#listeners=PLAINTEXT://:9092
8383
listeners=PLAINTEXT://:9092,OUTSIDE://:9094
8484
85-
# Hostname and port the broker will advertise to producers and consumers. If not set,
85+
# Hostname and port the broker will advertise to producers and consumers. If not set,
8686
# it uses the value for "listeners" if configured. Otherwise, it will use the value
8787
# returned from java.net.InetAddress.getCanonicalHostName().
8888
#advertised.listeners=PLAINTEXT://your.host.name:9092

0 commit comments

Comments
 (0)