skills/kubeblocks-manage-accounts/SKILL.md
Manage database accounts and passwords for KubeBlocks clusters. Configure custom root passwords at cluster creation time and define password generation policies (length, complexity). Use when the user wants to set, change, reset, rotate, or customize database passwords, credentials, or account security policies. NOT for managing TLS/SSL certificates (see configure-tls) or for application-level database user management via SQL (connect directly to the database instead).
npx skillsauth add apecloud/kubeblocks-skills kubeblocks-manage-accountsInstall 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 automatically creates database accounts (e.g., root, admin) when provisioning a cluster. Credentials are stored in Kubernetes Secrets. You can:
Official docs: https://kubeblocks.io/docs/preview/user_docs/connect-databases/overview
- [ ] Step 1: Get current credentials
- [ ] Step 2: (Optional) Set custom password or password policy
KubeBlocks stores account credentials in Secrets following the naming pattern <cluster>-<component>-account-<account>:
kubectl get secrets -n <ns> | grep <cluster>.*account
Example output:
mycluster-mysql-account-root Opaque 2 5m
kubectl get secrets -n <ns> <cluster>-<component>-account-root \
-o jsonpath='{.data.password}' | base64 -d
kubectl get secrets -n <ns> <cluster>-<component>-account-root \
-o jsonpath='{.data.username}' | base64 -d
# MySQL
kubectl exec -it <cluster>-<component>-0 -n <ns> -- \
mysql -u root -p$(kubectl get secrets -n <ns> <cluster>-<component>-account-root -o jsonpath='{.data.password}' | base64 -d)
# PostgreSQL
kubectl exec -it <cluster>-<component>-0 -n <ns> -- \
psql -U postgres
# Redis
kubectl exec -it <cluster>-<component>-0 -n <ns> -- \
redis-cli -a $(kubectl get secrets -n <ns> <cluster>-<component>-account-root -o jsonpath='{.data.password}' | base64 -d)
Create a Secret with the desired password, then reference it in the Cluster CR:
1. Create the password Secret:
apiVersion: v1
kind: Secret
metadata:
name: <cluster>-custom-password
namespace: <ns>
type: Opaque
stringData:
password: "MySecureP@ssw0rd!"
kubectl apply -f custom-password-secret.yaml
2. Reference in Cluster CR systemAccounts:
spec:
componentSpecs:
- name: <component>
systemAccounts:
- name: root
secretRef:
name: <cluster>-custom-password
namespace: <ns>
This tells KubeBlocks to use the password from the referenced Secret instead of auto-generating one.
Configure automatic password generation rules in the Cluster CR:
spec:
componentSpecs:
- name: <component>
systemAccounts:
- name: root
passwordConfig:
length: 16
numDigits: 4
numSymbols: 2
letterCase: MixedCases
Password policy fields:
| Field | Description | Default |
|-------|-------------|---------|
| length | Total password length | 16 |
| numDigits | Minimum number of digits | 4 |
| numSymbols | Minimum number of symbols | 0 |
| letterCase | Letter case: UpperCases, LowerCases, MixedCases | MixedCases |
To change the password of an existing cluster, update the Secret directly:
# Encode the new password
NEW_PASSWORD=$(echo -n "NewSecureP@ss123!" | base64)
# Patch the existing secret
kubectl patch secret <cluster>-<component>-account-root -n <ns> \
--type merge -p "{\"data\":{\"password\":\"$NEW_PASSWORD\"}}"
Then execute the password change in the database:
# MySQL
kubectl exec -it <cluster>-<component>-0 -n <ns> -- \
mysql -u root -p<old-password> -e "ALTER USER 'root'@'%' IDENTIFIED BY 'NewSecureP@ss123!';"
# PostgreSQL
kubectl exec -it <cluster>-<component>-0 -n <ns> -- \
psql -U postgres -c "ALTER USER postgres PASSWORD 'NewSecureP@ss123!';"
Secret not found:
kubectl get cluster <cluster> -n <ns> -o jsonpath='{.spec.componentSpecs[*].name}'Password doesn't work:
Custom password not applied on new cluster:
secretRef namespace and name are correctFollow 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.