I'm trying to setup a cluster for Neo4J version 4.0.1. I started with the official stable helm chart (more specifically I used an open PR [stable/neo4j] Neo4j fixes by srilumpa · Pull Request #20942 · helm/charts · GitHub because I'm on the latest version of K8s).
The first issue I experienced (which is not present in version 3.x) is related to Unable to run neo4j v4 casual cluster with docker-compose or docker swarm.
I managed to fix that by replacing all occurrences of $(hostname -f)
with $(hostname -I | awk '{print $1}')
.
Once that was fixed, I then tried to connect to the bolt server using the neo4j://
scheme. However I was getting:
{ Neo4jError: Could not perform discovery. No routing servers available. Known routing table: RoutingTable[database=default database, expirationTime=0, currentTime=1577183669630, routers=, readers=, writers=]
I tried the suggestion from this post Neo4jError: Could not perform discovery. No routing servers available - #2 by david.allen but it didn't fix the issue.
To give more details about the setup, I'm using an Ingress LB that forwards requests to a new service I created:
apiVersion: v1
kind: Service
metadata:
name: neo4j-external-access
labels:
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
app.kubernetes.io/instance: {{ .Release.Name | quote }}
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
app.kubernetes.io/name: {{ template "neo4j.name" . }}
app.kubernetes.io/component: core
spec:
type: ClusterIP
ports:
- name: http
port: 7474
targetPort: 7474
- name: bolt
port: 7687
targetPort: 7687
selector:
app.kubernetes.io/name: {{ template "neo4j.name" . }}
app.kubernetes.io/instance: {{ .Release.Name | quote }}
app.kubernetes.io/component: core
and the Ingress is as follows
- host: browser.domain.app
http:
paths:
- backend:
serviceName: neo4j-external-access
servicePort: 7474tcp
- host: bolt.domain.app
http:
paths:
- backend:
serviceName: neo4j-external-access
servicePort: 7687tcp
Finally, I'm using the following JS code (I use neo4j-driver v4.0.1) to connect to the bolt server:
const driver = neo4j.driver(
'neo4j://bolt.domain.app:443',
neo4j.auth.basic('neo4j', 'password'),
config
);
I tested the connection using the browser explorer and I still got the same error. The only way I could connect was using bolt://
instead of neo4j://
.
I searched for this issue, I've read this article Neo4j Considerations in Orchestration Environments | by David Allen | Neo4j Developer Blog | Medium, as well, but I can't find a solution.
Update
I had some progress which I want to share with you.
I ended up setting a unique bolt_advertised_address
for each of the pods. I did that by updating the statefulSet
manifest in the neo4j helm chart like this:
SET_INDEX=${HOSTNAME##*-}
export NEO4J_dbms_connector_bolt_advertised__address="bolt-$SET_INDEX.domain.app:443"
I also updated the ingress settings so it includes the above addresses.
I finally managed to the browser
explorer using neo4j://bolt-0.domain.app:443
.
However, I still get the same error when I'm trying to connect via the neo4j-driver
.
Cheers,
Pavlos