Exposing neo4j bolt port on Kubernetes cluster


I've installed neo4j after playing with it in Sandbox onto my Kubernetes cluster using the official stable/neo4j helm chart.

I would like to make this neo4j cluster accessible remotely (not just within the Kubernetes cluster) so I've written a service to expose the bolt port. The cluster has one LEADER & two FOLLOWER role servers, which is great for redundancy. However, when I try and access my service, it's a gamble as to whether I'll be served a LEADER or a FOLLOWER.

If I'm connected to a follower and I attempt a write, I get -

Neo.ClientError.Cluster.NotALeader: No write operations are allowed directly on this database. Writes must pass through the leader. The role of this server is: FOLLOWER

Here is my service -

apiVersion: v1
kind: Service
  name: pool1-neo4j-nodeport
  namespace: neo4j
  type: NodePort
  - port: 7687
    nodePort: 30725
    protocol: TCP
    app: neo4j
    component: core
    release: pool1

Am I missing something, is there something specific I need to do? I've also raised an issue on the Helm package.


This topic is covered in this article, under the subheading, "Looking at Neo4j from Outside of Kubernetes"

Additionally, "Querying Neo4j Clusters" will describe how all of this works, and why you're running into trouble. I recommend reading both -- they cover what's going on in your scenario, why it doesn't work, and also suggest possible approaches.

Thank you! I'll have a read!