Deploy NeoDash on Kubernetes

After we had the Neo4j database in place and started collecting data we tried to go for deeper analysis, primarily for communication to the management.

The Neo4j database comes with a web front-end. This front-end allows you to execute cypher-queries and displays the results as a table or text. For visualization there is also a graph tab displaying the queried graph-network. This is quite handy for ad-hoc analysis and also allows an overview of results on complex cypher queries.

So what is the problem?

When it comes to management we mainly have two problems with the Neo4j front-end. The first one is that the management doesn’t have knowledge of the data model designed by us. Therefore formulating individual queries to answer intended questions is hard and may result in wrong findings. In addition from a security perspective it is possible to alter the data model, which should be prevented. The second problem is that visualizations were not as convenient as with other tools the management are used to work with.

That’s when we set-up NeoDash a dashboard builder supporting Neo4j database. It is developed by the Neo4j Labs and therefore close to the database. The image can be pulled directly from Docker Hub. It supports building dashboards with maps, heatmaps, barcharts and tables but also direct KPIs, that can be delivered to management as is. The report is defined in JSON format including predefined cypher-queries.

This JSON definition will be either saved directly to the Neo4j database as a node or to a filesystem. We currently implemented the first option. But in the future the second option seems to be better for versioning the dashboard JSON file, since we are handling the front-end related files in a separate git project. This project includes the NeoDash deployment files and the JSON-report definitions. It supports us on following up changes that are made to the reports by different developers. With the help of a well configured pipeline the report should be distributed to all needed places.

Deploying NeoDash into Kubernetes

To develop new reports we currently use a local set-up and then deploy these new reports to our stand-alone report server. Be careful when editing the JSON-files: Prefer to use the NeoDash editor as this will result in a well formed syntax.

To run NeoDash, we need to set-up a service exposing the NeoDash dashboard front-end and a pod running the NeoDash Server in Kubernetes. We start the NeoDash server in standalone mode. That prevents users from making changes to the deployed reports. To configure this mode, we need to set the related environment variables. They predefine the connection to the database which doesn’t have to be inserted by the user any more. The NeoDash deployment definition will be as follows:

---
apiVersion: v1
kind: Service
metadata:
  name: neodash
spec:
  ports:
    - port: 5005
      name: neodash-port
  selector:
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: neodash
spec:
  template:
  metadata:
    labels:
      app.kubernetes.io/name: neodash
    spec:
      containers:
        - name: neodash
          image: neodash:2.2.0
          imagePullPolicy: Always
          ports:
            - containerPort: 5005
              name: neodash-port
          env:
            - name: standalone
              value: 'true'
            - name: standaloneProtocol
              value: 'neo4j+s'
            - name: standaloneHost
              value: 'neo4j-bolt.url'
            - name: standalonePort
              value: '443'
            - name: standaloneDatabase
              value: 'neo4j'
            - name: standaloneUsername
              value: 'neo4j'
            - name: standaloneDashboardName
              value: 'Dashboardname'
            - name: standaloneDashboardDatabase
              value: 'neo4j'
          resources:
            limits:
              cpu: 1000m   # 1 cpu
              memory: 8Gi
            requests:
              cpu: 50m   # 1/20 cpu
              memory: 1Gi

Remark: Since we are still running Neo4j community edition, we did not have multiuser handling. With our single administrative database user we ran the NeoDash server in standalone mode to only allow viewing the report but not edit it. Otherwise management could edit reports and even alter and delete database content. In the future we will add a user management e.g. Keykloak to manage access to the NeoDash dashboard.

Intrigued? There is a bonus article on visualizing and analysing Neo4j data using NeoDash.