<p>I am attempting to deploy a Neo4j <a href="https://neo4j.com/docs/operations-manual/3.3/clustering/causal-clustering/" rel="nofollow noreferrer">causal cluster</a> in Kubernetes. I've followed <a href="https://github.com/neo4j-contrib/kubernetes-neo4j" rel="nofollow noreferrer">this guide</a> on Github, and deployed the cluster in Google Kubernetes Engine and it works as expected, i.e., the cluster replicates writes in the followers, and catch up in case of failure (deleting pods).</p>

<p>What I want to do next  is to expose this cluster to accessed from outside of it. </p>

<p>The challenge I'm facing is that, in order to connect to a remote causal cluster, I need to have a static name/IP address of any of the <code>CORE</code> servers, using the <code>bolt+routing</code> URI, so that the driver can route the requests accordingly (read, write, etc.).</p>

<p>As it's shown here, the <a href="https://github.com/neo4j-contrib/kubernetes-neo4j/blob/master/cores/dns.yaml" rel="nofollow noreferrer">service</a> is exposed as <code>ClusterIP</code> mode, so it's only accessible from within the cluster. I have attempted to change it to <code>NodePort</code> and <code>LoadBalancer</code> modes, and in those cases, the <code>CORE</code> Neo4j cluster members cannot find each other.</p>

<p>How can I keep the internal communication of the required ports (Raft, Transactions, etc.) and expose the <code>7687</code> (and possibly <code>7474</code> for browser) for external communication?</p>

<p>You can have multiple <code>Service</code>s for the same deployment in Kubernetes.</p>

<ul>
<li>have a <code>ClusterIP</code> Service, so nodes can continue to communicate with each oter.</li>
<li>have a <code>LoadBalancer</code> Service, so you can expose the public port to the Internet.</li>
</ul>

<p>If you’re looking to restrict internal communication <em>further</em>, you should look at Kubernetes Network Policies (but I doubt that's what you need). Some resources on this:</p>

<ul>
<li><a href="https://github.com/ahmetb/kubernetes-networkpolicy-tutorial" rel="nofollow noreferrer">https://github.com/ahmetb/kubernetes-networkpolicy-tutorial</a></li>
<li><a href="https://kubernetes.io/docs/concepts/services-networking/network-policies/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/services-networking/network-policies/</a></li>
<li><a href="https://cloud.google.com/kubernetes-engine/docs/how-to/network-policy" rel="nofollow noreferrer">https://cloud.google.com/kubernetes-engine/docs/how-to/network-policy</a> </li>
</ul>
