I was able to solve my problem by doing the following changes -
Using NodeSelector in YML to make kafka pod run on a particular node of kube cluster.
Set KAFKA_ADVERTISED_HOST_NAME
to Kube hostName where this Kafka POD has been configured to run on ( as configured in step 1 )
Expose Kafka Service using NodePort and set POD port same as that of exposed NodePort as shown below -
spec:
ports:
- name: broker-2
port: **30031**
targetPort: 9092
nodePort: **30031**
protocol: TCP
selector:
app: kafka-2
broker_id: "2"
type: NodePort
Now, you can access Kafka brokers from outside of kube cluster using host:exposedPort