skills/kubeblocks-vertical-scaling/SKILL.md
Scale CPU and memory resources for KubeBlocks database clusters via OpsRequest (vertical scaling). Supports in-place updates when the feature gate is enabled. Use when the user wants to change, increase, decrease, resize, or adjust CPU or memory resources of a database cluster. NOT for adding/removing replicas or shards (see horizontal-scaling) or expanding disk storage (see volume-expansion).
npx skillsauth add apecloud/kubeblocks-skills kubeblocks-vertical-scalingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Vertical scaling adjusts the CPU and memory resources allocated to a KubeBlocks database cluster. KubeBlocks performs rolling updates — secondary/replica pods are updated first, then the primary, to minimize downtime.
Official docs: https://kubeblocks.io/docs/preview/user_docs/kubeblocks-for-mysql/cluster-management/scale-a-mysql-cluster Full doc index: https://kubeblocks.io/llms-full.txt
Before proceeding, verify the cluster is healthy and no other operation is running:
# Cluster must be Running
kubectl get cluster <cluster-name> -n <namespace> -o jsonpath='{.status.phase}'
# No pending OpsRequests
kubectl get opsrequest -n <namespace> -l app.kubernetes.io/instance=<cluster-name> --field-selector=status.phase!=Succeed
If the cluster is not Running or has a pending OpsRequest, wait for it to complete before proceeding.
Check current resource allocations:
kubectl get cluster <cluster-name> -n <namespace> -o yaml | grep -A 4 resources
- [ ] Step 1: Check current resources
- [ ] Step 2: Apply vertical scaling OpsRequest
- [ ] Step 3: Monitor the operation
- [ ] Step 4: Verify new resources
kubectl get cluster <cluster-name> -n <namespace> -o yaml | grep -A 8 resources
Or inspect a specific pod:
kubectl get pod <cluster-name>-<component>-0 -n <namespace> -o jsonpath='{.spec.containers[0].resources}' | jq .
apiVersion: apps.kubeblocks.io/v1beta1
kind: OpsRequest
metadata:
name: verticalscaling-<cluster-name>
namespace: <namespace>
spec:
clusterName: <cluster-name>
type: VerticalScaling
verticalScaling:
- componentName: <component-name>
requests:
cpu: "<new-cpu-request>"
memory: "<new-memory-request>"
limits:
cpu: "<new-cpu-limit>"
memory: "<new-memory-limit>"
Before applying, validate with dry-run:
kubectl apply -f - --dry-run=server <<'EOF'
apiVersion: apps.kubeblocks.io/v1beta1
kind: OpsRequest
metadata:
name: verticalscaling-mysql-cluster
namespace: default
spec:
clusterName: mysql-cluster
type: VerticalScaling
verticalScaling:
- componentName: mysql
requests:
cpu: "2"
memory: "4Gi"
limits:
cpu: "2"
memory: "4Gi"
EOF
If dry-run reports errors, fix the YAML before proceeding.
kubectl apply -f - <<'EOF'
apiVersion: apps.kubeblocks.io/v1beta1
kind: OpsRequest
metadata:
name: verticalscaling-mysql-cluster
namespace: default
spec:
clusterName: mysql-cluster
type: VerticalScaling
verticalScaling:
- componentName: mysql
requests:
cpu: "2"
memory: "4Gi"
limits:
cpu: "2"
memory: "4Gi"
EOF
Before applying, validate with dry-run:
kubectl apply -f - --dry-run=server <<'EOF'
apiVersion: apps.kubeblocks.io/v1beta1
kind: OpsRequest
metadata:
name: verticalscaling-pg-cluster
namespace: default
spec:
clusterName: pg-cluster
type: VerticalScaling
verticalScaling:
- componentName: postgresql
requests:
cpu: "1"
memory: "2Gi"
limits:
cpu: "1"
memory: "2Gi"
EOF
If dry-run reports errors, fix the YAML before proceeding.
kubectl apply -f - <<'EOF'
apiVersion: apps.kubeblocks.io/v1beta1
kind: OpsRequest
metadata:
name: verticalscaling-pg-cluster
namespace: default
spec:
clusterName: pg-cluster
type: VerticalScaling
verticalScaling:
- componentName: postgresql
requests:
cpu: "1"
memory: "2Gi"
limits:
cpu: "1"
memory: "2Gi"
EOF
Component name reference:
- MySQL:
mysql- PostgreSQL:
postgresql- Redis:
redis- MongoDB:
mongodb- Kafka:
kafka-combine(combined) orkafka-broker/kafka-controller(separated)
For clusters with multiple components, add entries to the verticalScaling list:
spec:
verticalScaling:
- componentName: kafka-broker
requests:
cpu: "2"
memory: "4Gi"
limits:
cpu: "2"
memory: "4Gi"
- componentName: kafka-controller
requests:
cpu: "1"
memory: "2Gi"
limits:
cpu: "1"
memory: "2Gi"
Watch the OpsRequest status:
kubectl get ops verticalscaling-<cluster-name> -n <namespace> -w
Success condition:
.status.phase=Succeed| Typical: 1-5min | If stuck >10min:kubectl describe ops verticalscaling-<cluster-name> -n <namespace>
Expected progression: Pending → Running → Succeed.
Watch the cluster status:
kubectl get cluster <cluster-name> -n <namespace> -w
Success condition:
.status.phase=Running| Typical: 1-5min | If stuck >10min:kubectl describe cluster <cluster-name> -n <namespace>
The cluster status will transition: Running → Updating → Running.
Watch pods being rolling-restarted:
kubectl get pods -n <namespace> -l app.kubernetes.io/instance=<cluster-name> -w
Success condition:
.status.phase=Running| Typical: 1-5min | If stuck >10min:kubectl describe pod <pod-name> -n <namespace>
Rolling update order: KubeBlocks updates secondary/replica pods first, then the primary pod. This minimizes downtime by ensuring at least one instance is always serving.
After the OpsRequest succeeds:
kubectl get cluster <cluster-name> -n <namespace> -o yaml | grep -A 8 resources
Or check a pod directly:
kubectl get pod <cluster-name>-<component>-0 -n <namespace> -o jsonpath='{.spec.containers[0].resources}' | jq .
OpsRequest fails or is rejected:
kubectl describe ops <ops-name> -n <namespace>Running state before scaling.kubectl describe nodesPods stuck in Pending after scaling:
kubectl describe pod <pod-name> -n <namespace>Scaling takes too long:
For general agent safety conventions (dry-run, status confirmation, production protection), see safety-patterns.md.
devops
Expand persistent volume storage for KubeBlocks database clusters via OpsRequest. Requires the StorageClass to support volume expansion (allowVolumeExpansion=true). Use when the user needs more disk space, wants to increase storage, expand volumes, or resize PVCs. NOT for changing CPU/memory (see vertical-scaling) or adding more replicas (see horizontal-scaling). Note that volume shrinking is not supported by Kubernetes.
data-ai
Upgrade the KubeBlocks operator itself via Helm. Covers update operator, upgrade to v1.0, update kubeblocks version, and CRD updates. Use when the user wants to upgrade KubeBlocks, update the operator, or upgrade to a new KubeBlocks release. NOT for upgrading database engine versions (see minor-version-upgrade).
development
Diagnostic guide for KubeBlocks-managed database clusters. Use when the user reports troubleshoot, debug, diagnose, not working, error, failed, stuck, CrashLoopBackOff, cluster exception, or similar problems with their database cluster. This skill guides the agent through diagnostic steps — it does NOT perform actions.
data-ai
Perform planned primary-secondary switchover for KubeBlocks database clusters via OpsRequest. Promotes a replica to primary with minimal downtime. Use when the user wants to promote a replica, switch primary, change leader, perform a planned failover, or do maintenance on the current primary node. NOT for unplanned failover recovery (handled automatically by HA middleware like Patroni, Orchestrator, or Sentinel) or restarting all pods (see kubeblocks-cluster-lifecycle).