MySQL Operator for Kubernetes Manual  /  MySQL Operator Cookbook  /  Bootstrap a MySQL InnoDB Cluster from a Dump using Helm

6.2 Bootstrap a MySQL InnoDB Cluster from a Dump using Helm

A MySQL InnoDB Cluster can be initialized with a database dump created by MySQL Shell or by MySQL Operator for Kubernetes. The backup could reside on a persistent volume accessible from the cluster, but our example uses an OCI Object Storage bucket.

Using an OCI Object Storage bucket

If you are boostrapping from OCI OS, then the following must be known:

  • The credentials of the user who has access to OCI OS

  • The OCI OS Object Prefix (plays the role of a directory). The following Helm variables must be set:

    • a name for the dump that follows the Kubernetes rules for naming an identifier, such as dump-20210916-140352.

    • initDB.dump.ociObjectStorage.prefix: the prefix from list above

    • initDB.dump.ociObjectStorage.bucketName: the bucket name from the list above

    • initDB.dump.ociObjectStorage.credentials: name of the Kubernetes secret that holds the credentials for accessing the OCI OS bucket

      For the credentials secret, the following information is needed: OCI OS User Name, Fingerprint, Tenancy Name, Region Name, Passphrase, and the Private Key of the user.

  • The OCI OS Bucket Name

The OCI command-line tool provides this information in $HOME/config under the [DEFAULT] section. Once obtained, execute:

export NAMESPACE="mynamespace"
export OCI_CREDENTIALS_SECRET_NAME="oci-credentials"
export OCI_USER="..."                # like ocid1.user.oc1....
export OCI_FINGERPRINT="..."         # like 90:01:..:..:....
export OCI_TENANCY="..."             # like ocid1.tenancy.oc1...
export OCI_REGION="..."              # like us-ashburn-1
export OCI_PASSPHRASE="..."          # set to empty string if no passphrase
export OCI_PATH_TO_PRIVATE_KEY="..." # like $HOME/.oci/oci_api_key.pem

kubectl -n $NAMESPACE create secret generic $OCI_CREDENTIALS_SECRET_NAME \
        --from-literal=user="$OCI_USER" \
        --from-literal=fingerprint="$OCI_FINGERPRINT" \
        --from-literal=tenancy="$OCI_TENANCY" \
        --from-literal=region="$OCI_REGION" \
        --from-literal=passphrase="$OCI_PASSPHRASE" \

With the OCI secret created, now create the cluster that'll be initialized from the dump in OCI OS:

export NAMESPACE="mynamespace"
export OCI_DUMP_PREFIX="..."  # like dump-20210916-140352
export OCI_BUCKET_NAME="..."  # like idbcluster_backup
export OCI_CREDENTIALS_SECRET_NAME="oci-credentials"
kubectl create namespace $NAMESPACE
helm install mycluster mysql-operator/mysql-innodbcluster \
        --namespace $NAMESPACE \
        --set credentials.root.user='root' \
        --set credentials.root.password='sakila' \
        --set'%' \
        --set serverInstances=3 \
        --set routerInstances=1 \
        --set"initdb-dump" \
        --set initDB.dump.ociObjectStorage.prefix="$OCI_DUMP_PREFIX" \
        --set initDB.dump.ociObjectStorage.bucketName="$OCI_BUCKET_NAME" \
        --set initDB.dump.ociObjectStorage.credentials="$OCI_CREDENTIALS_SECRET_NAME"