From 7bfdc7d2fe524327af22ded29e098ab9c58ad5ef Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 17 Sep 2024 14:40:49 +0200 Subject: [PATCH 1/3] new scripts --- deployment/scripts/cluster.backend-bash.sh | 22 +++++++++++ deployment/scripts/cluster.dashboard-token.sh | 22 +++++++++++ .../scripts/cluster.dashboard-tunnel.sh | 37 +++++++++++++++++++ deployment/scripts/cluster.neo4j-bash.sh | 22 +++++++++++ 4 files changed, 103 insertions(+) create mode 100755 deployment/scripts/cluster.backend-bash.sh create mode 100755 deployment/scripts/cluster.dashboard-token.sh create mode 100755 deployment/scripts/cluster.dashboard-tunnel.sh create mode 100755 deployment/scripts/cluster.neo4j-bash.sh diff --git a/deployment/scripts/cluster.backend-bash.sh b/deployment/scripts/cluster.backend-bash.sh new file mode 100755 index 0000000000..251978f7d1 --- /dev/null +++ b/deployment/scripts/cluster.backend-bash.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# time stamp +printf "Neo4J bash :\n " +date + +# base setup +SCRIPT_PATH=$(realpath $0) +SCRIPT_DIR=$(dirname $SCRIPT_PATH) + +# check CONFIGURATION +if [[ -z "$CONFIGURATION" ]]; then + echo "!!! You must provide a CONFIGURATION via environment variable !!!" + exit 1 +fi + +printf " Cluster: %s\n" $CONFIGURATION + +# configuration +KUBECONFIG=${KUBECONFIG:-${SCRIPT_DIR}/../configurations/${CONFIGURATION}/kubeconfig.yaml} + +kubectl --kubeconfig=${KUBECONFIG} -n default exec -it $(kubectl --kubeconfig=${KUBECONFIG} -n default get pods | grep ocelot-backend | awk '{ print $1 }') -- /bin/sh \ No newline at end of file diff --git a/deployment/scripts/cluster.dashboard-token.sh b/deployment/scripts/cluster.dashboard-token.sh new file mode 100755 index 0000000000..4a3a553289 --- /dev/null +++ b/deployment/scripts/cluster.dashboard-token.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# time stamp +printf "Token :\n " +date + +# base setup +SCRIPT_PATH=$(realpath $0) +SCRIPT_DIR=$(dirname $SCRIPT_PATH) + +# check CONFIGURATION +if [[ -z "$CONFIGURATION" ]]; then + echo "!!! You must provide a CONFIGURATION via environment variable !!!" + exit 1 +fi + +printf " Cluster: %s\n" $CONFIGURATION + +# configuration +KUBECONFIG=${KUBECONFIG:-${SCRIPT_DIR}/../configurations/${CONFIGURATION}/kubeconfig.yaml} + +kubectl --kubeconfig=${KUBECONFIG} create token admin-user -n kubernetes-dashboard diff --git a/deployment/scripts/cluster.dashboard-tunnel.sh b/deployment/scripts/cluster.dashboard-tunnel.sh new file mode 100755 index 0000000000..126a0efe8e --- /dev/null +++ b/deployment/scripts/cluster.dashboard-tunnel.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +# time stamp +printf "Tunnel started at:\n " +date + +# base setup +SCRIPT_PATH=$(realpath $0) +SCRIPT_DIR=$(dirname $SCRIPT_PATH) + +# check CONFIGURATION +if [[ -z "$CONFIGURATION" ]]; then + echo "!!! You must provide a CONFIGURATION via environment variable !!!" + exit 1 +fi + +printf " Cluster: %s\n" $CONFIGURATION + +# configuration +KUBECONFIG=${KUBECONFIG:-${SCRIPT_DIR}/../configurations/${CONFIGURATION}/kubeconfig.yaml} + +kubectl --kubeconfig=${KUBECONFIG} get pods -n kubernetes-dashboard +#kubectl --kubeconfig=${KUBECONFIG} get -o json -n kubernetes-dashboard pod kubernetes-dashboard-kong-5ccb57895b-vxxmf + +# export POD_NAME=$(kubectl --kubeconfig=${KUBECONFIG} get pods -n kubernetes-dashboard -l "app.kubernetes.io/name=kubernetes-dashboard-kong,app.kubernetes.io/instance=kubernetes-dashboard" -o jsonpath="{.items[0].metadata.name}") +export POD_NAME=kubernetes-dashboard-kong-5ccb57895b-fzqk6 +# export POD_NAME=$(kubectl --kubeconfig=${KUBECONFIG} get pods -n kubernetes-dashboard -l "app.kubernetes.io/name=kubernetes-dashboard,app.kubernetes.io/instance=kubernetes-dashboard" -o jsonpath="{.items[0].metadata.name}") + +echo $POD_NAME +kubectl --kubeconfig=${KUBECONFIG} -n kubernetes-dashboard port-forward $POD_NAME 8443:8443 + +# kubectl --kubeconfig=${KUBECONFIG} -n kubernetes-dashboard create token admin-user + +# kubectl --kubeconfig=${KUBECONFIG} apply -f ${SCRIPT_DIR}/../scripts/admin-user.yml + + + diff --git a/deployment/scripts/cluster.neo4j-bash.sh b/deployment/scripts/cluster.neo4j-bash.sh new file mode 100755 index 0000000000..8ac7ed6bc7 --- /dev/null +++ b/deployment/scripts/cluster.neo4j-bash.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# time stamp +printf "Neo4J bash :\n " +date + +# base setup +SCRIPT_PATH=$(realpath $0) +SCRIPT_DIR=$(dirname $SCRIPT_PATH) + +# check CONFIGURATION +if [[ -z "$CONFIGURATION" ]]; then + echo "!!! You must provide a CONFIGURATION via environment variable !!!" + exit 1 +fi + +printf " Cluster: %s\n" $CONFIGURATION + +# configuration +KUBECONFIG=${KUBECONFIG:-${SCRIPT_DIR}/../configurations/${CONFIGURATION}/kubeconfig.yaml} + +kubectl --kubeconfig=${KUBECONFIG} -n default exec -it $(kubectl --kubeconfig=${KUBECONFIG} -n default get pods | grep ocelot-neo4j | awk '{ print $1 }') -- bash \ No newline at end of file From 5bc5ae68a8d588670d963664f88e48f6d71a2fa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Wed, 18 Sep 2024 09:25:33 +0200 Subject: [PATCH 2/3] Adjust docs for deployment, DigitalOcean, and neo4j cypher commands --- deployment/deployment.md | 11 +++++++++ deployment/src/kubernetes/DigitalOcean.md | 24 ++++++++++++++++--- neo4j/README.md | 28 +++++++++++++++++++++-- 3 files changed, 58 insertions(+), 5 deletions(-) diff --git a/deployment/deployment.md b/deployment/deployment.md index d2cb9b3b96..0105d296c3 100644 --- a/deployment/deployment.md +++ b/deployment/deployment.md @@ -81,6 +81,17 @@ $ scripts/cluster.backup.sh The backup will be saved into your network folders `backup` folder in a new folder with the date and time. +##### Default Database Name + +To execute this script, it may be necessary to set the default database name in Neo4j. + +In our deployments there are cases where the database is called `neo4j` (used by default) and in other cases `graph.db` (accidentally happened when we loaded the database into a new cluster). + +In the new deployment with Helm, we set the default database name by the environment variable `NEO4J_dbms_default__database` in the Helm `values.yaml`. +See [Docker-specific configuration settings](https://neo4j.com/docs/operations-manual/4.4/docker/ref-settings/) + +For more information see [Database Management Commands](/neo4j/README.md#database-management-commands). + #### Multiple Networks Backup In order to save several network backups locally, you must define the configuration names of all networks in `.env`. The template for this is `deployment/.env.dist`: diff --git a/deployment/src/kubernetes/DigitalOcean.md b/deployment/src/kubernetes/DigitalOcean.md index 8792ca43dd..251a6d3411 100644 --- a/deployment/src/kubernetes/DigitalOcean.md +++ b/deployment/src/kubernetes/DigitalOcean.md @@ -70,9 +70,14 @@ For authentication, download the current cluster configuration file from Digital Set the context of the cluster by command: ```bash -$ kubectl config use-context +kubectl config use-context ``` +We seem to have two instances in our DigitalOcean cluster how we need to log into the Kubernetes Dashboard. +It looks like it depends on the Kubernetes Dashboard version, but we are not absolutely sure. + +#### Login with `kubeconfig` File + Port-forward the Kubernetes Dashboard to your local machine: ```bash @@ -82,9 +87,22 @@ $ export POD_NAME=$(kubectl get pods -n kubernetes-dashboard -l "app.kubernetes. $ kubectl -n kubernetes-dashboard port-forward $POD_NAME 8443:8443 ``` -### Log-In to Kubernetes Dashboard +Access the URL in your local web browser at `https://127.0.0.1:8443/`, and log in using your Kubernetes cluster credentials – downloaded config file. +You may encounter a certificate warning, so make sure to override it. + +#### Login with Admin Token + +Port-forward the Kubernetes Dashboard to your local machine: + +```bash +# create your access token +kubectl -n kubernetes-dashboard create token admin-user +# forward port +kubectl -n kubernetes-dashboard port-forward svc/kubernetes-dashboard-kong-proxy 8443:443 +``` -Access the URL in your local web browser at `https://127.0.0.1:8443/`, and log in using your Kubernetes cluster credentials – downloaded config file. You may encounter a certificate warning, so make sure to override it. +Access the URL in your local web browser at `https://127.0.0.1:8443/`, and log in using your access token. +You may encounter a certificate warning, so make sure to override it. ## Alternatives to Kubernetes Dashboard diff --git a/neo4j/README.md b/neo4j/README.md index 58370c392e..7b5ab87236 100644 --- a/neo4j/README.md +++ b/neo4j/README.md @@ -32,7 +32,7 @@ and drop the `.jar` file into the `plugins` folder of the just extracted Neo4j-S Then make sure to allow Apoc procedures by adding the following line to your Neo4j configuration \(`conf/neo4j.conf`\): -``` +```text dbms.security.procedures.unrestricted=apoc.* ``` @@ -76,6 +76,8 @@ $ docker cp :/var/lib/neo4j/neo4j-dump ` to the command `neo4j-admin dump`. +In our deployments there are cases where the database is called `neo4j` (used by default) and in other cases `graph.db` (accidentally happened when we loaded the database into a new cluster). + ### Import Neo4j Dump To import a dump into Neo4j running in a Docker container: @@ -144,6 +146,23 @@ On a server with Kubernetes cluster: $ kubectl -n default exec -it $(kubectl -n default get pods | grep ocelot-backend | awk '{ print $1 }') -- /bin/sh -c "yarn prod:migrate init" ``` +***Enter and Exit Cypher Shell*** + +```bash +# enter the bash of Neo4j database +$ kubectl -n default exec -it $(kubectl -n default get pods | grep ocelot-neo4j | awk '{ print $1 }') -- bash +# enter Cypher-Shell to send Cypher commands +neo4j# cypher-shell + +# send Cypher commands +cypher-shell# < Cypher commands > +# exit Cypher-Shell +cypher-shell# :exit + +# exit bash +neo4j# exit +``` + ***Cypher commands to show indexes and constraints*** ```bash @@ -189,7 +208,12 @@ $ SHOW DEFAULT DATABASE $ SHOW DATABASES ``` -To set the default database by configuration, use `NEO4J_dbms_default__database` as an environment variable when starting Neo4j 4.4, see [Docker specific configuration settings](). +To set the default database by configuration, use `NEO4J_dbms_default__database` as an environment variable when starting Neo4j 4.4, see [Docker specific configuration settings](https://neo4j.com/docs/operations-manual/4.4/docker/ref-settings/). If a database with this name does not exist, an empty database with this name is created and all other databases remain. You can switch back to an existing database without damaging it. + +It seems to be impossible to change the name of an existing database on the fly. +To change the name of an existing database, we need to load a dump or restore a backup under a new name in Neo4j. + +For more information on deployment, see [Default Database Name](/deployment/deployment.md#default-database-name). From 374fd25793222311ff544edd28aaa1632687eeba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Wed, 18 Sep 2024 09:36:39 +0200 Subject: [PATCH 3/3] Fix mark down links to pass linting --- deployment/deployment.md | 2 +- neo4j/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/deployment/deployment.md b/deployment/deployment.md index 0105d296c3..52495ec44a 100644 --- a/deployment/deployment.md +++ b/deployment/deployment.md @@ -90,7 +90,7 @@ In our deployments there are cases where the database is called `neo4j` (used by In the new deployment with Helm, we set the default database name by the environment variable `NEO4J_dbms_default__database` in the Helm `values.yaml`. See [Docker-specific configuration settings](https://neo4j.com/docs/operations-manual/4.4/docker/ref-settings/) -For more information see [Database Management Commands](/neo4j/README.md#database-management-commands). +For more information see [Database Management Commands](../neo4j/README.md#database-management-commands). #### Multiple Networks Backup diff --git a/neo4j/README.md b/neo4j/README.md index 7b5ab87236..e9a700e7fc 100644 --- a/neo4j/README.md +++ b/neo4j/README.md @@ -216,4 +216,4 @@ You can switch back to an existing database without damaging it. It seems to be impossible to change the name of an existing database on the fly. To change the name of an existing database, we need to load a dump or restore a backup under a new name in Neo4j. -For more information on deployment, see [Default Database Name](/deployment/deployment.md#default-database-name). +For more information on deployment, see [Default Database Name](../deployment/deployment.md#default-database-name).