Launching Neo4j on Google’s Kubernetes Marketplace
At the recent Cloud Next ’18 conference, Google announced the availability of Kubernetes applications in GCP marketplace. The gist of this is that now applications can be installed into a Kubernetes cluster from the marketplace, without writing any YAML.
Neo4j was one of the launch partners for this, and so I wanted to show a bit of how this works in practice, and why it’s cool. Today we’ll go from “I don’t have a Kubernetes cluster” to running Cypher in Neo4j inside of a Kubernetes cluster in about 10 minutes or so. We will be using the Neo4j Marketplace Entry.
Create a GKE Cluster
Let’s start by creating a Google Kubernetes Engine (GKE) cluster. GKE is Google’s hosted Kubernetes service. Basically regular Kubernetes with a few nice add ons and a great management shell that works with the CLI.
Now that we’ve got that in place, we just look up Neo4j in the GCP marketplace, making sure to use the “Kubernetes Apps” filter. You can jump straight to the right spot with this link.
Clicking this tile leads to the product overview page, with a big “Configure” button on it, which we’re going to click. Also on that product overview page is a link to the Neo4j on GKE User Guide, which is hosted on Github along with all of the helm charts and templates needed to recreate what this product is doing, or customize it, depending on what you need.
Configuring our solution, setting up a clustered database is pretty easy, we just need to choose various settings. Most important is “server replicas” which controls how many core nodes are in your neo4j cluster, and read replicas. I’ll keep the defaults, but this is worth considering for capacity in your cluster. You’ll be starting a stateful set with at least server replicas + read replicas.
Because Neo4j prefers SSDs, as of this writing there is one manual step to do — click the “Cloud Shell” button near the bottom to set up solid state disk ability. If you’re familiar with Kubernetes, what that’s doing is creating a new storage class and applying the config to your cluster. The command is pre-populated, you just have to hit enter.
Alright, now we’re ready to roll, just click “Deploy” and immediately containers start getting scheduled onto your cluster. Google will take you to the “Applications” tab under your GKE cluster window to show you the status as things move along. Of course you can dive into any of these workloads and inspect individual container logs, status, and so on.
After your cluster has finished deployed, this is what the happy state looks like:
Wait, What’s My Password?
When neo4j gets deployed, a strong password is chosen for you and assigned, then stored in a kubernetes secret. You can get that directly through the GKE UI by choosing Configuration -> my-graph-neo4j-secrets and then looking at the neo4j-password field, or you can get it from kubectl like so in your cloud shell:
$ kubectl get secrets my-graph-neo4j-secrets -o yaml | grep neo4j-password: | sed 's/.*neo4j-password: *//' | base64 --decode
(Remember to replace “my-graph” with the name of your deploy)
You can now connect to the internal DNS address:
Where $APP_INSTANCE_NAME is the name of your deploy, and $NAMESPACE is the kubernetes namespace where it is deployed.
Creating a simple Cypher Shell
Launching a shell requires scheduling the solution container into your cluster, and running cypher-shell as its entrypoint, like so:
$ kubectl run -it --rm cypher-shell \
--command -- ./bin/cypher-shell -u neo4j \
-p "$NEO4J_PASSWORD" \
And you’re in business.
Make sure to check out the Neo4j on GKE User Guide on github for full details on how to use your instance, how to set up SSH forwarding to use Neo4j Browser, all of the templates you need to customize your own kubernetes/neo4j solution, and more.
If you have any other questions, please follow up with us on the Neo4j Community Site!
Happy graph hacking!