|
22 | 22 | else |
23 | 23 | sed -i "s/#init#broker.rack=#init#/broker.rack=$ZONE/" /etc/kafka/server.properties |
24 | 24 | fi |
| 25 | +
|
| 26 | + kubectl -n $POD_NAMESPACE label pod $POD_NAME kafka-broker-id=$KAFKA_BROKER_ID |
| 27 | +
|
| 28 | + OUTSIDE_HOST=$(kubectl get node "$NODE_NAME" -o jsonpath='{.status.addresses[?(@.type=="InternalIP")].address}') |
| 29 | + if [ $? -ne 0 ]; then |
| 30 | + echo "Outside (i.e. cluster-external access) host lookup command failed" |
| 31 | + else |
| 32 | + OUTSIDE_HOST=${OUTSIDE_HOST}:3240${KAFKA_BROKER_ID} |
| 33 | + sed -i "s|#init#advertised.listeners=OUTSIDE://#init#|advertised.listeners=OUTSIDE://${OUTSIDE_HOST}|" /etc/kafka/server.properties |
| 34 | + fi |
25 | 35 | } |
26 | 36 |
|
27 | 37 | server.properties: |- |
@@ -58,14 +68,18 @@ data: |
58 | 68 | # EXAMPLE: |
59 | 69 | # listeners = PLAINTEXT://your.host.name:9092 |
60 | 70 | #listeners=PLAINTEXT://:9092 |
| 71 | + listeners=OUTSIDE://:9094,PLAINTEXT://:9092 |
61 | 72 |
|
62 | 73 | # Hostname and port the broker will advertise to producers and consumers. If not set, |
63 | 74 | # it uses the value for "listeners" if configured. Otherwise, it will use the value |
64 | 75 | # returned from java.net.InetAddress.getCanonicalHostName(). |
65 | 76 | #advertised.listeners=PLAINTEXT://your.host.name:9092 |
| 77 | + #init#advertised.listeners=OUTSIDE://#init#,PLAINTEXT://:9092 |
66 | 78 |
|
67 | 79 | # Maps listener names to security protocols, the default is for them to be the same. See the config documentation for more details |
68 | 80 | #listener.security.protocol.map=PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL |
| 81 | + listener.security.protocol.map=PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL,OUTSIDE:PLAINTEXT |
| 82 | + inter.broker.listener.name=PLAINTEXT |
69 | 83 |
|
70 | 84 | # The number of threads that the server uses for receiving requests from the network and sending responses to the network |
71 | 85 | num.network.threads=3 |
|
0 commit comments