skills/kubeblocks-cluster-lifecycle/SKILL.md
Manage KubeBlocks cluster lifecycle: stop, start, and restart database clusters via OpsRequest. Stopping terminates pods while retaining PVCs for cost savings. Use when the user wants to stop, start, restart, pause, resume, or shut down a database cluster temporarily. NOT for deleting a cluster permanently (see delete-cluster) or for scaling operations (see vertical-scaling, horizontal-scaling).
npx skillsauth add apecloud/kubeblocks-skills kubeblocks-cluster-lifecycleInstall 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.
KubeBlocks supports stopping, starting, and restarting database clusters through OpsRequest CRs. Stopping a cluster terminates all pods while retaining PVCs, allowing cost savings when the cluster is not in use.
Official docs: https://kubeblocks.io/docs/preview/user_docs/maintenance/stop-start-a-cluster Full doc index: https://kubeblocks.io/llms-full.txt
- [ ] Step 1: Check current cluster status
- [ ] Step 2: Apply the lifecycle operation (Stop / Start / Restart)
- [ ] Step 3: Verify the operation
kubectl get cluster <cluster-name> -n <namespace>
| Status | Meaning |
|--------|---------|
| Running | Cluster is healthy and serving traffic. Can be stopped or restarted. |
| Stopped | Cluster pods are terminated, PVCs retained. Can be started. |
| Updating | An operation is in progress. Wait for it to complete. |
Stops all pods in the cluster. PVCs are retained so data is preserved.
OpsRequest method:
apiVersion: apps.kubeblocks.io/v1beta1
kind: OpsRequest
metadata:
name: stop-<cluster-name>
namespace: <namespace>
spec:
clusterName: <cluster-name>
type: Stop
Before applying, validate with dry-run:
kubectl apply -f - --dry-run=server <<'EOF'
apiVersion: apps.kubeblocks.io/v1beta1
kind: OpsRequest
metadata:
name: stop-<cluster-name>
namespace: <namespace>
spec:
clusterName: <cluster-name>
type: Stop
EOF
If dry-run reports errors, fix the YAML before proceeding.
Apply:
kubectl apply -f - <<'EOF'
apiVersion: apps.kubeblocks.io/v1beta1
kind: OpsRequest
metadata:
name: stop-<cluster-name>
namespace: <namespace>
spec:
clusterName: <cluster-name>
type: Stop
EOF
Alternative — kubectl patch method:
kubectl patch cluster <cluster-name> -n <namespace> \
--type merge -p '{"spec":{"componentSpecs":[{"name":"<component-name>","stop":true}]}}'
Replace
<component-name>with the component name for the addon (e.g.,mysql,postgresql,redis,mongodb,kafka-combine).
Recreates pods from the retained PVCs, restoring the cluster to its previous state.
OpsRequest method:
apiVersion: apps.kubeblocks.io/v1beta1
kind: OpsRequest
metadata:
name: start-<cluster-name>
namespace: <namespace>
spec:
clusterName: <cluster-name>
type: Start
Before applying, validate with dry-run:
kubectl apply -f - --dry-run=server <<'EOF'
apiVersion: apps.kubeblocks.io/v1beta1
kind: OpsRequest
metadata:
name: start-<cluster-name>
namespace: <namespace>
spec:
clusterName: <cluster-name>
type: Start
EOF
If dry-run reports errors, fix the YAML before proceeding.
Apply:
kubectl apply -f - <<'EOF'
apiVersion: apps.kubeblocks.io/v1beta1
kind: OpsRequest
metadata:
name: start-<cluster-name>
namespace: <namespace>
spec:
clusterName: <cluster-name>
type: Start
EOF
Alternative — kubectl patch method:
kubectl patch cluster <cluster-name> -n <namespace> \
--type merge -p '{"spec":{"componentSpecs":[{"name":"<component-name>","stop":false}]}}'
Performs a rolling restart of specified components. Pods are restarted one at a time to maintain availability.
OpsRequest method:
apiVersion: apps.kubeblocks.io/v1beta1
kind: OpsRequest
metadata:
name: restart-<cluster-name>
namespace: <namespace>
spec:
clusterName: <cluster-name>
type: Restart
restart:
- componentName: <component-name>
Before applying, validate with dry-run:
kubectl apply -f - --dry-run=server <<'EOF'
apiVersion: apps.kubeblocks.io/v1beta1
kind: OpsRequest
metadata:
name: restart-<cluster-name>
namespace: <namespace>
spec:
clusterName: <cluster-name>
type: Restart
restart:
- componentName: <component-name>
EOF
If dry-run reports errors, fix the YAML before proceeding.
Apply:
kubectl apply -f - <<'EOF'
apiVersion: apps.kubeblocks.io/v1beta1
kind: OpsRequest
metadata:
name: restart-<cluster-name>
namespace: <namespace>
spec:
clusterName: <cluster-name>
type: Restart
restart:
- componentName: <component-name>
EOF
Note: The
componentNamedepends on the addon. Common values:
- MySQL:
mysql- PostgreSQL:
postgresql- Redis:
redis- MongoDB:
mongodb- Kafka:
kafka-combine(combined topology) orkafka-broker/kafka-controller(separated topology)
You can restart multiple components by adding more entries to the restart list.
kubectl get ops -n <namespace> -w
Success condition:
.status.phase=Succeed| Typical: 1-3min | If stuck >5min:kubectl describe ops <ops-name> -n <namespace>
Expected progression: Pending → Running → Succeed.
kubectl get cluster <cluster-name> -n <namespace> -w
Success condition: Stop:
.status.phase=Stopped| Start/Restart:.status.phase=Running| Typical: 1-3min | If stuck >5min:kubectl describe cluster <cluster-name> -n <namespace>
Stopped, all pods terminated.Running, all pods recreated.Updating, then returns to Running.kubectl get pods -n <namespace> -l app.kubernetes.io/instance=<cluster-name>
Running state.OpsRequest stuck in Running:
kubectl describe ops <ops-name> -n <namespace>kubectl logs -n kb-system -l app.kubernetes.io/name=kubeblocks --tail=50Start fails after Stop:
kubectl get pvc -n <namespace> -l app.kubernetes.io/instance=<cluster-name>Restart takes too long:
kubectl describe pod <pod-name> -n <namespace>For component names by engine, kubectl patch alternatives, cluster status transitions, and cost-saving patterns, see reference.md.
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
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).
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.