kubectl moco plugin

kubectl-moco is a kubectl plugin for MOCO.

kubectl moco [global options] <subcommand> [sub options] args...

Global options

Global options are compatible with kubectl. For example, the following options are available.

Global optionsDefault valueDescription
--kubeconfig$HOME/.kube/configPath to the kubeconfig file to use for CLI requests.
-n, --namespacedefaultIf present, the namespace scope for this CLI request.

MySQL users

You can choose one of the following user for --mysql-user option value.

NameDescription
moco-readonlyA read-only user.
moco-writableA user that can edit users, databases, and tables.
moco-adminThe super-user.

kubectl moco mysql [options] CLUSTER_NAME [-- mysql args...]

Run mysql command in a specified MySQL instance.

OptionsDefault valueDescription
-u, --mysql-usermoco-readonlyLogin as the specified user
--indexindex of the primaryIndex of the target mysql instance
-i, --stdinfalsePass stdin to the mysql container
-t, --ttyfalseStdin is a TTY

Examples

This executes SELECT VERSION() on the primary instance in mycluster in foo namespace:

$ kubectl moco -n foo mysql mycluster -- -N -e 'SELECT VERSION()'

To execute SQL from a file:

$ cat sample.sql | kubectl moco -n foo mysql -u moco-writable -i mycluster

To run mysql interactively for the instance 2 in mycluster in the default namespace:

$ kubectl moco mysql --index 2 -it mycluster

kubectl moco credential [options] CLUSTER_NAME

Fetch the credential information of a specified user

OptionsDefault valueDescription
-u, --mysql-usermoco-readonlyFetch the credential of the specified user
--formatplainOutput format: plain or mycnf

kubectl moco switchover CLUSTER_NAME

Switch the primary instance to one of the replicas.

Stop or start clustering and reconciliation

Read Stop Clustering and Reconciliation.

kubectl moco stop clustering CLUSTER_NAME

Stop the clustering of the specified MySQLCluster.

kubectl moco start clustering CLUSTER_NAME

Start the clustering of the specified MySQLCluster.

kubectl moco stop reconciliation CLUSTER_NAME

Stop the reconciliation of the specified MySQLCluster.

kubectl moco start reconciliation CLUSTER_NAME

Start the reconciliation of the specified MySQLCluster.