skills/kubeblocks-addon-mysql/SKILL.md
Deploy and manage MySQL clusters on KubeBlocks with topology selection guidance. Covers semi-synchronous replication, MySQL Group Replication (MGR), Orchestrator-managed HA, and optional ProxySQL load balancing. Use when the user mentions MySQL, MariaDB, or explicitly wants to create a MySQL database cluster. Provides engine-specific topology comparison, best-practice defaults, and connection methods. For generic cluster creation across all engines, see kubeblocks-create-cluster. For Day-2 operations (scaling, backup, etc.), use the corresponding operation skill.
npx skillsauth add apecloud/kubeblocks-skills kubeblocks-addon-mysqlInstall 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.
Deploy highly-available MySQL clusters using KubeBlocks. Multiple topologies are available — from simple semi-synchronous replication to full orchestrator-managed setups with ProxySQL.
Official docs: https://kubeblocks.io/docs/preview/user_docs/kubeblocks-for-mysql/cluster-management/create-and-connect-a-mysql-cluster Full doc index: https://kubeblocks.io/llms-full.txt
# Check if mysql addon is installed
helm list -n kb-system | grep mysql
# Install if missing
helm install kb-addon-mysql kubeblocks/mysql --namespace kb-system --version 1.0.0
| Topology | Value | Components | Use Case |
|---|---|---|---|
| Semi-Synchronous | semisync | mysql | Standard HA, 2+ replicas |
| Semi-Sync + ProxySQL | semisync-proxysql | mysql + proxysql | HA with query routing |
| Group Replication | mgr | mysql | Multi-primary capable, 3+ replicas |
| MGR + ProxySQL | mgr-proxysql | mysql + proxysql | MGR with load balancing |
| Orchestrator | orc | mysql + orchestrator | External HA manager |
| Orc + ProxySQL | orc-proxysql | mysql + orc + proxysql | Full HA stack |
Default recommendation: semisync — simplest, most widely deployed.
Keep these decisions visible in this engine-entry skill:
storageClassName from preflight| Version | serviceVersion |
|---|---|
| MySQL 5.7 | 5.7.44 |
| MySQL 8.0 | 8.0.33, 8.0.35 |
| MySQL 8.4 | 8.4.2 |
- [ ] Step 1: Ensure addon is installed
- [ ] Step 2: Create namespace
- [ ] Step 3: Create cluster
- [ ] Step 4: Wait for cluster to be ready
- [ ] Step 5: Connect to MySQL
helm list -n kb-system | grep mysql
If not found, install it:
helm install kb-addon-mysql kubeblocks/mysql --namespace kb-system --version 1.0.0
kubectl create namespace demo --dry-run=client -o yaml | kubectl apply -f -
This is the most common topology. One primary + one or more replicas with semi-sync replication for data safety.
apiVersion: apps.kubeblocks.io/v1
kind: Cluster
metadata:
name: mysql-cluster
namespace: demo
spec:
clusterDef: mysql
topology: semisync
terminationPolicy: Delete
componentSpecs:
- name: mysql
serviceVersion: "8.0.35"
replicas: 2
resources:
limits: {cpu: "0.5", memory: "0.5Gi"}
requests: {cpu: "0.5", memory: "0.5Gi"}
volumeClaimTemplates:
- name: data
spec:
accessModes: [ReadWriteOnce]
storageClassName: <storageClassName-from-preflight>
resources: {requests: {storage: 20Gi}}
Apply:
kubectl apply -f mysql-cluster.yaml
Multi-primary capable. Requires 3+ replicas:
apiVersion: apps.kubeblocks.io/v1
kind: Cluster
metadata:
name: mysql-mgr
namespace: demo
spec:
clusterDef: mysql
topology: mgr
terminationPolicy: Delete
componentSpecs:
- name: mysql
serviceVersion: "8.0.35"
replicas: 3
resources:
limits: {cpu: "0.5", memory: "0.5Gi"}
requests: {cpu: "0.5", memory: "0.5Gi"}
volumeClaimTemplates:
- name: data
spec:
accessModes: [ReadWriteOnce]
storageClassName: <storageClassName-from-preflight>
resources: {requests: {storage: 20Gi}}
For topologies with ProxySQL or Orchestrator, see reference.md.
kubectl -n demo get cluster mysql-cluster -w
Wait until STATUS shows Running. Typical startup time: 1-3 minutes.
Check component status:
kubectl -n demo get pods -l app.kubernetes.io/instance=mysql-cluster
The root password is stored in a Kubernetes secret:
# Secret name format: <cluster>-mysql-account-root
kubectl -n demo get secret mysql-cluster-mysql-account-root -o jsonpath='{.data.password}' | base64 -d
kubectl -n demo exec -it mysql-cluster-mysql-0 -- bash -c 'mysql -uroot -p"$(cat /etc/mysql/secret/password)"'
kubectl -n demo port-forward svc/mysql-cluster-mysql 3306:3306
# Then from another terminal:
mysql -h 127.0.0.1 -P 3306 -u root -p
MySQL supports three backup methods:
| Method | ActionSet | Use Case |
|---|---|---|
| XtraBackup | xtrabackup | Physical backup, fast for large DBs |
| Volume Snapshot | mysql-volumesnapshot | Storage-level snapshots, fastest |
| Binlog Archive | archive-binlog | Continuous archiving for PITR |
Example backup:
apiVersion: dataprotection.kubeblocks.io/v1alpha1
kind: Backup
metadata:
name: mysql-backup
namespace: demo
spec:
backupMethod: xtrabackup
backupPolicyName: mysql-cluster-mysql-backup-policy
Cluster stuck in Creating:
kubectl -n demo describe cluster mysql-cluster
kubectl -n demo get events --sort-by='.lastTimestamp'
Pod CrashLoopBackOff:
kubectl -n demo logs mysql-cluster-mysql-0
Semi-sync replica not connecting:
replicas >= 2 for semisync topology| Operation | Skill | External Docs | |---|---|---| | Stop / Start / Restart | cluster-lifecycle | Docs | | Scale CPU / Memory | vertical-scaling | Docs | | Add / Remove replicas | horizontal-scaling | Docs | | Expand storage | volume-expansion | Docs | | Change parameters | reconfigure-parameters | Docs | | Switchover primary | switchover | Docs | | Upgrade engine version | minor-version-upgrade | Docs | | Expose externally | expose-service | Docs | | Backup | backup | Docs | | Restore | restore | Docs |
Follow safety-patterns.md for dry-run before apply, status confirmation after watch, and pre-deletion checklist.
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.