You can change the resource requirements and limits (CPU and storage) by performing the vertical scale. For example, you can change the resource class from 1C2G to 2C4G.
This tutorial takes MySQL as an example to illustrate how to vertically scale a cluster.
NOTE
From v0.9.0, for MySQL and PostgreSQL, after vertical scaling is performed, KubeBlocks automatically matches the appropriate configuration template based on the new specification. This is the KubeBlocks dynamic configuration feature. This feature simplifies the process of configuring parameters, saves time and effort and reduces performance issues caused by incorrect configuration. For detailed instructions, refer to Configuration.
Before you start
Check whether the cluster status is Running. Otherwise, the following operations may fail.
kubectl get cluster mycluster
>
NAME CLUSTER-DEFINITION VERSION TERMINATION-POLICY STATUS AGE
mycluster mysql mysql-8.0.33 Delete Running 4d18h
Steps
There are two ways to apply vertical scaling.
Apply an OpsRequest to the specified cluster. Configure the parameters according to your needs.
Check the operation status to validate the vertical scaling.
kubectl get ops -n demo
>
NAMESPACE NAME TYPE CLUSTER STATUS PROGRESS AGE
demo ops-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.
kubectleditclustermycluster-ndemo
Edit the values of spec.componentSpecs.resources.
>...spec:clusterDefinitionRef:apecloud-mysqlclusterVersionRef:ac-mysql-8.0.30componentSpecs:-name:mysqlcomponentDefRef:mysqlreplicas:3resources:# Change the values of resourcesrequests:memory:"2Gi"cpu:"1"limits:memory:"4Gi"cpu:"2"...