Neo4J Kubernetes Cluster deployment

Sanajit Ghosh
3 min readOct 29, 2020
Neo4j on Kubernetes with HA clusters
  1. Create a kubernetes cluster with azure cli(Recommended). Here you can choose the number of agent or the master nodes. You can refer this link https://docs.microsoft.com/en-us/azure/container-service/kubernetes/container-service-kubernetes-walkthrough for setting up kubernetes cluster in Azure.

2. Once it is done, the agents and the master nodes gets populated in the resource group of azure.

3. For installing the neo4j, the core servers need to be installed. Please refer to this link for installing “ git clone https://github.com/neo4j-contrib/kubernetes-neo4j.git”

4. Once it is installed make sure there is neo4j.yaml present. Changes in this file will affect the process of installation

· For bypassing the authentication process remove the remove the NEO4J_dbms_security_auth__enabled=”false” from the noe4j.yaml

· Alternatively change it from kubernetes/core/dns.yaml or stateful.yaml file. Uncomment the line where authentication is mentioned

5. Please make sure the following ports 7474,7687,6362 are exposed.

6. If “kubectl get pods “ fails to get the pod details ,update the version in the yaml file from 3.3.0 Enterprise Edition to latest.

7. Follow the remaining steps to deploy the neo4J

we can deploy a Neo4j cluster by executing the following command:

$ kubectl apply -f cores

service “neo4j” configured

statefulset “neo4j-core” created

We can check that Neo4j is up and running by checking the logs of our pods until we see the following line:

$ kubectl logs -l “app=neo4j”

2017–09–13 09:41:39.562+0000 INFO Remote interface available at

http://neo4j-core-2.neo4j.default.svc.cluster.local:7474/

We can query the topology of the Neo4j cluster by running the following command:

$ kubectl exec neo4j-core-0 — bin/cypher-shell — format verbose \

“CALL dbms.cluster.overview() YIELD id, role RETURN id, role”

+ — — — — — — — — — — — — — — — — — — — — — — — — — — -+

| id | role |

+ — — — — — — — — — — — — — — — — — — — — — — — — — — -+

| “719fa587–68e4–4194-bc61–8a35476a0af5” | “LEADER” |

| “bb057924-f304–4f6d-b726-b6368c8ac0f1” | “FOLLOWER” |

| “f84e7e0d-de6c-480e-8981-dad114de08cf” | “FOLLOWER” |

Note that security is disabled on these servers for demo purposes. If we’re using this in production, don’t leave the server unprotected.

Now let’s add some read replicas. We can do so by running the following command:

$ kubectl apply -f read-replicas

deployment “neo4j-replica” created

Now, the topology looks like:

$ kubectl exec neo4j-core-0 — bin/cypher-shell — format verbose \

“CALL dbms.cluster.overview() YIELD id, role RETURN id, role”

+ — — — — — — — — — — — — — — — — — — — — — — — — — — — — -+

| id | role |

+ — — — — — — — — — — — — — — — — — — — — — — — — — — — — -+

| “719fa587–68e4–4194-bc61–8a35476a0af5” | “LEADER” |

| “bb057924-f304–4f6d-b726-b6368c8ac0f1” | “FOLLOWER” |

| “f84e7e0d-de6c-480e-8981-dad114de08cf” | “FOLLOWER” |

| “8952d105–97a5–416b-9f61-b56ba44f3c02” | “READ_REPLICA” |

+ — — — — — — — — — — — — — — — — — — — — — — — — — — — — -+

--

--