Skip to content

Commit 0e96487

Browse files
committed
Merge branch 'outside-services' into kubernetes-1.8-test
2 parents b533b29 + 4c202f4 commit 0e96487

File tree

5 files changed

+68
-0
lines changed

5 files changed

+68
-0
lines changed

10broker-config.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ data:
2222
else
2323
sed -i "s/#init#broker.rack=#init#/broker.rack=$ZONE/" /etc/kafka/server.properties
2424
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
2535
}
2636
2737
server.properties: |-
@@ -61,14 +71,18 @@ data:
6171
# EXAMPLE:
6272
# listeners = PLAINTEXT://your.host.name:9092
6373
#listeners=PLAINTEXT://:9092
74+
listeners=OUTSIDE://:9094,PLAINTEXT://:9092
6475
6576
# Hostname and port the broker will advertise to producers and consumers. If not set,
6677
# it uses the value for "listeners" if configured. Otherwise, it will use the value
6778
# returned from java.net.InetAddress.getCanonicalHostName().
6879
#advertised.listeners=PLAINTEXT://your.host.name:9092
80+
#init#advertised.listeners=OUTSIDE://#init#,PLAINTEXT://:9092
6981
7082
# Maps listener names to security protocols, the default is for them to be the same. See the config documentation for more details
7183
#listener.security.protocol.map=PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL
84+
listener.security.protocol.map=PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL,OUTSIDE:PLAINTEXT
85+
inter.broker.listener.name=PLAINTEXT
7286
7387
# The number of threads that the server uses for receiving requests from the network and sending responses to the network
7488
num.network.threads=3

50kafka.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ spec:
2525
valueFrom:
2626
fieldRef:
2727
fieldPath: spec.nodeName
28+
- name: POD_NAME
29+
valueFrom:
30+
fieldRef:
31+
fieldPath: metadata.name
32+
- name: POD_NAMESPACE
33+
valueFrom:
34+
fieldRef:
35+
fieldPath: metadata.namespace
2836
command: ['/bin/bash', '/etc/kafka/init.sh']
2937
volumeMounts:
3038
- name: config
@@ -37,6 +45,7 @@ spec:
3745
value: -Dlog4j.configuration=file:/etc/kafka/log4j.properties
3846
ports:
3947
- containerPort: 9092
48+
- containerPort: 9094
4049
command:
4150
- ./bin/kafka-server-start.sh
4251
- /etc/kafka/server.properties

outside-services/outside-0.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
kind: Service
2+
apiVersion: v1
3+
metadata:
4+
name: outside-0
5+
namespace: kafka
6+
spec:
7+
selector:
8+
app: kafka
9+
kafka-broker-id: "0"
10+
ports:
11+
- protocol: TCP
12+
targetPort: 9094
13+
port: 32400
14+
nodePort: 32400
15+
type: NodePort

outside-services/outside-1.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
kind: Service
2+
apiVersion: v1
3+
metadata:
4+
name: outside-1
5+
namespace: kafka
6+
spec:
7+
selector:
8+
app: kafka
9+
kafka-broker-id: "1"
10+
ports:
11+
- protocol: TCP
12+
targetPort: 9094
13+
port: 32401
14+
nodePort: 32401
15+
type: NodePort

outside-services/outside-2.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
kind: Service
2+
apiVersion: v1
3+
metadata:
4+
name: outside-2
5+
namespace: kafka
6+
spec:
7+
selector:
8+
app: kafka
9+
kafka-broker-id: "2"
10+
ports:
11+
- protocol: TCP
12+
targetPort: 9094
13+
port: 32402
14+
nodePort: 32402
15+
type: NodePort

0 commit comments

Comments
 (0)