Check whether the cluster status is Running
. Otherwise, the following operations may fail.
kubectl get cluster mycluster -n demo
>
NAME CLUSTER-DEFINITION VERSION TERMINATION-POLICY STATUS AGE
mycluster starrocks starrocks-3.1.1 Delete Running 4m29s
kbcli cluster list mycluster -n demo
>
NAME NAMESPACE CLUSTER-DEFINITION VERSION TERMINATION-POLICY STATUS CREATED-TIME
mycluster demo starrocks starrocks-3.1.1 Delete Running Jul 17,2024 19:06 UTC+0800
Apply an OpsRequest to the specified cluster. Configure the parameters according to your needs.
kubectl apply -f - <<EOF
apiVersion: apps.kubeblocks.io/v1alpha1
kind: OpsRequest
metadata:
name: mycluster-vertical-scaling
namespace: demo
spec:
clusterName: mycluster
type: VerticalScaling
verticalScaling:
- componentName: fe
requests:
memory: "2Gi"
cpu: "1"
limits:
memory: "4Gi"
cpu: "2"
EOF
Check the operation status to validate the vertical scaling.
kubectl get ops -n demo
>
NAMESPACE NAME TYPE CLUSTER STATUS PROGRESS AGE
demo mycluster-vertical-scaling VerticalScaling mycluster Succeed 3/3 6m
If an error occurs, you can troubleshoot with kubectl describe ops -n demo
command to view the events of this operation.
Check whether the corresponding resources change.
kubectl describe cluster mycluster -n demo
Change the configuration of spec.componentSpecs.resources
in the YAML file. spec.componentSpecs.resources
controls the requirement and limit of resources and changing them triggers a vertical scaling.
kubectl edit cluster mycluster -n demo
Edit the values of spec.componentSpecs.resources
.
...
spec:
clusterDefinitionRef: starrocks-ce
clusterVersionRef: starrocks-ce-3.1.1
componentSpecs:
- name: fe
componentDefRef: fe
replicas: 2
resources: # Change the values of resources
requests:
memory: "2Gi"
cpu: "1"
limits:
memory: "4Gi"
cpu: "2"
...
Check whether the corresponding resources change.
kubectl describe cluster mycluster -n demo
Set the --cpu
and --memory
values according to your needs and run the following command to perform vertical scaling.
kbcli cluster vscale mycluster -n demo --cpu=2 --memory=20Gi --components=be
Please wait a few seconds until the scaling process is over.
Validate the vertical scaling operation.
View the OpsRequest progress.
KubeBlocks outputs a command automatically for you to view the OpsRequest progress. The output includes the status of this OpsRequest and Pods. When the status is Succeed
, this OpsRequest is completed.
kbcli cluster describe-ops mycluster-verticalscaling-smx8b -n demo
Check the cluster status.
kbcli cluster list mycluster -n demo
>
NAME NAMESPACE CLUSTER-DEFINITION VERSION TERMINATION-POLICY STATUS CREATED-TIME
mycluster demo starrocks starrocks-3.1.1 Delete Updating Jul 17,2024 19:06 UTC+0800
To solve the problem, you can manually check whether this error is caused by insufficient resources. Then if AutoScaling is supported by the Kubernetes cluster, the system recovers when there are enough resources. Otherwise, you can create enough resources and troubleshoot with kubectl describe
command.
After the OpsRequest status is Succeed
or the cluster status is Running
again, check whether the corresponding resources change.
kbcli cluster describe mycluster -n demo
Horizontal scaling changes the amount of pods. For example, you can scale out replicas from three to five.
From v0.9.0, besides replicas, KubeBlocks also supports scaling in and out instances, refer to the Horizontal Scale tutorial for more details and examples.
Check whether the cluster status is Running
. Otherwise, the following operations may fail.
kubectl get cluster mycluster -n demo
>
NAME CLUSTER-DEFINITION VERSION TERMINATION-POLICY STATUS AGE
mycluster starrocks starrocks-3.1.1 Delete Running 4m29s
kbcli cluster list mycluster -n demo
>
NAME NAMESPACE CLUSTER-DEFINITION VERSION TERMINATION-POLICY STATUS CREATED-TIME
mycluster demo starrocks starrocks-3.1.1 Delete Running Jul 17,2024 19:06 UTC+0800
Apply an OpsRequest to a specified cluster. Configure the parameters according to your needs.
The example below means adding two replicas for the component fe
.
kubectl apply -f - <<EOF
apiVersion: apps.kubeblocks.io/v1alpha1
kind: OpsRequest
metadata:
name: mycluster-horizontal-scaling
namespace: demo
spec:
clusterName: mycluster
type: HorizontalScaling
horizontalScaling:
- componentName: fe
scaleOut:
replicaChanges: 2
EOF
If you want to scale in replicas, replace scaleOut
with scaleIn
.
The example below means deleting two replicas for the component fe
.
kubectl apply -f - <<EOF
apiVersion: apps.kubeblocks.io/v1alpha1
kind: OpsRequest
metadata:
name: mycluster-horizontal-scaling
namespace: demo
spec:
clusterName: mycluster
type: HorizontalScaling
horizontalScaling:
- componentName: fe
scaleIn:
replicaChanges: 2
EOF
Check the operation status to validate the horizontal scaling status.
kubectl get ops -n demo
>
NAMESPACE NAME TYPE CLUSTER STATUS PROGRESS AGE
demo mycluster-horizontal-scaling HorizontalScaling mycluster Succeed 3/3 6m
If an error occurs, you can troubleshoot with kubectl describe ops -n demo
command to view the events of this operation.
Check whether the corresponding resources change.
kubectl describe cluster mycluster -n demo
Change the configuration of spec.componentSpecs.replicas
in the YAML file. spec.componentSpecs.replicas
stands for the pod amount and changing this value triggers a horizontal scaling of a cluster.
kubectl edit cluster mycluster -n demo
Edit the values of spec.componentSpecs.replicas
.
...
spec:
clusterDefinitionRef: starrocks-ce
clusterVersionRef: starrocks-ce-3.1.1
componentSpecs:
- name: fe
componentDefRef: fe
replicas: 2 # Change this value
...
Check whether the corresponding resources change.
kubectl describe cluster mycluster -n demo
Configure the parameters --components
and --replicas
, and run the command.
kbcli cluster hscale mycluster --replicas=3 --components=be -n demo
--components
describes the component name ready for horizontal scaling.--replicas
describes the replica amount of the specified components. Edit the amount based on your demands to scale in or out replicas.Please wait a few seconds until the scaling process is over.
Validate the vertical scaling.
View the OpsRequest progress.
KubeBlocks outputs a command automatically for you to view the OpsRequest progress. The output includes the status of this OpsRequest and Pods. When the status is Succeed
, this OpsRequest is completed.
kbcli cluster describe-ops mycluster-horizontalscaling-ffp9p -n demo
View the cluster status.
kbcli cluster list mycluster -n demo
After the OpsRequest status is Succeed
or the cluster status is Running
again, check whether the corresponding resources change.
kbcli cluster describe mycluster -n demo