I'm working with Neo4j in Kubernetes. For a showcase, I want to fill the Neo4j in the Pods with initial data which i can do with a cypher-file, I'm having in the /bin
folder using the cypher-shell. So basically I start the container and run cat bin/initialData.cypher | bin/cypher-shell
. I've validated that this works by running it in the kubectl exec -it <pod> /bin/bash
bash. However, no matter how I try to map to the spec.container.command
, it fails. Currently my best guess is
spec:
containers:
command:
- /bin/bash
- -c
- |
cd bin
ls
cat initialData.cypher | cypher-shell
which does not work. It displays the ls
correctly but throws a connection refused
afterwards, where I have no idea where its coming from.
edit: Updated
Exec seems like the better way to handle this but you wouldn’t usually use both command and args. In this case, probably just put the whole thing in command.
I've found out what my problem was. I did not realize that the commands are not linked to the initialisation lifecycles meaning the command was executed, before the neo4j was started in the container. Basically, using the command was the wrong approach for me.
You did valid spec, but with a wrong syntax.
Try like this
spec:
containers:
command: ["/bin/bash"]
args: ["-c","cat import/initialData.cypher | bin/cypher-shell"]
Update: In your neo4j.conf you have to uncomment the lines related to using the neo4j-shell
# Enable a remote shell server which Neo4j Shell clients can log in to.
dbms.shell.enabled=true
# The network interface IP the shell will listen on (use 0.0.0.0 for all interfaces).
dbms.shell.host=127.0.0.1
# The port the shell will listen on, default is 1337.
dbms.shell.port=1337