Databases
SQL databases
You can easily create a database from the templates available in the DSRI OpenShift web UI catalog:
You can connect to a database from another application in the same project by using the database service name as hostname:
You can also use the oc
CLI to get the services in your project:
oc get services
Start PostgreSQL 🐘
Use the Postgresql template in the DSRI OpenShift web UI catalog to start a SQL database.
When the database has been deployed, you can connect from another pod using your favorite language and connector.
Example with the psql
Command Line Interface:
apt-get update && apt-get install postgresql-client -y
Connect to the Postgresql database using the service name (change depending on the username and database name you chose):
psql -h postgresql-db -U postgres db
Checkout the dsri-demo repository for a quick demo for accessing and using a PostgreSQL database from a Jupyter notebook on the DSRI.
Start MySQL 🐬
Use the MySQL template in the DSRI OpenShift web UI catalog.
When the database has been deployed, you can connect from another pod using your favorite language and connector.
Example with the mysql
Command Line Interface:
apt-get update && apt-get install mariadb-client -y
Connect to the MySQL database using the service name:
mysql -h example-mysql -p
Checkout the dsri-demo repository for a quick demo for accessing and using a MySQL database from a Jupyter notebook on the DSRI.
Alternatively, MySQL databases can be started using Helm, see the Helm documentation page for more details.
NoSQL databases
MongoDB 🌿
MongoDB is a general purpose, document-based, distributed database built for modern application developers and for the cloud era.
MongoDB can be deployed via Helm Chart as follows:
1) Install the Helm Client as explained in (https://dsri.maastrichtuniversity.nl/docs/helm)
2) Add the Bitnami Helm Repository. Bitnami offers a wide range of Helm charts, and you can add their repository with the following command:
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update
3) you can deploy MongoDB as follows:
helm install my-mongodb bitnami/mongodb
4) You can connect with my-mongodb as follows (within the cluster, for ex; via a terminal session opened at https://console-openshift-console.apps.dsri2.unimaas.nl/):
In the follwoing scripts, we assume that we are working with a project/namespace named as 'manu-test'. Replace this with your own project/namespace name. MongoDB can be accessed on the following DNS name(s) and ports from within your cluster:
my-mongodb.manu-test.svc.cluster.local
To get the root password run:
export MONGODB_ROOT_PASSWORD=$(kubectl get secret --namespace manu-test my-mongodb -o jsonpath="{.data.mongodb-root-password}" | base64 -d)
To connect to your database, create a MongoDB; client container:
kubectl run --namespace manu-test my-mongodb-client --rm --tty -i --restart='Never' --env="MONGODB_ROOT_PASSWORD=$MONGODB_ROOT_PASSWORD" --image docker.io/bitnami/mongodb:8.0.4-debian-12-r0 --command -- bash
Then, run the following command:
export MONGODB_ROOT_USER="root"
mongosh admin --host "my-mongodb" --authenticationDatabase admin --username $MONGODB_ROOT_USER --password $MONGODB_ROOT_PASSWORD
To connect to your database from outside the cluster execute the following commands:
kubectl port-forward --namespace manu-test svc/my-mongodb 27017:27017 &
mongosh --host 127.0.0.1 --authenticationDatabase admin --username $MONGODB_ROOT_USER --password $MONGODB_ROOT_PASSWORD
Redis 🎲
Redis is an advanced key-value cache and store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets, sorted sets, bitmaps and hyperlog.
Use the Redis template in the DSRI OpenShift web UI catalog.
Use the service name as hostname to connect from another pod in the same project.
Graph databases
OpenLink Virtuoso triplestore
Search for the Virtuoso triplestore template in the DSRI web UI catalog. Instantiate the template to create a Virtuoso triplestore in your project.
The deployment is based on the latest open source version of Virtuoso: https://hub.docker.com/r/openlink/virtuoso-opensource-7
Use the service name as hostname to connect from another pod in the same project.
Ontotext GraphDB triplestore
Use the official DockerHub image if you have an enterprise license. Or build GraphDB free edition image from graphdb-docker on GitHub.
After downloading the .zip
file from the github to your laptop, unzip it and go the graphdb-docker-master
folder in your terminal:
cd graphdb-docker-master
Before creating your GraphDB ImageStream, make sure you are in the right project:
oc project my-project
Create the ImageStream for GraphDB:
oc new-build --name graphdb --binary
Build the image on the DSRI and save it in the ImageStream:
oc start-build graphdb --from-dir=. --follow --wait
You can now use the Ontotext GraphDB template to deploy a GraphDB instance on DSRI.
Use the name of the ImageStream when instantiating the template, you can check if the image was properly built in Search > Filter Resources for ImageStreams
Use the service name as hostname to connect from another pod in the same project.