Install APOC and Graph Algorithms on Neo4j running on Kubernetes

Running the enterprise distro (3.4.5) using Helm charts config and trying to install APOC and Graph Algorithms

I have tried to use the initiContainers in .yaml while installing using helm - but it does not seem to be pulling in the APOC.

Please post your initContainers YAML and the logs for the containers & initContainers. This lets others see what's going on and gives the chance of some advice.

Specify cluster domain (used eg. as suffix in definition of NEO4J_causal__clustering_initial__discovery__members environment variable)
clusterDomain: "cluster.local"

Specs for the images used for running tests against the Helm package

testImage: "markhneedham/k8s-kubectl"
testImageTag: "master"

Cores

core:
numberOfServers: 3
persistentVolume:
## whether or not persistence is enabled
##
enabled: true

## core server data Persistent Volume mount root path
##
mountPath: /data

## core server data Persistent Volume size
##
size: 10Gi

## core server data Persistent Volume Storage Class
## If defined, storageClassName: <storageClass>
## If set to "-", storageClassName: "", which disables dynamic provisioning
## If undefined (the default) or set to null, no storageClassName spec is
##   set, choosing the default provisioner.  (gp2 on AWS, standard on
##   GKE, AWS & OpenStack)
## storageClass: "-"

## Subdirectory of core server data Persistent Volume to mount
## Useful if the volume's root directory is not empty
##
## subPath: ""

Pass extra environment variables to the Neo4j container.

extraVars:

- name: EXTRA_VAR_1

value: extra-var-value-1

- name: EXTRA_VAR_2

value: extra-var-value-2

sidecarContainers:

Additional containers to be added to the Neo4j core pod.

- name: my-sidecar

image: nginx:latest

initContainers:

init containers to run before the Neo4j core pod e.g. to install plugins

- name: init-plugins

image: "appropriate/curl:latest"

imagePullPolicy: "IfNotPresent"

volumeMounts:

- name: plugins

mountPath: /plugins

command: [ "/bin/sh", "-c" , "curl -L https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/download/3.2.0.3/apoc-3.2.0.3-all.jar -O ; cp apoc-3.2.0.3-all.jar /plugins/ "]

Read Replicas

readReplica:
numberOfServers: 0

Pass extra environment variables to the Neo4j container.

extraVars:

- name: EXTRA_VAR_1

value: extra-var-value-1

- name: EXTRA_VAR_2

value: extra-var-value-2

sidecarContainers:

Additional containers to be added to the Neo4j replica pod.

- name: my-sidecar

image: nginx:latest

initContainers:

init containers to run before the Neo4j replica pod e.g. to install plugins

resources: {}

limits:

cpu: 100m

memory: 512Mi

requests:

cpu: 100m

memory: 512Mi

Logs from pod-0

Active database: graph.db
Directories in use:
home: /var/lib/neo4j
config: /var/lib/neo4j/conf
logs: /var/lib/neo4j/logs
plugins: /plugins
import: /var/lib/neo4j/import
data: /var/lib/neo4j/data
certificates: /var/lib/neo4j/certificates
run: /var/lib/neo4j/run
Starting Neo4j.
2019-07-17 17:42:09.245+0000 INFO ======== Neo4j 3.4.5 ========
2019-07-17 17:42:09.287+0000 INFO Starting...
2019-07-17 17:42:12.808+0000 INFO Initiating metrics...
2019-07-17 17:42:13.273+0000 INFO Resolved initial host 'neo4j-helm-neo4j.neo4j.svc.cluster.local:5000' to [100.96.1.26:5000]
2019-07-17 17:42:13.385+0000 INFO My connection info: [
Discovery: listen=0.0.0.0:5000, advertised=neo4j-helm-neo4j-core-0.neo4j-helm-neo4j.neo4j.svc.cluster.local:5000,
Transaction: listen=0.0.0.0:6000, advertised=neo4j-helm-neo4j-core-0.neo4j-helm-neo4j.neo4j.svc.cluster.local:6000,
Raft: listen=0.0.0.0:7000, advertised=neo4j-helm-neo4j-core-0.neo4j-helm-neo4j.neo4j.svc.cluster.local:7000,
Client Connector Addresses: bolt://neo4j-helm-neo4j-core-0.neo4j-helm-neo4j.neo4j.svc.cluster.local:7687,http://neo4j-helm-neo4j-core-0.neo4j-helm-neo4j.neo4j.svc.cluster.local:7474,https://neo4j-helm-neo4j-core-0.neo4j-helm-neo4j.neo4j.svc.cluster.local:7473
]
2019-07-17 17:42:13.391+0000 INFO Discovering cluster with initial members: [neo4j-helm-neo4j.neo4j.svc.cluster.local:5000]
2019-07-17 17:42:13.392+0000 INFO Attempting to connect to the other cluster members before continuing...
2019-07-17 17:46:50.569+0000 INFO Sending metrics to CSV file at /var/lib/neo4j/metrics
2019-07-17 17:46:50.749+0000 INFO Bolt enabled on 0.0.0.0:7687.
2019-07-17 17:46:53.614+0000 WARN Server thread metrics not available (missing neo4j.server.threads.jetty.all)
2019-07-17 17:46:53.617+0000 WARN Server thread metrics not available (missing neo4j.server.threads.jetty.idle)
2019-07-17 17:46:55.203+0000 INFO Started.
2019-07-17 17:46:55.496+0000 INFO Mounted REST API at: /db/manage
2019-07-17 17:46:55.598+0000 INFO Server thread metrics has been registered successfully
2019-07-17 17:46:56.860+0000 INFO Remote interface available at http://neo4j-helm-neo4j-core-0.neo4j-helm-neo4j.neo4j.svc.cluster.local:7474/

Hey, two concerns here -- things to look for.

  • You haven't included the logs of the initcontainer itself. This makes it not possible to see if APOC failed to download, or what's going on. What we're trying to determine is if the download happened, and if the resulting file is located in the /plugins director of your instance. I think this is not happening, because in your startup logs, I don't see any APOC messages I'd usually see.
  • Your YAML makes it look like you are using Mark Needham's old repo -- if this is correct you should probably be using this one and not the one I think you're using: charts/stable/neo4j at master · helm/charts · GitHub

David,

I am using the repo you have in your second point above - I have taken the generic values.yaml and modified from there

Just as a work around - it is possible to download the plugins into the container and then restart neo4j?

Manish

Yes, it is possible to download the plugins, but you wouldn't do this by restarting Neo4j. As soon as you lose the underlying data disk or do a different deploy, you'd be missing the plugin again. Additionally, you can't really restart the docker container, because the neo4j process and the docker container are the same thing so when the neo4j process stops, the docker container is no longer running.

What you can also do instead of initContainers is to build your own custom image of Neo4j which just layers the plugins on top in the right place. Here's an example:

If you go this route, then you'll just make your own version with whatever extras you need, and you will then deploy that container rather than the default Neo4j container.

I'm not sure if this may be the cause, but I've noticed that the first two numbers of your Neo4j version (3.4.5) is different from that of your APOC release (3.2.0.3).

According to the APOC user guide,

Make sure that the first two version numbers match between Neo4j and APOC .

You can find the list of releases here.

As an example, the following worked for me (Neo4j 3.5.5)

  initContainers:
  ## init containers to run before the Neo4j core pod e.g. to install plugins
  - name: init-plugins
    image: "appropriate/curl:latest"
    imagePullPolicy: "IfNotPresent"
    volumeMounts:
    - name: plugins
      mountPath: /plugins
    command:
      - "/bin/sh"
      - "-c"
      - |
        curl -L https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/download/3.5.0.2/apoc-3.5.0.2-all.jar -O
        cp apoc-3.5.0.2-all.jar /plugins/