|
24 | 24 | fi |
25 | 25 |
|
26 | 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 |
27 | 35 | } |
28 | 36 |
|
29 | 37 | server.properties: |- |
@@ -63,14 +71,18 @@ data: |
63 | 71 | # EXAMPLE: |
64 | 72 | # listeners = PLAINTEXT://your.host.name:9092 |
65 | 73 | #listeners=PLAINTEXT://:9092 |
| 74 | + listeners=OUTSIDE://:9094,PLAINTEXT://:9092 |
66 | 75 |
|
67 | 76 | # Hostname and port the broker will advertise to producers and consumers. If not set, |
68 | 77 | # it uses the value for "listeners" if configured. Otherwise, it will use the value |
69 | 78 | # returned from java.net.InetAddress.getCanonicalHostName(). |
70 | 79 | #advertised.listeners=PLAINTEXT://your.host.name:9092 |
| 80 | + #init#advertised.listeners=OUTSIDE://#init#,PLAINTEXT://:9092 |
71 | 81 |
|
72 | 82 | # Maps listener names to security protocols, the default is for them to be the same. See the config documentation for more details |
73 | 83 | #listener.security.protocol.map=PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL |
| 84 | + listener.security.protocol.map=OUTSIDE:PLAINTEXT,PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL |
| 85 | + inter.broker.listener.name=PLAINTEXT |
74 | 86 |
|
75 | 87 | # The number of threads that the server uses for receiving requests from the network and sending responses to the network |
76 | 88 | num.network.threads=3 |
|
0 commit comments