Kubernetes : Python + Neo4j Analytics Environment : Neo4j
Category : DevOps Tag : docker gds NoSQL kubernetes
April 18, 2022, 9:47 p.m.

Short Description :
How to use neo4j helm and deploy neo4j in local k8se (Minikube)
source : datak

<h2>Background</h2><p>Thye blog explains how to create a scaled analytics engironment for both python jupyter notebook and neo4j. This would be a solution in case you are in a following situation</p><ul><li>You won't be able to use typical cloud platform because of a company data policy, but you would need to prepare scaling platform by yourselves</li><li>You would liek to create microserviecs connecting each container with more customized way</li></ul><p><br></p><p>This blog mainly refers following links;</p><ul><li><a href="https://neo4j.com/docs/operations-manual/current/kubernetes/quickstart-standalone/" target="_blank">neo4j docs : Deploy a standalone instance</a><br></li><li><a href="https://medium.com/neo4j/deploying-neo4j-on-kubernetes-with-helm-charts-f08a53cdc2a6" target="_blank">medium : Deploying Neo4j on Kubernetes with Helm Charts</a><br></li></ul><p><br></p><h2>Neo4j helm chart</h2><p>Helm chart is a configuration management system, providing a prescriptive way of running products on Kubernetes, pulling down the required image and configurations. We are using <b>Neo4j standalone helm chart</b>, which is a single pod version. There is a Neo4j cluster helm chart, but this</p><p>According to the neo4j docs,</p><blockquote><p>In the standalone server setup, the user is responsible for defining a single yaml file, containing all the configurations for the neo4j standalone instance, and for running the `helm install my-neo4j-release neo4j/neo4j-standalone -f config.yaml` command to deploy the Neo4j DBMS. Then, the Neo4j Helm Chart creates Kubernetes entities needed for running and accessing Neo4j.</p></blockquote><p><img src="/media/django-summernote/2022-04-19/7a9db5a6-d3a6-4c63-a41c-7c5f05ced3e0.png" style="width: 850px;"></p><p><span style="font-size: 10px;">source :&nbsp;https://neo4j.com/docs/operations-manual/current/kubernetes/quickstart-standalone/server-setup/</span><br></p><p><br></p><h2>Prerequisite</h2><p>We will use Neo4j helm to deploy Neo4j to local kubernetes Minikube. You need to install followings to move on;</p><ol><li>Minikube</li><li>Kubectl</li><li>Helm</li></ol><p><br></p><h2>Deployment Procedure</h2><p>1. Start minikube</p><pre># shell minikube start minikube dashboard</pre><p>2. Create project directly</p><pre># shell mkdir neo4j-k8s &amp;&amp; cd neo4j-k8s</pre><p>3. Install Neo4j helm</p><pre># shell helm repo add neo4j <a href="https://helm.neo4j.com/neo4j" target="_blank">https://helm.neo4j.com/neo4j</a> helm repo update</pre><p>This would show output in shell like:</p><pre>Hang tight while we grab the latest from your chart repositories... ...Successfully got an update from the "neo4j" chart repository ...Successfully got an update from the "jupyterhub" chart repository Update Complete. ⎈Happy Helming!⎈<br></pre><p>You can check installed helm chart by:</p><pre># shell helm repo list</pre><p>4. Check name space</p><pre># shell kubectl get namespace</pre><p>Create namespace if you would like</p><pre># shell kubectl create namespace &lt;your new namespace&gt;</pre><p>Now set whatever namespace as the default context</p><pre># shell kubectl config set-context --current --namespace=&lt;type specific namespace from the list&gt;</pre><p>5. Create config file</p><pre># shell touch config.yaml</pre><pre># config.yaml neo4j: password: 1234 #resources: # cpu: 1 # memory: 5Gi #Neo4j Edition to use (community|enterprise) the default is #community so only change this if you have a license edition: “enterprise” #set edition: “enterprise” to use Neo4j Enterprise Edition #To use Neo4j Enterprise Edition you must have a Neo4j license #agreement. # #More information is also available at: neo4j.com/licensing #Email inquiries can be directed to: licensing@neo4j.com # #Set acceptLicenseAgreement: “yes” to confirm that you have a #Neo4j license agreement acceptLicenseAgreement: "yes" volumes: data: mode: “defaultStorageClass” #Neo4j configuration (yaml format) config: dbms.default_database: “neo4j” dbms.config.strict_validation: “true” </pre><p>6. Deploy neo4j from helm and config.yaml</p><pre># shell helm install &lt;RELEASE_NAME&gt; neo4j/neo4j-standalone --set volumes.data.mode=defaultStorageClass -f config.yaml</pre><p>You can put anything in &lt;RELEASE_NAME&gt;, for example, 'neo4j-k8s') but you have to remember</p><p>With the completion, you will see:</p><pre>NAME: tak-neo LAST DEPLOYED: Mon Apr 18 17:39:03 2022 NAMESPACE: default STATUS: deployed REVISION: 1 TEST SUITE: None NOTES: Thank you for installing neo4j-standalone. Your release "tak-neo" has been installed . The neo4j user's password has been set to "1234".To view the progress of the rollout try: $ kubectl rollout status --watch --timeout=600s statefulset/tak-neo Once rollout is complete you can log in to Neo4j at "neo4j://tak-neo.default.svc.cluster.local:7687". Try: $ kubectl run --rm -it --image "neo4j:4.4.5-enterprise" cypher-shell \ -- cypher-shell -a "neo4j://tak-neo.default.svc.cluster.local:7687" -u neo4j -p "1234" Graphs are everywhere!<br></pre><p><br></p><p>Wait for deploying this, and you will see pods in a certain namespace cluster</p><pre># shell kubectl get pod</pre><p>You will see something like:</p><pre>NAME READY STATUS RESTARTS AGE tak-neo-0 0/1 Running 2 50s<br></pre><p>7. Get external IP</p><p>Unlike jupyterHub, &lt;minikube IP&gt;:port does not work for some reason. Need to use port forwarding</p><pre># shell kubectl port-forward svc/&lt;RELEASE_NAME&gt; tcp-bolt tcp-http tcp-https</pre><p>Then you will get:</p><pre>Forwarding from 127.0.0.1:7687 -&gt; 7687 Forwarding from [::1]:7687 -&gt; 7687 Forwarding from 127.0.0.1:7474 -&gt; 7474 Forwarding from [::1]:7474 -&gt; 7474 Forwarding from 127.0.0.1:7473 -&gt; 7473 Forwarding from [::1]:7473 -&gt; 7473</pre><p><br></p><h2><span style="color: inherit; font-family: inherit;">Troubleshooting</span><br></h2><p>Official documents has lots of greats reference point</p><p><a href="https://neo4j.com/docs/operations-manual/current/kubernetes/troubleshooting/" target="_blank">document</a><br></p><p><br></p><h2>Customization and Miscellaneous</h2><p>All customization will be written in future blogs such as;</p><ol><li>How to add plugins such as apoc, graphdatascience, and bloom</li><li>How to add license for bloom</li><li>How to create persistent storage in Neo4j</li><li>How to graph apps to same k8s cluster</li></ol><p><br></p><p>Also below are how to uninstall deploymehnt</p><pre># shell helm uninstall &lt;RELEASE_NAME&gt;</pre><p>If you don't remember &lt;RELEASE_NAME&gt;,</p><pre># shell helm list</pre><p>then you will see existing deployment by helm like:</p><pre>NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION tak-jhub default 1 2022-04-16 23:30:35.983417 -0700 MST deployed jupyterhub-1.2.0 1.5.0</pre><p><br></p><p>how to upgrade helm chart after updating configuration</p><pre style="line-height: 1.42857;">#shell helm upgrade &lt;RELEASE_NAME&gt; neo4j/neo4j-standalone --set volumes.data.mode=defaultStorageClass -f config.yaml</pre><p style="line-height: 1.42857;">You might need to restart pod. Just killing existing pod will be re-created new pod</p><pre style="line-height: 1.42857;">#sell kubectl delete pod &lt;your pod name&gt;</pre>


<< Back to Blog Posts
Back to Home

Related Posts

Kubernetes : Deploy React Boiler
Apr 18 2022
Show how to deploy react app to local kubernetes/minikube using docker
Kubernetes : Control external IP by Ingress
Apr 18 2022
About Kubernetes Services
Kubernetes : Python + Neo4j Analytics Environment : JupyterHub
Apr 17 2022
How to use jupyterhub helm and deploy jupyterhub in local k8s (Minikube)
Kubernetes : Jupyterhub Customization
Apr 21 2022
Follow up from jupyterhub helm based deployment for a customization
Kubernetes : Rancher
Apr 21 2022
test
Kubernetes : Neo4j Customization
Apr 21 2022
Follow up from previous neo4j helm deployment for a customization



© DATAK 2024