Set up a RisingWave cluster in Kubernetes
This article will help you use the Kubernetes Operator for RisingWave (hereinafter ‘the Operator’) to deploy a RisingWave cluster in Kubernetes.
The Operator is a deployment and management system for RisingWave. It runs on top of Kubernetes and provides functionalities like provisioning, upgrading, scaling, and destroying the RisingWave instances inside the cluster.
Prerequisites
Ensure that the Kubernetes command-line tool
kubectl
is installed in your environment.Ensure that the PostgreSQL interactive terminal
psql
is installed in your environment.Ensure that Docker is installed in your environment and running.
Create a Kubernetes cluster
The steps in this section are intended for creating a Kubernetes cluster in your local environment.
If you are using a managed Kubernetes service such as AKS, GKE, and EKS, refer to the corresponding documentation for instructions.
Steps:
kind
is a tool for running local Kubernetes clusters using Docker containers as cluster nodes. You can see the available tags ofkind
on Docker Hub.Create a cluster.
kind create cluster
(Optional) Check if the cluster is created properly.
kubectl cluster-info
Deploy the Operator
Before the deployment, ensure that the following requirements are satisfied.
- Docker version ≥ 18.09
kubectl
version ≥ 1.18- For Linux, set the value of the
sysctl
parameternet.ipv4.ip_forward
to 1.
Steps:
Install the Operator.
kubectl apply -f https://github.com/risingwavelabs/risingwave-operator/releases/latest/download/risingwave-operator.yaml
(Optional) Check if the Pods are running.
kubectl -n cert-manager get pods
kubectl -n risingwave-operator-system get pods
Deploy a RisingWave instance
Select an object storage service for data persistence.
- etcd+MinIO
- etcd+S3
RisingWave supports using MinIO as the object storage.
Run the following command to deploy a RisingWave instance with MinIO as the object storage.
kubectl apply -f https://raw.githubusercontent.com/risingwavelabs/risingwave-operator/main/docs/manifests/risingwave/risingwave-etcd-minio.yaml
RisingWave supports using Amazon S3 as the object storage.
Steps:
Create a Secret with the name ‘s3-credentials’.
kubectl create secret generic s3-credentials --from-literal AccessKeyID=${ACCESS_KEY} --from-literal SecretAccessKey=${SECRET_ACCESS_KEY} --from-literal Region=${AWS_REGION}
On the S3 console, create a bucket with the name ‘hummock001’.
Deploy a RisingWave instance with S3 as the object storage.
kubectl apply -f https://raw.githubusercontent.com/risingwavelabs/risingwave-operator/main/docs/manifests/risingwave/risingwave-etcd-s3.yaml
You can check the status of the RisingWave instance by running the following command.
kubectl get risingwave
If the instance is running properly, the output should look like this:
- etcd+MinIO
- etcd+S3
NAME RUNNING STORAGE(META) STORAGE(OBJECT) AGE
risingwave-etcd-minio True etcd MinIO 30s
NAME RUNNING STORAGE(META) STORAGE(OBJECT) AGE
risingwave-etcd-s3 True etcd S3 30s
Connect to RisingWave
- ClusterIP
- NodePort
- LoadBalancer
By default, the Operator creates a service for the frontend component, through which you can interact with RisingWave, with the type of ClusterIP
. But it is not accessible outside Kubernetes. Therefore, you need to create a standalone Pod for PostgreSQL inside Kubernetes.
Steps:
Create a Pod.
kubectl apply -f https://raw.githubusercontent.com/risingwavelabs/risingwave-operator/main/docs/manifests/psql/psql-console.yaml
Attach to the Pod so that you can execute commands inside the container.
kubectl exec -it psql-console bash
Connect to RisingWave via
psql
.- etcd+MinIO
- etcd+S3
psql -h risingwave-etcd-minio-frontend -p 4567 -d dev -U root
psql -h risingwave-etcd-s3-frontend -p 4567 -d dev -U root
You can connect to RisingWave from Nodes such as EC2 in Kubernetes
Steps:
Set the Service type to
NodePort
.# ...
spec:
global:
serviceType: NodePort
# ...Connect to RisingWave by running the following commands on the Node.
- etcd+MinIO
- etcd+S3
export RISINGWAVE_NAME=risingwave-etcd-minio
export RISINGWAVE_NAMESPACE=default
export RISINGWAVE_HOST=`kubectl -n ${RISINGWAVE_NAMESPACE} get node -o jsonpath='{.items[0].status.addresses[?(@.type=="InternalIP")].address}'`
export RISINGWAVE_PORT=`kubectl -n ${RISINGWAVE_NAMESPACE} get svc -l risingwave/name=${RISINGWAVE_NAME},risingwave/component=frontend -o jsonpath='{.items[0].spec.ports[0].nodePort}'`
psql -h ${RISINGWAVE_HOST} -p ${RISINGWAVE_PORT} -d dev -U rootexport RISINGWAVE_NAME=risingwave-etcd-s3
export RISINGWAVE_NAMESPACE=default
export RISINGWAVE_HOST=`kubectl -n ${RISINGWAVE_NAMESPACE} get node -o jsonpath='{.items[0].status.addresses[?(@.type=="InternalIP")].address}'`
export RISINGWAVE_PORT=`kubectl -n ${RISINGWAVE_NAMESPACE} get svc -l risingwave/name=${RISINGWAVE_NAME},risingwave/component=frontend -o jsonpath='{.items[0].spec.ports[0].nodePort}'`
psql -h ${RISINGWAVE_HOST} -p ${RISINGWAVE_PORT} -d dev -U root
If you are using EKS, GCP, or other managed Kubernetes services provided by cloud vendors, you can expose the Service to the public network with a load balancer in the cloud.
Steps:
Set the Service type to
LoadBalancer
.# ...
spec:
global:
serviceType: LoadBalancer
# ...Connect to RisingWave with the following commands.
- etcd+MinIO
- etcd+S3
export RISINGWAVE_NAME=risingwave-etcd-minio
export RISINGWAVE_NAMESPACE=default
export RISINGWAVE_HOST=`kubectl -n ${RISINGWAVE_NAMESPACE} get svc -l risingwave/name=${RISINGWAVE_NAME},risingwave/component=frontend -o jsonpath='{.items[0].status.loadBalancer.ingress[0].ip}'`
export RISINGWAVE_PORT=`kubectl -n ${RISINGWAVE_NAMESPACE} get svc -l risingwave/name=${RISINGWAVE_NAME},risingwave/component=frontend -o jsonpath='{.items[0].spec.ports[0].port}'`
psql -h ${RISINGWAVE_HOST} -p ${RISINGWAVE_PORT} -d dev -U rootexport RISINGWAVE_NAME=risingwave-etcd-s3
export RISINGWAVE_NAMESPACE=default
export RISINGWAVE_HOST=`kubectl -n ${RISINGWAVE_NAMESPACE} get svc -l risingwave/name=${RISINGWAVE_NAME},risingwave/component=frontend -o jsonpath='{.items[0].status.loadBalancer.ingress[0].ip}'`
export RISINGWAVE_PORT=`kubectl -n ${RISINGWAVE_NAMESPACE} get svc -l risingwave/name=${RISINGWAVE_NAME},risingwave/component=frontend -o jsonpath='{.items[0].spec.ports[0].port}'`
psql -h ${RISINGWAVE_HOST} -p ${RISINGWAVE_PORT} -d dev -U root
You can now connect a streaming source to RisingWave and issue SQL queries to manage your data.