mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Merge pull request #7848 from Ocelot-Social-Community/more-scripts
chore(other): adjust docs for deployment, neo4j cypher commands, and have new scripts
This commit is contained in:
commit
9a68447a7e
@ -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`:
|
||||
|
||||
22
deployment/scripts/cluster.backend-bash.sh
Executable file
22
deployment/scripts/cluster.backend-bash.sh
Executable file
@ -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
|
||||
22
deployment/scripts/cluster.dashboard-token.sh
Executable file
22
deployment/scripts/cluster.dashboard-token.sh
Executable file
@ -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
|
||||
37
deployment/scripts/cluster.dashboard-tunnel.sh
Executable file
37
deployment/scripts/cluster.dashboard-tunnel.sh
Executable file
@ -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
|
||||
|
||||
|
||||
|
||||
22
deployment/scripts/cluster.neo4j-bash.sh
Executable file
22
deployment/scripts/cluster.neo4j-bash.sh
Executable file
@ -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
|
||||
@ -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 <context-name>
|
||||
kubectl config use-context <context-name>
|
||||
```
|
||||
|
||||
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.
|
||||
|
||||
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 access token.
|
||||
You may encounter a certificate warning, so make sure to override it.
|
||||
|
||||
## Alternatives to Kubernetes Dashboard
|
||||
|
||||
|
||||
@ -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 <docker-image-name('neo4j')>:/var/lib/neo4j/neo4j-dump <local-folder
|
||||
|
||||
If you need a specific database name, add the option `--database=<name>` 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](<https://neo4j.com/docs/operations-manual/4.4/docker/ref-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).
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user