When using the official Neo4j Helm chart to deploy Neo4j into Kubernetes, it is possible to mount an existing Kubernetes PersistentVolume
into a Neo4j pod. This is achieved using the additionalVolumes
configuration.
The following example shows how this is achieved using Docker Desktop. This will need customising for specific cloud vendors. There are two example ymal manifests attached: one for creating the PV and PVC and, one to be used to install the Helm chart.
Given the following PersistentVolume
and PersistentVolumeClaim
apiVersion: v1
kind: PersistentVolume
metadata:
name: my-neo4j-pv
labels:
type: local
spec:
storageClassName: hostpath
capacity:
storage: 256Mi
accessModes:
- ReadWriteMany
hostPath:
path: /tmp
persistentVolumeReclaimPolicy: Retain
---
#
# PersistentVolumeClaim
#
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: my-neo4j-pvc
spec:
storageClassName: hostpath
accessModes:
- ReadWriteMany
resources:
requests:
storage: 256Mi
We can mount this into the container as follows
neo4j:
resources:
cpu: "1"
memory: "2Gi"
startupProbe:
failureThreshold: 1000
periodSeconds: 30
password: "password"
edition: "enterprise"
acceptLicenseAgreement: "yes"
# only required because we are running in Docker Desktop
podSpec:
podAntiAffinity: false
volumes:
data:
mode: defaultStorageClass
defaultStorageClass:
requests:
storage: 2Gi
additionalVolumes:
- name: test
persistentVolumeClaim:
claimName: "my-neo4j-pvc"
additionalVolumeMounts:
- mountPath: "/mnt/additionalVolume"
name: test
In the above, we see that the volume is mounted into the container's /mnt/additionalVolume
folder. This is shown in the following terminal output from inside the container
neo4j@neo4j-0:~$ ls -l /mnt
total 0
drwxrwxrwt 1 root root 60 Oct 30 09:59 additionalVolume
neo4j@neo4j-0:~$
Comments
0 comments
Article is closed for comments.