Neo4j: running in Kubernetes
Tags: kubernetes, database
Published: 2020-08-05 14:37:20

---
title: Neo4j: running in Kubernetes
published: true
date: 2020-08-05 08:58:58 UTC
tags: kubernetes,databases
canonical_url: https://itnext.io/neo4j-running-in-kubernetes-79633944f213
---

![](https://cdn-images-1.medium.com/max/1024/1*GZMkWmnz9GI1GfU5Zcu1CA.png)

In the previous post — [Neo4j: graph database — run with Docker and Cypher QL examples](https://rtfm.co.ua/en/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](https://hub.helm.sh/charts/equinor-charts/neo4j-community).

Add its repository:

```
$ helm repo add equinor-charts [https://equinor.github.io/helm-charts/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!
```

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`](https://rtfm.co.ua/en/kubernetes-persistentvolume-and-persistentvolumeclaim-an-overview-with-examples/#StorageClass) of its [`PersistentVolume`](https://rtfm.co.ua/en/kubernetes-persistentvolume-and-persistentvolumeclaim-an-overview-with-examples/), and add a password for the administrator access:

```
$ 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/](http://localhost:7474/)
We can see the content of the logs by running the following command:
kubectl logs -l “app=neo4j-community”
```

Okay -  it’s deployed, check pods:

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

Check its [`PersistentVolumeClaim`](https://rtfm.co.ua/en/kubernetes-persistentvolume-and-persistentvolumeclaim-an-overview-with-examples/):

```
$ 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
```

Check the corresponding [`PersistentVolume`](https://rtfm.co.ua/en/kubernetes-persistentvolume-and-persistentvolumeclaim-an-overview-with-examples/) — pay attention, that we’ve created that PVC in the dynamic way, so it has the Reclaim policy set to _Delete_:

```
$ 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
```

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

```
$ 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
```

Check connection:

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

The server is ready for work.

### Useful links

- [Neo4j-Helm User Guide](https://github.com/neo4j-contrib/neo4j-helm/blob/master/user-guide/USER-GUIDE.md)
- [Neo4j Considerations in Orchestration Environments](https://medium.com/neo4j/neo4j-considerations-in-orchestration-environments-584db747dca5)
- [How to backup Neo4j Running in Kubernetes](https://medium.com/neo4j/how-to-backup-neo4j-running-in-kubernetes-3697761f229a)
- [External Exposure of Neo4j Clusters](https://github.com/neo4j-contrib/neo4j-helm/blob/master/tools/external-exposure/EXTERNAL-EXPOSURE.md)

_Originally published at_ [_RTFM: Linux, DevOps и системное администрирование_](https://rtfm.co.ua/en/neo4j-running-in-kubernetes/)_._

* * *