Getting Started with Helm Charts (ScalarDB Analytics with PostgreSQL)
This guide explains how to get started with ScalarDB Analytics with PostgreSQL by using a Helm Chart in a Kubernetes cluster as a test environment. In addition, the contents of this guide assume that you already have a Mac or Linux environment set up for testing. Although minikube is mentioned, the steps described should work in any Kubernetes cluster.
What you will create
You will deploy the following components in a Kubernetes cluster:
+-------------------------------------------------------------------------------------------------------------------------------------------+
| [Kubernetes cluster] |
| |
| [Pod] [Pod] [Pod] |
| |
| +------------------------------------+ |
| +---> | ScalarDB Analytics with PostgreSQL | ---+ +-----------------------------+ |
| | +------------------------------------+ | +---> | MySQL ("customer" schema) | <---+ |
| | | | +-----------------------------+ | |
| +-------------+ +---------+ | +------------------------------------+ | | | |
| | OLAP client | ---> | Service | ---+---> | ScalarDB Analytics with PostgreSQL | ---+---+ +---+ |
| +-------------+ +---------+ | +------------------------------------+ | | | | |
| | | | +-----------------------------+ | | |
| | +------------------------------------+ | +---> | PostgreSQL ("order" schema) | <---+ | |
| +---> | ScalarDB Analytics with PostgreSQL | ---+ +-----------------------------+ | |
| +------------------------------------+ | |
| | |
| +-------------+ | |
| | OLTP client | ---(Load sample data with a test OLTP workload)-----------------------------------------------------------------------+ |
| +-------------+ |
| |
+-------------------------------------------------------------------------------------------------------------------------------------------+
Step 1. Start a Kubernetes cluster
First, you need to prepare a Kubernetes cluster. If you're using a minikube environment, please refer to the Getting Started with Scalar Helm Charts. If you have already started a Kubernetes cluster, you can skip this step.
Step 2. Start MySQL and PostgreSQL pods
ScalarDB including ScalarDB Analytics with PostgreSQL can use several types of database systems as a backend database. In this guide, you will use MySQL and PostgreSQL.
You can deploy MySQL and PostgreSQL on the Kubernetes cluster as follows:
-
Add the Bitnami helm repository.
helm repo add bitnami https://charts.bitnami.com/bitnami
-
Update the helm repository.
helm repo update bitnami
-
Deploy MySQL.
helm install mysql-scalardb bitnami/mysql \
--set auth.rootPassword=mysql \
--set primary.persistence.enabled=false -
Deploy PostgreSQL.
helm install postgresql-scalardb bitnami/postgresql \
--set auth.postgresPassword=postgres \
--set primary.persistence.enabled=false -
Check if the MySQL and PostgreSQL pods are running.
kubectl get pod
You should see the following output:
NAME READY STATUS RESTARTS AGE
mysql-scalardb-0 1/1 Running 0 3m17s
postgresql-scalardb-0 1/1 Running 0 3m12s
Step 3. Create a working directory
Since you'll be creating some configuration files locally, create a working directory for those files.
mkdir -p ~/scalardb-analytics-postgresql-test/
Step 4. Set the versions of ScalarDB, ScalarDB Analytics with PostgreSQL, and the chart
Set the following three environment variables. If you want to use another version of ScalarDB and ScalarDB Analytics with PostgreSQL, be sure to set them to the versions that you want to use.
You must use the same minor versions (for example, 3.10.x) of ScalarDB Analytics with PostgreSQL as ScalarDB, but you don't need to make the patch versions match. For example, you can use ScalarDB 3.10.1 and ScalarDB Analytics with PostgreSQL 3.10.3 together.
SCALARDB_VERSION=3.10.1
SCALARDB_ANALYTICS_WITH_POSTGRESQL_VERSION=3.10.3
CHART_VERSION=$(helm search repo scalar-labs/scalardb-analytics-postgresql -l | grep -e ${SCALARDB_ANALYTICS_WITH_POSTGRESQL_VERSION} | awk '{print $2}' | sort --version-sort -r | head -n 1)
Step 5. Run OLTP transactions to load sample data to MySQL and PostgreSQL
Before deploying ScalarDB Analytics with PostgreSQL, run the OLTP transactions to create sample data.
-
Start an OLTP client pod in the Kubernetes cluster.
kubectl run oltp-client --image eclipse-temurin:8-jdk-jammy --env SCALARDB_VERSION=${SCALARDB_VERSION} -- sleep inf
-
Check if the OLTP client pod is running.
kubectl get pod oltp-client
You should see the following output:
NAME READY STATUS RESTARTS AGE
oltp-client 1/1 Running 0 17s -
Run bash in the OLTP client pod.
kubectl exec -it oltp-client -- bash
After this step, run each command in the OLTP client pod.
-
Install the git and curl commands in the OLTP client pod.
apt update && apt install -y curl git
-
Clone the ScalarDB samples repository.
git clone https://github.com/scalar-labs/scalardb-samples.git
-
Go to the directory
scalardb-samples/multi-storage-transaction-sample/
.cd scalardb-samples/multi-storage-transaction-sample/
pwd
You should see the following output:
# pwd
/scalardb-samples/multi-storage-transaction-sample -
Create a configuration file (
database.properties
) to access MySQL and PostgreSQL in the Kubernetes cluster.cat << 'EOF' > database.properties
scalar.db.storage=multi-storage
scalar.db.multi_storage.storages=storage0,storage1
# Storage 0
scalar.db.multi_storage.storages.storage0.storage=jdbc
scalar.db.multi_storage.storages.storage0.contact_points=jdbc:mysql://mysql-scalardb.default.svc.cluster.local:3306/
scalar.db.multi_storage.storages.storage0.username=root
scalar.db.multi_storage.storages.storage0.password=mysql
# Storage 1
scalar.db.multi_storage.storages.storage1.storage=jdbc
scalar.db.multi_storage.storages.storage1.contact_points=jdbc:postgresql://postgresql-scalardb.default.svc.cluster.local:5432/postgres
scalar.db.multi_storage.storages.storage1.username=postgres
scalar.db.multi_storage.storages.storage1.password=postgres
scalar.db.multi_storage.namespace_mapping=customer:storage0,order:storage1
scalar.db.multi_storage.default_storage=storage1
EOF -
Download Schema Loader from ScalarDB Releases.
curl -OL https://github.com/scalar-labs/scalardb/releases/download/v${SCALARDB_VERSION}/scalardb-schema-loader-${SCALARDB_VERSION}.jar
-
Run Schema Loader to create sample tables.
java -jar scalardb-schema-loader-${SCALARDB_VERSION}.jar --config database.properties --schema-file schema.json --coordinator
-
Load initial data for the sample workload.
./gradlew run --args="LoadInitialData"
-
Run the sample workload of OLTP transactions. Running these commands will create several
order
entries as sample data../gradlew run --args="PlaceOrder 1 1:3,2:2"
./gradlew run --args="PlaceOrder 1 5:1"
./gradlew run --args="PlaceOrder 2 3:1,4:1"
./gradlew run --args="PlaceOrder 2 2:1"
./gradlew run --args="PlaceOrder 3 1:1"
./gradlew run --args="PlaceOrder 3 2:1"
./gradlew run --args="PlaceOrder 3 3:1"
./gradlew run --args="PlaceOrder 3 5:1"