risingwave

by apecloud

Helm chartv1.2.0-alpha.0App v1.0.0Verified publisher

RisingWave is a distributed SQL streaming database that enables cost-efficient and reliable processing of streaming data.

About this chart

RisingWave

RisingWave is a distributed SQL streaming database that enables cost-efficient and reliable processing of streaming data. There are multiple components in the RisingWave system, each with a specific role.

  • Meta node manages metadata and coordinates the system
  • Compute nodes handle stream processing and query execution
  • Compactor nodes manage data storage and compaction, and
  • Frontend node serves as the entry point for user interactions.

RisingWave has multiple Connectors, enabling integration with external data sources and sinks, facilitating data ingestion and export.

Such architecture allows RisingWave to provide real-time analytics and high-concurrent access to Materialized Views, making it suitable for a wide range of applications in the modern data ecosystem.

Features In KubeBlocks

Lifecycle Management

HorizontalscalingVertical scalingExpandvolumeRestartStop/StartConfigureExposeSwitchover
YesYesYesYesYesNoYesN/A

Versions

Major Versions
1.0

Prerequisites

  • Kubernetes cluster >= v1.21

  • kubectl installed, refer to K8s Install Tools

  • Helm, refer to Installing Helm

  • KubeBlocks installed and running, refer to Install Kubeblocks

  • RisingWave Addon Enabled, refer to Install Addons

  • [Optional] ETCD Addon and MinIO Addon Enabled

  • Create K8s Namespace demo, to keep resources created in this tutorial isolated:

    kubectl create ns demo
    

Examples

Create

Pre-requisites

Before creating the RisingWave cluster, ETCD and Object Storage endpoints are required. Here in this example, we use MinIO as the object storage and ETCD as the metadata store.

# cat examples/risingwave/etcd-cluster.yaml
apiVersion: apps.kubeblocks.io/v1
kind: Cluster
metadata:
  name: etcd-cluster
  namespace: demo
spec:
  terminationPolicy: Delete
  componentSpecs:
    - name: etcd
      componentDef: etcd
      serviceVersion: 3.5.15
      disableExporter: true
      replicas: 3
      resources:
        limits:
          cpu: "0.5"
          memory: "0.5Gi"
        requests:
          cpu: "0.5"
          memory: "0.5Gi"
      volumeClaimTemplates:
        - name: data
          spec:
            storageClassName: ""
            accessModes:
              - ReadWriteOnce
            resources:
              requests:
                storage: 20Gi
kubectl apply -f examples/risingwave/etcd-cluster.yaml # create etcd cluster
kubectl apply -f examples/risingwave/minio-cluster.yaml # create minio cluster

What for all Cluster running and get ETCD and Minio Endpoint:

  • ETCD endpoint:
# Get ETCD endpoint
ETCD_ENDPOINT="etcd-cluster-etcd-headless.demo.svc.cluster.local:2379"
# Get Minio endpoint
MINIO_ENDPOINT="minio-cluster-minio.demo.svc.cluster.local:9000"
# Get Minio user and password
MINIO_USER=$(kubectl get secret minio-cluster-minio-account-root -n demo -o jsonpath="{.data.username}" | base64 --decode)
MINIO_PASSWORD=$(kubectl get secret minio-cluster-minio-account-root -n demo -o jsonpath="{.data.password}" | base64 --decode)
# Create a Bucket `risingwave` in MinIO if not exists:
MINIO_BUCKET="<BUCKET_NAME>"

Port-forward the MinIO service first:

kubectl port-forward svc/minio-cluster-minio -n demo 9000:9000

Then, use the following command to create a bucket:

mc alias set minio http://localhost:9000 $MINIO_USER $MINIO_PASSWORD  # set minio alias
mc mb minio/${MINIO_BUCKET}  # create bucket
mc ls minio # list bucket

Create RisingWave Cluster

There are five components in the cluster, provisioned in the following order:

  • connector
  • meta
  • compactor, compute
  • frontend

[!IMPORTANT] Before applying the yaml file, please replace envs RW_STATE_STORE and RW_ETCD_ENDPOINTS with the actual values.

- name: RW_STATE_STORE
  value: hummock+minio://${ENV:MINIO_USER}:${ENV:MINIO_PASSWORD}@${ENV:MINIO_ENDPOINT}/${ENV:MINIO_BUCKET}
- name: RW_DATA_DIRECTORY
  value: /path/to/prefix
- name: RW_ETCD_ENDPOINTS
  value: ${ENV:ETCD_ENDPOINT}
# cat examples/risingwave/cluster.yaml
apiVersion: apps.kubeblocks.io/v1
kind: Cluster
metadata:
  name: risingwave-cluster
  namespace: demo
spec:
  terminationPolicy: Delete
  clusterDef: risingwave
  topology: cluster
  componentSpecs:
    - name: meta
      replicas: 1
      env:
        # Directory for storing data
        - name: RW_DATA_DIRECTORY
          value: prefix
        # MinIO username
        - name: MINIO_USER
          valueFrom:
            secretKeyRef:
              key: username
              name: minio-cluster-minio-account-root
        # MinIO password
        - name: MINIO_PASSWORD
          valueFrom:
            secretKeyRef:
              key: password
              name: minio-cluster-minio-account-root
        # MinIO bucket name
        - name: MINIO_BUCKET
          value: test-bucket
        # MinIO endpoint
        - name: MINIO_ENDPOINT
          value: minio-cluster-minio.demo.svc.cluster.local:9000
        # State store configuration
        - name: RW_STATE_STORE
          value: hummock+minio://$(MINIO_USER):$(MINIO_PASSWORD)@$(MINIO_ENDPOINT)/$(MINIO_BUCKET)
        # ETCD endpoints
        - name: RW_ETCD_ENDPOINTS
          value: etcd-cluster-etcd-headless.demo.svc.cluster.local:2379
        # ETCD authentication
        - name: RW_ETCD_AUTH
          value: "false"
        # Telemetry enable flag
        - name: ENABLE_TELEMETRY
          value: "false"
      resources:
        limits:
          cpu: "1"
          memory: 1Gi
        requests:
          cpu: 500m
          memory: 500Mi
      serviceVersion: v1.0.0
    - name: compactor
      env:
        # Directory for storing data
        - name: RW_DATA_DIRECTORY
          value: prefix
        # MinIO username
        - name: MINIO_USER
          valueFrom:
            secretKeyRef:
              key: username
              name: minio-cluster-minio-account-root
        # MinIO password
        - name: MINIO_PASSWORD
          valueFrom:
            secretKeyRef:
              key: password
              name: minio-cluster-minio-account-root
        # MinIO bucket name
        - name: MINIO_BUCKET
          value: test-bucket
        # MinIO endpoint
        - name: MINIO_ENDPOINT
          value: minio-cluster-minio.demo.svc.cluster.local:9000
        # State store configuration
        - name: RW_STATE_STORE
          value: hummock+minio://$(MINIO_USER):$(MINIO_PASSWORD)@$(MINIO_ENDPOINT)/$(MINIO_BUCKET)
        # Telemetry enable flag
        - name: ENABLE_TELEMETRY
          value: "false"
      replicas: 1
      resources:
        limits:
          cpu: "1"
          memory: 1Gi
        requests:
          cpu: 500m
          memory: 500Mi
      serviceVersion: v1.0.0
    - name: compute
      env:
        # Directory for storing data
        - name: RW_DATA_DIRECTORY
          value: prefix
        # MinIO username
        - name: MINIO_USER
          valueFrom:
            secretKeyRef:
              key: username
              name: minio-cluster-minio-account-root
        # MinIO password
        - name: MINIO_PASSWORD
          valueFrom:
            secretKeyRef:
              key: password
              name: minio-cluster-minio-account-root
        # MinIO bucket name
        - name: MINIO_BUCKET
          value: test-bucket
        # MinIO endpoint
        - name: MINIO_ENDPOINT
          value: minio-cluster-minio.demo.svc.cluster.local:9000
        # State store configuration
        - name: RW_STATE_STORE
          value: hummock+minio://$(MINIO_USER):$(MINIO_PASSWORD)@$(MINIO_ENDPOINT)/$(MINIO_BUCKET)
      replicas: 1
      resources:
        limits:
          cpu: "1"
          memory: 1Gi
        requests:
          cpu: 500m
          memory: 500Mi
      serviceVersion: v1.0.0
    - name: connector
      replicas: 1
      env:
        # Directory for storing data
        - name: RW_DATA_DIRECTORY
          value: prefix
        # MinIO username
        - name: MINIO_USER
          valueFrom:
            secretKeyRef:
              key: username
              name: minio-cluster-minio-account-root
        # MinIO password
        - name: MINIO_PASSWORD
          valueFrom:
            secretKeyRef:
              key: password
              name: minio-cluster-minio-account-root
        # MinIO bucket name
        - name: MINIO_BUCKET
          value: test-bucket
        # MinIO endpoint
        - name: MINIO_ENDPOINT
          value: minio-cluster-minio.demo.svc.cluster.local:9000
        # State store configuration
        - name: RW_STATE_STORE
          value: hummock+minio://$(MINIO_USER):$(MINIO_PASSWORD)@$(MINIO_ENDPOINT)/$(MINIO_BUCKET)
      resources:
        limits:
          cpu: "1"
          memory: 1Gi
        requests:
          cpu: 500m
          memory: 500Mi
      serviceVersion: v1.0.0
    - name: frontend
      env:
        # State store configuration
        - name: RW_STATE_STORE
          value: hummock+minio://$(MINIO_USER):$(MINIO_PASSWORD)@$(MINIO_ENDPOINT)/$(MINIO_BUCKET)
        # Directory for storing data
        - name: RW_DATA_DIRECTORY
          value: prefix
        # MinIO username
        - name: MINIO_USER
          valueFrom:
            secretKeyRef:
              key: username
              name: minio-cluster-minio-account-root
        # MinIO password
        - name: MINIO_PASSWORD
          valueFrom:
            secretKeyRef:
              key: password
              name: minio-cluster-minio-account-root
        # MinIO bucket name
        - name: MINIO_BUCKET
          value: test-bucket
        # MinIO endpoint
        - name: MINIO_ENDPOINT
          value: minio-cluster-minio.demo.svc.cluster.local:9000
      replicas: 1
      resources:
        limits:
          cpu: "1"
          memory: 1Gi
        requests:
          cpu: 500m
          memory: 500Mi
      serviceVersion: v1.0.0

kubectl apply -f examples/risingwave/cluster.yaml

Connect to RisingWave

Make sure RisingWave is up and running. To access RisingWave, you can expose the frontend service:

kubectl port-forward svc/risingwave-cluster-frontend -n demo 4567:4567

Then, use the following command in the terminal to connect to RisingWave using psql:

psql -h localhost -p 4566 -d dev -U root

Parameter Explanation:

  • -h: Specifies the hostname or IP address to connect to. The default is localhost.
  • -p: Specifies the port number that RisingWave is listening on. The default is 4566.
  • -d: Specifies the database name. The default is dev.
  • -U: Specifies the username. The default is root.

[!NOTE] By default, the root user does not require a password to connect to the database.

Create a Table

Here is an example from the RisingWave Quick Start

CREATE TABLE website_visits (
  timestamp timestamp with time zone,
  user_id varchar,
  page_id varchar,
  action varchar
);

This will create a table to store data related to website visits, where:

  • timestamp: Records the visit time, with the data type as a timestamp with time zone.
  • user_id: Records the user ID, with the data type as a variable-length string (varchar).
  • page_id: Records the page ID, with the data type as a variable-length string.
  • action: Records the user's action, such as viewing a page, with the data type as a variable-length string.

Insert Data

You can insert 5 rows of data into the website_visits table using the following SQL command:

INSERT INTO website_visits (timestamp, user_id, page_id, action) VALUES
  ('2023-06-13T10:00:00Z', 'user1', 'page1', 'view'),
  ('2023-06-13T10:01:00Z', 'user2', 'page2', 'view'),
  ('2023-06-13T10:02:00Z', 'user3', 'page3', 'view'),
  ('2023-06-13T10:03:00Z', 'user4', 'page1', 'view'),
  ('2023-06-13T10:04:00Z', 'user5', 'page2', 'view');

Verify the Inserted Data

After inserting the data, you can run the following query to verify the contents of the table:

SELECT * FROM website_visits;

The output should display:

timestampuser_idpage_idaction
2023-06-13 10:00:00+00user1page1view
2023-06-13 10:01:00+00user2page2view
2023-06-13 10:02:00+00user3page3view
2023-06-13 10:03:00+00user4page1view
2023-06-13 10:04:00+00user5page2view

Horizontal scaling

Scale-out

Horizontal scaling out risingwave compute component by adding ONE more replica:

# cat examples/risingwave/scale-out.yaml
apiVersion: operations.kubeblocks.io/v1alpha1
kind: OpsRequest
metadata:
  name: risingwave-scale-out
  namespace: demo
spec:
  # Specifies the name of the Cluster resource that this operation is targeting.
  clusterName: risingwave-cluster
  type: HorizontalScaling
  # Lists HorizontalScaling objects, each specifying scaling requirements for a Component, including desired total replica counts, configurations for new instances, modifications for existing instances, and instance downscaling options
  horizontalScaling:
    # Specifies the name of the Component.
    # - frontend
    # - compute
  - componentName: compute
    # Specifies the replica changes for scaling in components
    scaleOut:
      # Specifies the replica changes for the component.
      # add one more replica to current component
      replicaChang

Deploy risingwave with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has risingwave on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartrisingwave is pinned at v1.2.0-alpha.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply