<p>Basically I'm builing a system on google cloud. Most services are working on k8s cluster but some codes are not. Lambda and operator of composer, dataflow job are the examples. (Composer is also k8s but different cluster)</p>
<p>I picked kafka as event channel to interconnect the services and I have to decide proper place of kafka broker. K8s pods or VM. I prefer k8s pods, but I worry about the communication between brokers and services, espicially with services outside of k8s cluster.</p>
<blockquote>
<p>Consumer addresses broker with &quot;bootstrap server&quot; that is list of some broker's static unique address. I suppose if brokers are installed inside k8s, addresses of them will be not static unique from outside. Can brokers are connected from service outside of k8s? If possible, which string must be provided to bootstrap sever config?</p>
</blockquote>
<p>Conventional virtual machine is the solution without any suspicion. But I want put more and more things into k8s.</p>

<p>There are a different solutions to your problems</p>
<p>You can deploy the Kafka on K8s cluster and use the service mesh to interconnect both clusters. So broker and service can connect with each other without any worry.</p>
<p>If you are on GCP you can use the MCS service or traffic director and other service mesh.</p>
<p>You can also set up Kafka on <strong>VM</strong> and expose it over the IP and further that will be used by services to connect.</p>
<blockquote>
<p>Can brokers are connected from service outside of k8s?</p>
</blockquote>
<p>Yes, you can expose your Kafka broker using the service type Loadblanacer or Node Port. <a href="https://banzaicloud.com/blog/kafka-external-access/#:%7E:text=You%20can%20expose%20the%20Kafka,in%20the%20KafkaCluster%20custom%20resource.&amp;text=Above%2C%20externalListeners%20creates%20two%20external,are%20registered%20in%20the%20advertized." rel="nofollow noreferrer">Reference doc</a></p>
<blockquote>
<p>I suppose if brokers are installed inside k8s, addresses of them will
be not static unique from outside.</p>
</blockquote>
<p>You dont need to bind Kafka to any specific hostname for the interface, Kafka will listen to all the interfaces and you can expose it using the <strong>K8s service</strong> if running on K8s.</p>
