Install kbcli if you want to manage the StarRocks cluster with kbcli
.
To keep things isolated, create a separate namespace called demo
throughout this tutorial.
kubectl create namespace demo
KubeBlocks implements a Cluster
CRD to define a cluster. Here is an example of creating a StarRocks cluster. If you only have one node for deploying a cluster with multiple replicas, configure the cluster affinity by setting spec.schedulingPolicy
or spec.componentSpecs.schedulingPolicy
. For details, you can refer to the API docs. But for a production environment, it is not recommended to deploy all replicas on one node, which may decrease the cluster availability.
cat <<EOF | kubectl apply -f -
apiVersion: apps.kubeblocks.io/v1
kind: Cluster
metadata:
name: mycluster
namespace: demo
spec:
terminationPolicy: Delete
componentSpecs:
- name: fe
componentDef: starrocks-ce-fe
serviceAccountName: kb-starrocks-cluster
replicas: 1
resources:
limits:
cpu: '1'
memory: 1Gi
requests:
cpu: '1'
memory: 1Gi
- name: be
componentDef: starrocks-ce-be
replicas: 2
resources:
limits:
cpu: '1'
memory: 1Gi
requests:
cpu: '1'
memory: 1Gi
volumeClaimTemplates:
- name: data
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
EOF
Field | Definition |
---|---|
spec.terminationPolicy | It is the policy of cluster termination. Valid values are DoNotTerminate , Delete , WipeOut . For the detailed definition, you can refer to Termination Policy. |
spec.componentSpecs | It is the list of ClusterComponentSpec objects that define the individual Components that make up a Cluster. This field allows customized configuration of each component within a cluster. Note: shardingSpecs and componentSpecs cannot both be empty; at least one must be defined to configure a cluster. ClusterComponentSpec defines the specifications for a Component in a Cluster. |
spec.componentSpecs.replicas | It specifies the number of replicas of the component. |
spec.componentSpecs.resources | It specifies the resources required by the Component. |
spec.componentSpecs.volumeClaimTemplates | It specifies a list of PersistentVolumeClaim templates that define the storage requirements for the Component. |
spec.componentSpecs.volumeClaimTemplates.name | It refers to the name of a volumeMount defined in componentDefinition.spec.runtime.containers[*].volumeMounts . |
spec.componentSpecs.volumeClaimTemplates.spec.storageClassName | It is the name of the StorageClass required by the claim. If not specified, the StorageClass annotated with storageclass.kubernetes.io/is-default-class=true will be used by default. |
spec.componentSpecs.volumeClaimTemplates.spec.resources.storage | You can set the storage size as needed. |
For more API fields and descriptions, refer to the API Reference.
KubeBlocks operator watches for the Cluster
CRD and creates the cluster and all dependent resources. You can get all the resources created by the cluster with kubectl get all,secret,rolebinding,serviceaccount -l app.kubernetes.io/instance=mycluster -n demo
.
kubectl get all,secret,rolebinding,serviceaccount -l app.kubernetes.io/instance=mycluster -n demo
Run the following command to see the created StarRocks cluster object:
kubectl get cluster mycluster -n demo -o yaml