David Allen
Jul 16 · 4 min read

Neo4j recently released a distribution of Neo4j Enterprise Causal Clustering on Pivotal Container Service (PKS). This distribution makes it easy to spin up a clustered, highly available graph database on top of Kubernetes quickly and easily.

Neo4j on Pivotal Container Service (PKS). Get it?

This article is going to describe what this is all about, and how to get started with it! To discuss and connect with other community members doing this, make sure to drop by the Neo4j Community Site’s cloud topic.

Getting Started

You can find Neo4j on Pivotal’s PivNet site here. You’ll want to start by downloading both artifacts, the Neo4j Docker image, and the Neo4j Helm Chart package. You’ll also want to check out the documentation that comes with it.

Neo4j on PivNet

Installing

The first thing to do is to load the downloaded docker image on to your local machine, like so:

$ docker load < causal-cluster_image.*.tgz
(...)
Loaded image: gcr.io/neo4j-pivotal/causal-cluster:3.5.7-master-eb023576dddee4f8cdc5afb6041c796f460f8a46

Next, unarchive the downloaded helm chart:

$ tar zxvf neo4j-3.5.7.tgz
x neo4j/Chart.yaml
x neo4j/values.yaml
x neo4j/templates/_helpers.tpl
x neo4j/templates/core-dns.yaml
x neo4j/templates/core-statefulset.yaml
x neo4j/templates/expanded.yaml
x neo4j/templates/poddisruptionbudget.yaml
x neo4j/templates/readreplica-dns.yaml
x neo4j/templates/readreplicas-statefulset.yaml
x neo4j/templates/secret.yaml
x neo4j/README.md
x neo4j/test.sh

Finally, we’ll use helm to install Neo4j as a package into our Kubernetes cluster. Take special note of the parameters being provided here and adjust according to your needs. For full descriptions of what these parameters do, and what your other options are, check the documentation.

Take special note of the image, and how it matches the loaded image above. Yours might differ depending on release you’re using, so make sure it’s right.

NAMESPACE=default
APP_NAME=my-neo4j-deploy
IMAGE=gcr.io/neo4j-pivotal/causal-cluster:3.5.7-master-eb023576dddee4f8cdc5afb6041c796f460f8a46

$ helm install neo4j --namespace $NAMESPACE --name $APP_NAME \
--set namespace=$NAMESPACE \
--set image=$IMAGE \
--set name=$APP_NAME \
--set neo4jPassword=mySecretPassword \
--set authEnabled=true \
--set coreServers=3 \
--set readReplicaServers=1 \
--set cpuRequest=200m \
--set memoryRequest=1Gi \
--set volumeSize=2Gi \
--set volumeStorageClass=standard \
--set acceptLicenseAgreement=yes
NAME: my-neo4j-deploy
LAST DEPLOYED: Tue Jul 16 11:25:19 2019
NAMESPACE: default
STATUS: DEPLOYED
RESOURCES:
==> v1/Secret
NAME TYPE DATA AGE
my-neo4j-deploy-neo4j-secrets Opaque 1 1s
==> v1/Service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
my-neo4j-deploy-neo4j ClusterIP None <none> 7474/TCP,7473/TCP,7687/TCP 1s
my-neo4j-deploy-neo4j-readreplica-svc ClusterIP None <none> 7474/TCP,7473/TCP,7687/TCP 1s
==> v1beta2/StatefulSet
NAME READY AGE
my-neo4j-deploy-neo4j-core 0/3 1s
my-neo4j-deploy-neo4j-replica 0/1 1s

You’ll see that helm outputs some messages related to the StatefulSets it is creating and the fact they’re not ready yet. We’ll need a few minutes for everything to come up happily. If you’re interested in a deeper breakdown of what resources are being created and how they all work together, read this article, which goes over how Neo4j works with Kubernetes.

Things are looking good

Where’s My Data?

Neo4j on PKS uses persistent volume claims of the size and storage class you specified when installing via helm. These PVCs in turn map to the /data directory inside of the pod. The actual container running is essentially Neo4j’s Standard Docker Container, for the purposes of understanding layout and configuration.

Neo4j stores data on Persistent Volume Claims

Once everything is up, you’ll see that the pods and StatefulSets are happy, and we’re ready to start using this cluster. Let’s run a cypher-shell against our new instance. The password we’re using is what we specified above on deploy.

The cypher-shell tool is provided in the container that ships with this, so connecting to your cluster is a matter of running that tool, and connecting to the right URL where your service is deployed.

APP_INSTANCE_NAME=my-neo4j-deploy
NEO4J_PASSWORD=mySecretPassword
kubectl run -it --rm cypher-shell \
--image=gcr.io/neo4j-pivotal/causal-cluster:3.5.7-master-eb023576dddee4f8cdc5afb6041c796f460f8a46 \
--restart=Never \
--namespace=default \
--command -- ./bin/cypher-shell -u neo4j \
-p "$NEO4J_PASSWORD" \
-a $APP_INSTANCE_NAME-neo4j.default.svc.cluster.local
If you don't see a command prompt, try pressing enter.Connected to Neo4j 3.5.7 at bolt://my-neo4j-deploy-neo4j.default.svc.cluster.local:7687 as user neo4j.Type :help for a list of available commands or :exit to exit the shell.Note that Cypher queries must end with a semicolon.neo4j> match (n) return count(n);+----------+
| count(n) |
+----------+
| 0 |
+----------+
1 row available after 276 ms, consumed after another 0 ms
neo4j> return apoc.version();
+----------------+
| apoc.version() |
+----------------+
| "3.5.0.3" |
+----------------+
1 row available after 2 ms, consumed after another 0 ms

Cleaning Up

When you’re done with a cluster, you can shut it down and remove all resources with a single easy command.

$ helm delete --purge my-neo4j-deploy
release "my-neo4j-deploy" deleted

Related Resources for Neo4j on Kubernetes

The following is a list of other articles and tutorials you may want to check out that will help with Neo4j on Kubernetes!

Neo4j Developer Blog

Developer Content around Graph Databases, Neo4j, Cypher, Data Science, Graph Analytics, GraphQL and more.

Thanks to Michael Hunger

David Allen

Written by

Neo4j Developer Blog

Developer Content around Graph Databases, Neo4j, Cypher, Data Science, Graph Analytics, GraphQL and more.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade