Skip to main content
Upstream deployment example. This page uses community images, charts, or an upstream lab. Get Enterprise Edition installation files and confirm the supported image, chart, and operator versions for your release.

Goals

The goals of this quickstart are:
  • Deploy the StarRocks Kubernetes Operator and a cluster with Helm
  • Configure a password for the database user root
  • Provide for high-availability with three FEs and three BEs
  • Store metadata in persistent storage
  • Store data in persistent storage
  • Allow MySQL clients to connect from outside the Kubernetes cluster
  • Allow loading data from outside the Kubernetes cluster using Stream Load
  • Load some public datasets
  • Query the data
Tip The datasets and queries are the same as the ones used in the Basic Quick Start. The main difference here is deploying with Helm and the StarRocks Operator. The data used is provided by NYC OpenData and the National Centers for Environmental Information. Both of these datasets are large, and because this tutorial is intended to help you get exposed to working with the database we are not going to load data for the past 120 years. You can run this with a GKE Kubernetes cluster built on three e2-standard-4 machines (or similar) with 80GB disk. For larger deployments, we have other documentation and will provide that later. There is a lot of information in this document, and it is presented with step-by-step content at the beginning, and the technical details at the end. This is done to serve these purposes in this order:
  1. Get the system deployed with Helm.
  2. Allow the reader to load data in the database and analyze that data.
  3. Explain the basics of data transformation during loading.

Prerequisites



Kubernetes environment

The Kubernetes environment used while writing this guide consists of three nodes with four vCPUS, and 16GB RAM each (GCP e2-standard-4 machines). The Kubernetes cluster was deployed with this gcloud command: Tip This command is for your reference, if you are using AWS, Azure, or any other Kubernetes provider you will need to modify this for your environment. In Google Cloud you will need to specify your own project and an appropriate location.

Helm

Helm is a package manager for Kubernetes that simplifies the deployment and management of applications. In this lab you will use Helm to deploy the CelerData Enterprise Edition Kubernetes operator and the sample cluster. Install helm

SQL client

You can use the SQL client provided in the Kubernetes environment, or use one on your system. This guide uses the mysql CLI Many MySQL-compatible clients will work.

curl

curl is used to issue the data load job to the database, and to download the datasets. Check to see if you have it installed by running curl or curl.exe at your OS prompt. If curl is not installed, get curl here.

Terminology

FE

Frontend nodes are responsible for metadata management, client connection management, query planning, and query scheduling. Each FE stores and maintains a complete copy of metadata in its memory, which guarantees indiscriminate services among the FEs.

BE

Backend nodes are responsible for both data storage and executing query plans.

Add the database Helm chart repo

The Helm Chart contains the definitions of the StarRocks Operator and the custom resource StarRocksCluster.
  1. Add the Helm Chart Repo.
  2. Update the Helm Chart Repo to the latest version.
  3. View the Helm Chart Repo that you added.

Download the data

Download these two datasets to your machine.

New York City crash data

Weather data


Create a Helm values file

The goals for this quick start are:
  1. Configure a password for the database user root
  2. Provide for high-availability with three FEs and three BEs
  3. Store metadata in persistent storage
  4. Store data in persistent storage
  5. Allow MySQL clients to connect from outside the Kubernetes cluster
  6. Allow loading data from outside the Kubernetes cluster using Stream Load
The Helm chart provides options to satisfy all of these goals, but they are not configured by default. The rest of this section covers the configuration needed to meet all of these goals. A complete values spec will be provided, but first read the details for each of the six sections and then copy the full spec.

1. Password for the database user

This bit of YAML instructs the StarRocks operator to set the password for the database user root to the value of the password key of the Kubernetes secret `starrocks-root-pass.
  • Task: Create the Kubernetes secret

2. High Availability with 3 FEs and 3 BEs

By setting starrocks.starrockFESpec.replicas to 3, and starrocks.starrockBeSpec.replicas to 3 you will have enough FEs and BEs for high availability. Setting the CPU and memory requests low allows the pods to be created in a small Kubernetes environment.

3. Store metadata in persistent storage

Setting a value for starrocks.starrocksFESpec.storageSpec.name to anything other than "" causes:
  • Persistent storage to be used
  • the value of starrocks.starrocksFESpec.storageSpec.name to be used as the prefix for all storage volumes for the service.
By setting the value to fe these PVs will be created for FE 0:
  • fe-meta-kube-starrocks-fe-0
  • fe-log-kube-starrocks-fe-0

4. Store data in persistent storage

Setting a value for starrocks.starrocksBeSpec.storageSpec.name to anything other than "" causes:
  • Persistent storage to be used
  • the value of starrocks.starrocksBeSpec.storageSpec.name to be used as the prefix for all storage volumes for the service.
By setting the value to be these PVs will be created for BE 0:
  • be-data-kube-starrocks-be-0
  • be-log-kube-starrocks-be-0
Setting the storageSize to 15Gi reduces the storage from the default of 1Ti to fit smaller quotas for storage.

5. LoadBalancer for MySQL clients

By default, access to the FE service is through cluster IPs. To allow external access, service.type is set to LoadBalancer

6. LoadBalancer for external data loading

Stream Load requires external access to both FEs and BEs. The requests are sent to the FE and then the FE assigns a BE to process the upload. To allow the curl command to be redirected to the BE the starroclFeProxySpec needs to be enabled and set to type LoadBalancer.

The complete values file

The above snippets combined provide a full values file. Save this to my-values.yaml:

Set the database root database user password

To load data from outside of the Kubernetes cluster the database will be exposed externally. You should set a password for the database user root. The operator will apply the password to the FE and BE nodes.

Deploy the operator and cluster

Check the status of the cluster

You can check the progress with these commands:
Note The kube-starrocks-initpwd pod will go through error and CrashLoopBackOff states as it attempts to connect to the FE and BE pods to set the database root password. You should ignore these errors and wait for a status of Completed for this pod.

Verify that the cluster is healthy

Tip These are the same commands as above, but show the desired state.
Tip The system is ready when all of the pods except for kube-starrocks-initpwd show 1/1 in the READY column. The kube-starrocks-initpwd pod should show 0/1 and a STATUS of Completed.
The EXTERNAL-IP addresses in the highlighted lines will be used to provide SQL client and Stream Load access from outside the Kubernetes cluster.
Tip Store the EXTERNAL-IP addresses from the highlighted lines in environment variables so that you have them handy:

Connect to the database with a SQL client

Tip If you are using a client other than the mysql CLI, open that now. This command will run the mysql command in a Kubernetes pod:
If you have the mysql CLI installed locally, you can use it instead of the one in the Kubernetes cluster:

Create some tables



Create a database

Type these two lines in at the StarRocks > prompt and press enter after each:

Create two tables

Crashdata

The crash dataset contains many more fields than these, the schema has been trimmed down to include only the fields that might be useful to answer questions about the impact weather has on driving conditions.

Weatherdata

Similar to the crash data, the weather dataset has many more columns (a total of 125 columns) and only the ones that are expected to answer the questions are included in the database.
Exit from the MySQL client, or open a new shell to run commands at the command line to upload data.

Upload data

There are many ways to load data into the database. For this tutorial, the simplest way is to use curl and Stream Load. Upload the two datasets that you downloaded earlier. Tip Open a new shell as these curl commands are run at the operating system prompt, not in the mysql client. The commands refer to the datasets that you downloaded, so run them from the directory where you downloaded the files. Since this is a new shell, run the export commands again:
You will be prompted for a password. Use the password that you added to the Kubernetes secret starrocks-root-pass. If you used the command provided, the password is g()()dpa$$word. The curl commands look complex, but they are explained in detail at the end of the tutorial. For now, we recommend running the commands and running some SQL to analyze the data, and then reading about the data loading details at the end.

Connect with a MySQL client

Connect with a MySQL client if you are not connected. Remember to use the external IP address of the kube-starrocks-fe-service service and the password that you configured in the Kubernetes secret starrocks-root-pass.

Answer some questions



These queries can be run in your SQL client. All of the queries use the quickstart database.

How many crashes are there per hour in NYC?

Here is part of the output. Note that I am looking closer at January 6th and 7th as this is Monday and Tuesday of a non-holiday week. Looking at New Years Day is probably not indicative of a normal morning during rush-hour traffic.
It looks like about 40 accidents on a Monday or Tuesday morning during rush hour traffic, and around the same at 17:00 hours.

What is the average temperature in NYC?

Output: Note that this is data from 2014, NYC has not been this cold lately.

Is it safe to drive in NYC when visibility is poor?

Let’s look at the number of crashes when visibility is poor (between 0 and 1.0 miles). To answer this question use a JOIN across the two tables on the DATETIME column.
The highest number of crashes in a single hour during low visibility is 129. There are multiple things to consider:
  • February 3rd 2014 was a Monday
  • 8AM is rush hour
  • It was raining (0.12 inches or precipitation that hour)
  • The temperature is 32 degrees F (the freezing point for water)
  • Visibility is bad at 0.25 miles, normal for NYC is 10 miles

What about driving in icy conditions?

Water vapor can desublimate to ice at 40 degrees F; this query looks at temps between 0 and 40 degrees F.
The results for freezing temperatures suprised me a little, I did not expect too much traffic on a Sunday morning in the city on a cold January day.A quick look at weather.com showed that there was a big storm with many crashes that day, just like what can be seen in the data.
Drive carefully!

Cleanup

Run this command if you are finished and would like to remove the cluster and the StarRocks operator.

Summary

In this tutorial you:
  • Deployed the database with Helm and the StarRocks Operator
  • Loaded crash data provided by New York City and weather data provided by NOAA
  • Analyzed the data using SQL JOINs to find out that driving in low visibility or icy streets is a bad idea
There is more to learn; we intentionally glossed over the data transformation done during the Stream Load. The details on that are in the notes on the curl commands below.

Notes on the curl commands



Stream Load and curl take many arguments. Only the ones used in this tutorial are described here, the rest will be linked to in the more information section.

--location-trusted

This configures curl to pass credentials to any redirected URLs.

-u root

The username used to log in to the database

-T filename

T is for transfer, the filename to transfer.

label:name-num

The label to associate with this Stream Load job. The label must be unique, so if you run the job multiple times you can add a number and keep incrementing that.

column_separator:,

If you load a file that uses a single , then set it as shown above, if you use a different delimiter then set that delimiter here. Common choices are \t, ,, and |.

skip_header:1

Some CSV files have a single header row with all of the column names listed, and some add a second line with datatypes. Set skip_header to 1 or 2 if you have one or two header lines, and set it to 0 if you have none.

enclose:\"

It is common to enclose strings that contain embedded commas with double-quotes. The sample datasets used in this tutorial have geo locations that contain commas and so the enclose setting is set to \". Remember to escape the " with a \.

max_filter_ratio:1

This allows some errors in the data. Ideally this would be set to 0 and the job would fail with any errors. It is set to 1 to allow all rows to fail during debugging.

columns:

The mapping of CSV file columns to table columns. You will notice that there are many more columns in the CSV files than columns in the table. Any columns that are not included in the table are skipped. You will also notice that there is some transformation of data included in the columns: line for the crash dataset. It is very common to find dates and times in CSV files that do not conform to standards. This is the logic for converting the CSV data for the time and date of the crash to a DATETIME type:
The columns line
This is the beginning of one data record. The date is in MM/DD/YYYY format, and the time is HH:MI. Since DATETIME is generally YYYY-MM-DD HH:MI:SS we need to transform this data.
This is the beginning of the columns: parameter:
This instructs the database to:
  • Assign the content of the first column of the CSV file to tmp_CRASH_DATE
  • Assign the content of the second column of the CSV file to tmp_CRASH_TIME
  • concat_ws() concatenates tmp_CRASH_DATE and tmp_CRASH_TIME together with a space between them
  • str_to_date() creates a DATETIME from the concatenated string
  • store the resulting DATETIME in the column CRASH_DATE

More information

Default values.yaml Stream Load The Motor Vehicle Collisions - Crashes dataset is provided by New York City subject to these terms of use and privacy policy. The Local Climatological Data(LCD) is provided by NOAA with this disclaimer and this privacy policy. Helm is a package manager for Kubernetes. A Helm Chart is a Helm package and contains all of the resource definitions necessary to run an application on a Kubernetes cluster. starrocks-kubernetes-operator and kube-starrocks Helm Chart.