Neo4j: running in Kubernetes

By | 08/05/2020
 

In the previous post – Neo4j: graph database – run with Docker and Cypher QL examples – we’ve run the Neo4j database with в Docker.

The next task is to run it in the Kubernetes cluster.

Will use the Neo4j Community Edition, which will be running as a single-node instance as cluster ability for the Neo4j is available in the Enterprise version which is costs about 190.000 USD/year.

For the Community Edition, we can apply a Helm chart – neo4j-community.

Add its repository:

[simterm]

$ helm repo add equinor-charts https://equinor.github.io/helm-charts/charts/
"equinor-charts" has been added to your repositories

$ helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "equinor-charts" chart repository
...Successfully got an update from the "stable" chart repository
Update Complete. ⎈ Happy Helming!

[/simterm]

Deploy to a custom namespace, in this example, it’s eks-dev-1-neo4j.

With the --set accept its license, and add values for the  StorageClass of its PersistentVolume, and add a password for the administrator access:

[simterm]

$ helm upgrade --install --namespace eks-dev-1-neo4j --create-namespace neo4j-community equinor-charts/neo4j-community --set acceptLicenseAgreement=yes --set neo4jPassword=mySecretPassword --set persistentVolume.storageClass=gp2
Release "neo4j-community" does not exist. Installing it now.
NAME: neo4j-community
LAST DEPLOYED: Fri Jul 31 15:27:38 2020
NAMESPACE: eks-dev-1-neo4j
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
We'll need to wait a few seconds for Neo4j to start.

We need to see this line in our pod log:

> Remote interface available at Remote interface available at http://localhost:7474/

We can see the content of the logs by running the following command:

kubectl logs -l "app=neo4j-community"

[/simterm]

Okay – it’s deployed, check pods:

[simterm]

$ kk -n eks-dev-1-neo4j get pod
NAME                                READY   STATUS    RESTARTS   AGE
neo4j-community-neo4j-community-0   1/1     Running   0          29s

[/simterm]

Check its PersistentVolumeClaim:

[simterm]

$ kk -n eks-dev-1-neo4j get pvc
NAME                                        STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
datadir-neo4j-community-neo4j-community-0   Bound    pvc-29c5d6a0-34b7-4b5c-94d2-778139790a2d   10Gi       RWO            gp2            15m

[/simterm]

Check the corresponding PersistentVolume – pay attention, that we’ve created that PVC in the dynamic way, so it has the Reclaim policy set to Delete:

[simterm]

$ kk -n eks-dev-1-neo4j get pv pvc-29c5d6a0-34b7-4b5c-94d2-778139790a2d
NAME                                       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM                                                       STORAGECLASS   REASON   AGE
pvc-29c5d6a0-34b7-4b5c-94d2-778139790a2d   10Gi       RWO            Delete           Bound    eks-dev-1-neo4j/datadir-neo4j-community-neo4j-community-0   gp2                     16m

[/simterm]

Now, run port-forwarding to access the Neo4j server from your workstation:

[simterm]

$ kubectl -n eks-dev-1-neo4j port-forward neo4j-community-neo4j-community-0 7474:7474
Forwarding from 127.0.0.1:7474 -> 7474
Forwarding from [::1]:7474 -> 7474

[/simterm]

Check connection:

[simterm]

$ curl http://localhost:7474/db/data/
{
  "errors" : [ {
    "code" : "Neo.ClientError.Security.Unauthorized",
    "message" : "No authentication header supplied."
  } ]
}

[/simterm]

The server is ready for work.

Useful links