How it works

Before you begin
Create Kubernetes cluster
You can use the cloud-managed Kubernetes service, such as an Amazon Elastic Kubernetes Service (EKS) or Google Kubernetes Engine (GKE) cluster, or a self-managed Kubernetes cluster.-
Create an Amazon EKS cluster
- Check that the following command-line tools are installed in your environment:
- Install and configure AWS command-line tool AWS CLI.
- Install EKS cluster command-line tool eksctl.
- Install the Kubernetes cluster command-line tool kubectl.
- Use one of the following methods to create an EKS cluster:
- Check that the following command-line tools are installed in your environment:
- Create a GKE cluster Before you start to create a GKE cluster, make sure that you complete all the prerequisites. Then follow the instructions provided in Create a GKE cluster to create a GKE cluster.
- Create a self-managed Kubernetes cluster Follow the instructions provided in Bootstrapping clusters with kubeadm to create a self-managed Kubernetes cluster. You can use Minikube and Docker Desktop to create a single-node private Kubernetes cluster with minimum steps.
Deploy StarRocks Kubernetes Operator
-
Add the custom resource StarRocksCluster.
-
Deploy the StarRocks Operator. You can choose to deploy the StarRocks Operator by using a default configuration file or a custom configuration file.
-
Deploy the StarRocks Operator by using a default configuration file.
The StarRocks Operator is deployed to the namespace
starrocksand manages all StarRocks clusters under all namespaces. -
Deploy the StarRocks Operator by using a custom configuration file.
-
Download the configuration file operator.yaml, which is used to deploy the StarRocks Operator.
- Modify the configuration file operator.yaml to suit your needs.
-
Deploy the StarRocks Operator.
-
Download the configuration file operator.yaml, which is used to deploy the StarRocks Operator.
-
Deploy the StarRocks Operator by using a default configuration file.
-
Check the running status of the StarRocks Operator. If the pod is in the
Runningstate and all containers inside the pod areREADY, the StarRocks Operator is running as expected.
NOTE
If you customize the namespace in which the StarRocks Operator is located, you need to replacestarrocks with the name of your customized namespace.
Deploy Cluster
You can directly use the sample configuration files provided by the database to deploy a cluster (an object instantiated by using the custom resource Cluster). For example, you can use starrocks-fe-and-be.yaml to deploy a cluster that contains three FE nodes and three BE nodes.
You can also deploy the cluster by using a modified configuration file. For supported fields and detailed descriptions, see api.md.
Deploying the cluster takes a while. During this period, you can use the command
kubectl -n starrocks get pods to check the starting status of the cluster. If all the pods are in the Running state and all containers inside the pods are READY, the cluster is running as expected.
NOTE
If you customize the namespace in which the cluster is located, you need to replace starrocks with the name of your customized namespace.
kubectl logs -n starrocks <pod_name> to view the log information or use kubectl -n starrocks describe pod <pod_name> to view the event information to locate the problem.
Configure BE and CN core dump collection and restart behavior
The BE and CN container entrypoints can monitor, compress, and upload core dumps. They also support restarting the component for debugging. Configure the following environment variables on the BE or CN container:
Core dump collection requires
inotifywait, pigz, and rclone in the container image. The standard, non-minimal Ubuntu BE/CN image includes these commands. The minimal Ubuntu image and the UBI image do not include them. If collection is enabled and a required command is missing, the BE or CN refuses to start and reports the missing commands in the container log.
Manage Cluster
Access Cluster
The components of the cluster can be accessed through their associated Services, such as the FE Service. For detailed descriptions of Services and their access addresses, see api.md and Services. Note- Only the FE Service is deployed by default. If you need to deploy the BE Service and CN Service, you need to configure
starRocksBeSpecandstarRocksCnSpecin the cluster configuration file. - The name of a Service is
<cluster name>-<component name>-serviceby default, for example,starrockscluster-sample-fe-service. You can also specify the Service name in the spec of each component.
Access Cluster from within Kubernetes Cluster
From within the Kubernetes cluster, the cluster can be accessed through the FE Service’s ClusterIP.-
Obtain the internal virtual IP address
CLUSTER-IPand portPORT(S)of the FE Service. -
Access the cluster by using the MySQL client from within the Kubernetes cluster.
Access Cluster from outside Kubernetes Cluster
From outside the Kubernetes cluster, you can access the cluster through the FE Service’s LoadBalancer or NodePort. This topic uses LoadBalancer as an example:-
Run the command
kubectl -n starrocks edit src starrockscluster-sampleto update the cluster configuration file, and change the Service type ofstarRocksFeSpectoLoadBalancer. -
Obtain the IP address
EXTERNAL-IPand portPORT(S)that the FE Service exposes to the outside. -
Log in to your machine host and access the cluster by using the MySQL client.
Upgrade Cluster
Upgrade BE nodes
Run the following command to specify a new BE image file, such asstarrocks/be-ubuntu:latest:
Upgrade FE nodes
Run the following command to specify a new FE image file, such asstarrocks/fe-ubuntu:latest:
kubectl -n starrocks get pods to view the upgrade progress.
Scale cluster
Scale out BE cluster
Run the following command to scale the BE cluster to 9 nodes:Scale in BE cluster
When scaling in BE nodes, you need to scale them one at a time, and wait for the tablets on the BEs to be re-distributed before proceeding. If there are tables with single replicas, taking a BE node offline may cause data loss if the tablets fail to be redistributed. Execute the following command to scale in a cluster with 10 BE nodes to 9.alive status is false.
The redistribution of tablets will take some time. You can check the progress by executing SHOW PROC '/statistic';.
Scale out FE cluster
Run the following command to scale out the FE cluster to 4 nodes:kubectl -n starrocks get pods to view the scaling progress.
Automatic scaling for CN cluster
Run the commandkubectl -n starrocks edit src starrockscluster-sample to configure the automatic scaling policy for the CN cluster. You can specify the resource metrics for CNs as the average CPU utilization, average memory usage, elastic scaling threshold, upper elastic scaling limit, and lower elastic scaling limit. The upper elastic scaling limit and lower elastic scaling limit specify the maximum number and minimum number of CNs allowed for elastic scaling.
Note
If the automatic scaling policy for the CN cluster is configured, delete the replicas field from the starRocksCnSpec in the cluster configuration file.
Kubernetes also supports using behavior to customize scaling behaviors according to business scenarios, helping you achieve rapid or slow scaling or disable scaling. For more information about automatic scaling policies, see Horizontal Pod Scaling.
The following is a template provided by the database to help you configure automatic scaling policies:
- The upper and lower elastic scaling limit.
- The elastic scaling threshold.
FAQ
Issue description: When a custom resource StarRocksCluster is installed usingkubectl apply -f xxx, an error is returned The CustomResourceDefinition 'starrocksclusters.starrocks.com' is invalid: metadata.annotations: Too long: must have at most 262144 bytes.
Cause analysis: Whenever kubectl apply -f xxx is used to create or update resources, a metadata annotation kubectl.kubernetes.io/last-applied-configuration is added. This metadata annotation is in JSON format and records the last-applied-configuration. kubectl apply -f xxx” is suitable for most cases, but in rare situations , such as when the configuration file for the custom resource is too large, it may cause the size of the metadata annotation to exceed the limit.
Solution: If you install the custom resource StarRocksCluster for the first time, it is recommended to use kubectl create -f xxx. If the custom resource StarRocksCluster is already installed in the environment, and you need to update its configuration, it is recommended to use kubectl replace -f xxx.