Neo4j Causal Cluster on GKE


Dave Bennett 02/12/2016

I was inspired by Mark Needham’s post last week Kubernetes: Spinning up a Neo4j 3.1 Causal Cluster. I was going through this exact exercise myself and this really short circuited my learning curve. Mark left off that the next steps for him were to spin it up on both Google Container Engine (GKE) and AWS. He also wanted to add READ_REPLICA nodes into the mix. I couldn’t wait so I took what Mark had started with and built on it.

The CORE nodes can be separated from the EDGE nodes thus allowing each StatefulSet (PetSet) to be scaled in isolation.

First you will need s Google Compute Platform account. Google makes this a really easy, low risk free proposition with the free trial right now. They provide new contestants with a $300 USD credit for a 60 day trial. Once you are signed up you will want to check out the Google Container Engine (GKE) quickstart guide. You will need to enable billing (involves a credit card) and create a project to proceed.

Using the Google Cloud Shell, you can get away without installing anything locally. But if you are really committed you can downaload and install the Cloud SDK.

The first thing to do is to create a new cluster in Google Container Engine (GKE). This can be done via the command line or via the UI.

The following is the GKE Create Cluster url. The UI is very self explanatory.

NOTE: Of importance in creating a new cluster is enabling Kubernetes alpha feautures. Click on more and then select the alpha features check box.

Before it is created you can optionally click on command line at the bottom of the page to get the equivalent command line version of the UI options that you just selected

If you would rather create it via the command line and don’t want to go throug the UI at all, creating a new container cluster via the CLI can be done with something like the following.

The project id needs to be replaced with your actual project id but other than that change this command will create a cluster that you can use to run your Kubernetes Neo4j containers.

Now that the cluster of instances is set up all that is left to do is deploy the containers. This can be accomplished with the exact command Mark used and using Mark’s template.

This will bring up the same Neo4j Causal Core Cluster that Mark had in his example.

Now, say we want to add a few READ_REPLICA to the causal cluster. How do we achieve that? I started with Mark’s template and I added a new StatefulSet (née PetSet) section for the read reaplicas. After some trial and error I came up with the following template

I had to play around with the labels a bit to get the networking to work forwards and backwards between the two StatefulSets. I still need to understand this a little better but I ended up with two labels for each: “app” and “role”. Having a different “app” yielded an incomplete solution but if the “app” was the same and the “role” was ommitted it only worked partially too.

Now the cluster can be scaled horizontally with different StatefulSets (PetSets). The CORE nodes can be separated from the EDGE nodes thus allowing each StatefulSet (PetSet) to be scaled in isolation from the other(s). The following command scales the CORE PetSet.

While this one scales the EDGE petset.

The resulting scaled causal cluster can be easily viewed in the Neo4j browser using the kubectl port-forward.

No Results