Tanzu MySQL for Kubernetes Architecture

Warning: VMware Tanzu™ SQL with MySQL for Kubernetes is currently in beta and is intended for evaluation and test purposes only. Do not use this product in a production environment. If you discover any bugs, contact Support.

Page last updated:

This topic provides some architectural information about VMware Tanzu™ SQL with MySQL for Kubernetes (Tanzu MySQL for Kubernetes).

Tanzu MySQL for Kubernetes Architecture Diagram

The diagram below shows the architecture of Tanzu MySQL for Kubernetes: A diagram showing the architecture of Tanzu MySQL for Kubernetes with the operator deployment and app namespace

Controllers and Custom Resource Definitions (CRDs)

Tanzu MySQL for Kubernetes provides extensions to the Kubernetes API through custom resources. The product provides five separate custom resources:

TanzuMySQL

Applying this resource causes the Kubernetes Operator to create a StatefulSet with a single Pod with two containers. One container runs the MySQL database software, and the other runs components to support backups.

The TanzuMySQL Pod mounts a Persistent Volume Claim (PVC) which holds the MySQL data.

When a TanzuMySQL instance is created, the Tanzu MySQL operator automatically creates a Kubernetes service with a service type of ClusterIP which routes connections to the TanzuMySQL Pod.

  ---
  apiVersion: mysql.tanzu.vmware.com/v1alpha1
  kind: TanzuMySQL
  metadata:
    name: tanzumysql-sample
  spec:
    resources:
      mysql:
        requests:
          memory: 1Gi
    storageSize: 1Gi
    imagePullSecret: tanzu-mysql-image-registry

After applying this resource, the operator creates the low-level Kubernetes resources to run this TanzuMySQL instance.

You can see the status of the instance by running:

kubectl get tanzumysqls.mysql.tanzu.vmware.com

Initially, this instance is in a pending state:

$ kubectl get tanzumysqls.mysql.tanzu.vmware.com
NAME                READY   STATUS    AGE
tanzumysql-sample           Pending   2s

Later, the instance transitions to a running state:

$ kubectl get tanzumysqls.mysql.tanzu.vmware.com
NAME                READY   STATUS    AGE
tanzumysql-sample   true    Running   27s

TanzuMySQLBackupLocation

This resource describes metadata and credentials for storing backups in an S3-compatible object store.

TanzuMySQLBackup resources reference this backup location to know where to save backup artifacts. The operator creates or maintains a TanzuMySQLBackup resource for every artifact found in the backup location. Consequently, creating a TanzuMySQLBackupLocation that contains existing artifacts generates new, corresponding TanzuMySQLBackup resources.

  ---
  apiVersion: v1
  kind: Secret
  metadata:
    name: backuplocation-sample-creds
  stringData:
    # S3 Credentials
    accessKeyId: "my-s3-access-key-id"
    secretAccessKey: "my-s3-secret-access-key"
  ---
  apiVersion: mysql.tanzu.vmware.com/v1alpha1
  kind: TanzuMySQLBackupLocation
  metadata:
    name: backuplocation-sample
  spec:
    storage:
      # For S3 or Minio:
      s3:
        bucket: "s3bucket"
        bucketPath: "optional/prefix/for/backup/objects/"
        region: "us-east-1"
        endpoint:  "" # optional, default to AWS
        forcePathStyle: false
        disableSSL: false
        secret:
          name: backuplocation-sample-creds

Credentials for S3 are stored in a Kubernetes secret with the keys accessKeyId, secretAccessKey. TanzuMySQLBackupLocation resources do not currently have any associated status, but you can list them using kubectl. For example:

$ kubectl get tanzumysqlbackuplocations.mysql.tanzu.vmware.com
NAME                    AGE
backuplocation-sample   2m38s

TanzuMySQLBackup

This resource triggers the instance to run the Percona XtraBackup utility and upload a backup artifact to the blobstore. Blobstore artifacts are represented as TanzuMySQLBackup resources for subsequent restore. The resource requests for a backup to be taken as soon as possible. For a resource that requests a scheduled backup, see TanzuMySQLBackupSchedule below. For example:

---
apiVersion: mysql.tanzu.vmware.com/v1alpha1
kind: TanzuMySQLBackup
metadata:
  name: backup-sample
spec:
  location:
    name: backuplocation-sample
  cluster:
    name: tanzumysql-sample

You can see the status of the backup using kubectl. For example:

$ kubectl get tanzumysqlbackups.mysql.tanzu.vmware.com
NAME            STATUS      TIME SCHEDULED                TIME STARTED                  TIME COMPLETED                AGE
backup-sample   Succeeded   2020-12-07T15:52:12.065092Z   2020-12-07T15:52:12.279522Z   2020-12-07T15:52:16.041156Z   8s

TanzuMySQLBackupSchedule

This resource defines a schedule to automatically create TanzuMySQLBackup resources. For example:

---
apiVersion: mysql.tanzu.vmware.com/v1alpha1
kind: TanzuMySQLBackupSchedule
metadata:
  name: tanzumysqlbackupschedule-sample
spec:
  backupTemplate:
    spec:
      location:
        name: backuplocation-sample
      cluster:
        name: tanzumysql-sample
  schedule: "@daily"

TanzuMySQLBackupSchedule resources do not currently have any associated status, but you can list them using kubectl. For example:

$ kubectl get tanzumysqlbackupschedules.mysql.tanzu.vmware.com
NAME                              AGE
tanzumysqlbackupschedule-sample   8s

TanzuMySQLRestore

This resource instructs the operator to create a new PVC and a new TanzuMySQL instance from an existing TanzuMySQLBackup resource. The backup artifact for the TanzuMySQLBackup resource is loaded into the new PVC before the MySQL database is started. For example:

---
apiVersion: mysql.tanzu.vmware.com/v1alpha1
kind: TanzuMySQLRestore
metadata:
  name: tanzumysqlrestore-sample
spec:
  tanzuMysqlBackup:
    name: backup-sample
  tanzuMysqlTemplate:
    metadata:
      name: tanzumysql-sample
    spec:
      storageSize: 1Gi
      imagePullSecret: tanzu-mysql-image-registry

You can see the status of the restore using kubectl. For example:

$ kubectl get tanzumysqlrestores.mysql.tanzu.vmware.com
NAME                       STATUS    TIME STARTED                  TIME COMPLETED   AGE
tanzumysqlrestore-sample   Running   2020-12-07T15:56:26.000000Z                    10s

The restore retrieves and unpacks the backup artifact and creates the TanzuMySQL instance. The restore time is proportional to the size of the backup artifact. For example:

$ kubectl get tanzumysqlrestores.mysql.tanzu.vmware.com
NAME                       STATUS      TIME STARTED                  TIME COMPLETED                AGE
tanzumysqlrestore-sample   Succeeded   2020-12-07T15:56:26.000000Z   2020-12-07T15:56:41.765479Z   20s

At the end of the restore process, you have a TanzuMySQL instance with the READY state true and with STATUS running. For example:

$ kubectl get tanzumysqls.mysql.tanzu.vmware.com
NAME                READY   STATUS    AGE
tanzumysql-sample   true    Running   30s