KubeBlocks
BlogsKubeBlocks Cloud
⌘K
​

Overview

Introduction
Concepts
Kubernetes and Operator 101
Supported addons
About this manual

Try out KubeBlocks with Playground

Try out KubeBlocks on cloud
Try out KubeBlocks on laptop

Installation

Prerequisite for Local Env

Prerequisite for Local Env
Install kbcli
Install KubeBlocks
Install Addons
Uninstall KubeBlocks and kbcli

Upgrade KubeBlocks

Upgrade to v0.8
Upgrade to v0.9.0
Upgrade to v0.9.3
FAQ

Connect Database

Overview
Testing environment
Production environment

Maintenance

Scale

Horizontal Scale
Vertical Scale

Backup and Restore

Introduction

Backup

Configure BackupRepo
Configure BackupPolicy
Scheduled backup
On-demand backup

Restore

Restore from backup set
PITR

In Place Update

Overview on in-place update
Enable in-place update

Resource Scheduling

Configure pod affinity for database clusters

Cross K8s Deployment

Deploy a Cluster across Multiple Kubernetes Clusters by KubeBlocks

Instance Template

Introduction of instance template
Apply instance template

Observability

Monitor database
Configure alert

User Management

Manage user accounts

Handle an Exception

Handle an exception
Full disk lock

Developer

Developer guides
Terminology

Add an add-on to KubeBlocks

Add-ons of KubeBlocks
Add an add-on
Backup and restore
Parameter template
Parameter configuration
Monitoring
Multi-component configuration
Environment variables and placeholders

External Component

Reference external component

API Reference

Cluster
Backup
Add-On
  1. Preparation
    1. Before you start to try KubeBlocks on AWS
    2. Configure access key
    3. Initialize Playground
    4. Before you start to try KubeBlocks on GCP
    5. Configure GCP environment
    6. Initialize Playground
    7. Before you start to try KubeBlocks on Tencent Cloud
    8. Configure TKE environment
    9. Initialize Playground
    10. Before you start to try KubeBlocks on Alibaba Cloud
    11. Configure ACK environment
    12. Initialize Playground
  2. Try KubeBlocks with Playground
    1. Describe a MySQL cluster
    2. Access a MySQL cluster
    3. High availability of MySQL
      1. Delete the Standalone MySQL cluster
      2. Create a Raft MySQL cluster
      3. Simulate leader pod failure recovery
  3. Destroy Playground

Try out KubeBlocks on Cloud

This guide walks you through the quickest way to get started with KubeBlocks on cloud, demonstrating how to create a demo environment (Playground) with one command.

Preparation

When deploying KubeBlocks on the cloud, cloud resources are initialized with the help of the terraform script. kbcli downloads the script and stores it locally, then calls the terraform commands to initialize a fully-managed Kubernetes cluster and deploy KubeBlocks on this cluster.

Before you start to try KubeBlocks on AWS

Make sure you have all the followings prepared.

  • Install AWS CLI
  • Install kubectl
  • Install kbcli

Configure access key

Option 1. Use aws configure.

Fill in an access key and run the command below to authenticate the requests.

aws configure
AWS Access Key ID [None]: YOUR_ACCESS_KEY_ID
AWS Secret Access Key [None]: YOUR_SECRET_ACCESS_KEY

You can refer to Quick configuration with aws configure for detailed information.

Option 2. Use environment variables.

export AWS_ACCESS_KEY_ID="YOUR_ACCESS_KEY_ID"
export AWS_SECRET_ACCESS_KEY="YOUR_SECRET_ACCESS_KEY"

Initialize Playground

kbcli playground init --cloud-provider aws --region us-west-2
  • cloud-provider specifies the cloud provider.
  • region specifies the region to deploy a Kubernetes cluster. You can find the region list on the official website.

During the initialization, kbcli clones the GitHub repository to the directory ~/.kbcli/playground, installs KubeBlocks, and creates a MySQL cluster. After executing the kbcli playground init command, kbcli automatically switches the current context of kubeconfig to the new Kubernetes cluster. Run the command below to view the created cluster.

# View kbcli version
kbcli version

# View the cluster list
kbcli cluster list
NOTE

The initialization lasts about 20 minutes. If the installation fails after a long time, please check your network.

Before you start to try KubeBlocks on GCP

Make sure you have all the followings prepared.

  • Google Cloud account
  • Install kubectl
  • Install kbcli

Configure GCP environment

Steps:

  1. Install Google Cloud SDK.

    # macOS brew install
    brew install --cask google-cloud-sdk
    
    # windows
    choco install gcloudsdk
    
  2. Initialize GCP.

    gcloud init
    
  3. Log in to GCP.

    gcloud auth application-default login
    
  4. Configure GOOGLE_PROJECT environment variables,kbcli playground creates GKE cluster in the project.

    export GOOGLE_PROJECT=<project-name>
    

Initialize Playground

The following command deploys a GKE service in the region us-central1 on GCP, and installs KubeBlocks.

kbcli playground init --cloud-provider gcp --region us-central1
  • cloud-provider specifies the cloud provider.
  • region specifies the region to deploy a Kubernetes cluster.

During the initialization, kbcli clones the GitHub repository to the directory ~/.kbcli/playground, installs KubeBlocks, and creates a MySQL cluster. After executing the kbcli playground init command, kbcli automatically switches the current context of kubeconfig to the new Kubernetes cluster. Run the command below to view the created cluster.

# View kbcli version
kbcli version

# View the cluster list
kbcli cluster list
NOTE

The initialization takes about 20 minutes. If the installation fails after a long time, please check your network.

Before you start to try KubeBlocks on Tencent Cloud

Make sure you have all the followings prepared.

  • Tencent Cloud account
  • Install kubectl
  • Install kbcli

Configure TKE environment

Steps:

  1. Log in to Tencent Cloud.

  2. Go to Tencent Kubernetes Engine (TKE) to grant resource operation permission to your account before using the container service.

  3. Go to API Console -> Access Key -> API Keys and click Create Key to create a pair of Secret ID and Secret Key.

  4. Add the Secret ID and Secret Key to the environment variables.

    export TENCENTCLOUD_SECRET_ID=YOUR_SECRET_ID
    export TENCENTCLOUD_SECRET_KEY=YOUR_SECRET_KEY
    

Initialize Playground

The following command deploys a Kubernetes service in the region ap-chengdu on Tencent Cloud and installs KubeBlocks.

kbcli playground init --cloud-provider tencentcloud --region ap-chengdu
  • cloud-provider specifies the cloud provider.
  • region specifies the region to deploy a Kubernetes cluster.

During the initialization, kbcli clones the GitHub repository to the directory ~/.kbcli/playground, installs KubeBlocks, and creates a MySQL cluster. After executing the kbcli playground init command, kbcli automatically switches the current context of kubeconfig to the new Kubernetes cluster. Run the command below to view the created cluster.

# View kbcli version
kbcli version

# View the cluster list
kbcli cluster list
NOTE

The initialization takes about 20 minutes. If the installation fails after a long time, please check your network.

Before you start to try KubeBlocks on Alibaba Cloud

Make sure you have all the followings prepared.

  • Alibaba Cloud account.
  • Install kubectl.
  • Install kbcli

Configure ACK environment

Steps:

  1. Log in to Alibaba Cloud.

  2. Follow the instructions in Quick start for first-time users to check whether you have activated Alibaba Cloud Container Service for Kubernetes (ACK) and assigned roles.

    NOTE

    For users who deploy Alibaba Cloud in China Mainland, refer to the corresponding guide.

  3. Click AliyunOOSLifecycleHook4CSRole and click Agree to Authorization to create an AliyunOOSLifecycleHook4CSRole role.

    This operation grant permissions to access Operation Orchestration Service (OOS) and to access the resources in other cloud products since creating and managing a node pool is required for creating an ACK cluster.

    Refer to Scale a node pool for details.

  4. Create an AccessKey ID and the corresponding AccessKey secret.

    1. Go to Alibaba Cloud Management Console. Hover the pointer over your account console and click AccessKey Management. AccessKey Management

    2. Click Create AccessKey to create the AccessKey ID and the corresponding AccessKey secret.

    3. Add the AccessKey ID and AccessKey secret to the environment variable to configure identity authorization information.

      export ALICLOUD_ACCESS_KEY="YOUR_ACCESS_KEY"
      export ALICLOUD_SECRET_KEY="YOUR_SECRET_KEY"
      
    NOTE

    Refer to Create an AccessKey pair for details.

Initialize Playground

The following command deploys an ACK cluster in the region cn-hangzhou on Alibaba Cloud, and installs KubeBlocks.

kbcli playground init --cloud-provider alicloud --region cn-hangzhou
  • cloud-provider specifies the cloud provider.
  • region specifies the region to deploy a Kubernetes cluster.

During the initialization, kbcli clones the GitHub repository to the directory ~/.kbcli/playground, installs KubeBlocks, and creates a MySQL cluster. After executing the kbcli playground init command, kbcli automatically switches the current context of kubeconfig to the new Kubernetes cluster. Run the command below to view the created cluster.

# View kbcli version
kbcli version

# View the cluster list
kbcli cluster list
NOTE

The initialization takes about 20 minutes. If the installation fails after a long time, please check your network.

Try KubeBlocks with Playground

Go through the following instructions to try basic features of KubeBlocks.

Describe a MySQL cluster

Steps:

  1. View the database cluster list.

    kbcli cluster list
    
  2. View the details of a specified database cluster, such as STATUS, Endpoints, Topology, Images, and Events.

    kbcli cluster describe mycluster
    

Access a MySQL cluster

Option 1. Connect database from container network.

Wait until the status of this cluster is Running, then run kbcli cluster connect to access a specified database cluster. For example,

kbcli cluster connect mycluster

Option 2. Connect database remotely.

Steps:

  1. Get Credentials.

    kbcli cluster connect --show-example --show-password --client=cli mycluster
    
  2. Run port-forward.

    kubectl port-forward service/mycluster-mysql 3306:3306
    >
    Forwarding from 127.0.0.1:3306 -> 3306
    Forwarding from [::1]:3306 -> 3306
    
  3. Open another terminal tab to connect the database cluster.

    mysql -h 127.0.0.1 -P 3306 -u root -p"******"
    >
    ...
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    mysql> show databases;
    >
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mydb               |
    | mysql              |
    | performance_schema |
    | sys                |
    +--------------------+
    5 rows in set (0.02 sec)
    

High availability of MySQL

This guide shows a simple failure simulation to show you the failure recovery capability of MySQL.

Delete the Standalone MySQL cluster

Delete the Standalone MySQL cluster before trying out high availability.

kbcli cluster delete mycluster

Create a Raft MySQL cluster

You can use kbcli to create a Raft MySQL cluster. The following is an example of creating a Raft MySQL cluster with default configurations.

kbcli cluster create --cluster-definition='apecloud-mysql' --set replicas=3

Simulate leader pod failure recovery

In this example, delete the leader pod to simulate a failure.

Steps:

  1. Make sure the newly created cluster is Running.

    kbcli cluster list
    
  2. Find the leader pod name in Topology. In this example, the leader pod's name is maple05-mysql-1.

    kbcli cluster describe maple05
    >
    Name: maple05         Created Time: Jan 27,2023 17:33 UTC+0800
    NAMESPACE        CLUSTER-DEFINITION        VERSION                STATUS         TERMINATION-POLICY
    default          apecloud-mysql            ac-mysql-8.0.30        Running        WipeOut
    
    Endpoints:
    COMPONENT        MODE             INTERNAL                EXTERNAL
    mysql            ReadWrite        10.43.29.51:3306        <none>
    
    Topology:
    COMPONENT        INSTANCE               ROLE            STATUS         AZ            NODE                                                 CREATED-TIME
    mysql            maple05-mysql-1        leader          Running        <none>        k3d-kubeblocks-playground-server-0/172.20.0.3        Jan 30,2023 17:33 UTC+0800
    mysql            maple05-mysql-2        follower        Running        <none>        k3d-kubeblocks-playground-server-0/172.20.0.3        Jan 30,2023 17:33 UTC+0800
    mysql            maple05-mysql-0        follower        Running        <none>        k3d-kubeblocks-playground-server-0/172.20.0.3        Jan 30,2023 17:33 UTC+0800
    
    Resources Allocation:
    COMPONENT        DEDICATED        CPU(REQUEST/LIMIT)        MEMORY(REQUEST/LIMIT)        STORAGE-SIZE        STORAGE-CLASS
    mysql            false            <none>                    <none>                       <none>              <none>
    
    Images:
    COMPONENT        TYPE         IMAGE
    mysql            mysql        docker.io/apecloud/wesql-server:8.0.30-5.alpha2.20230105.gd6b8719
    
    Events(last 5 warnings, see more:kbcli cluster list-events -n default mycluster):
    TIME        TYPE        REASON        OBJECT        MESSAGE
    
  3. Delete the leader pod.

    kubectl delete pod maple05-mysql-1
    >
    pod "maple05-mysql-1" deleted
    
  4. Connect to the Raft MySQL cluster. It can be accessed within seconds.

    kbcli cluster connect maple05
    >
    Connect to instance maple05-mysql-2: out of maple05-mysql-2(leader), maple05-mysql-1(follower), maple05-mysql-0(follower)
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 33
    Server version: 8.0.30 WeSQL Server - GPL, Release 5, Revision d6b8719
    
    Copyright (c) 2000, 2022, Oracle and/or its affiliates.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    mysql>
    

Destroy Playground

  1. Before destroying Playground, it is recommended to delete the database clusters created by KubeBlocks.

    # View all clusters
    kbcli cluster list -A
    
    # Delete a cluster
    # A double-check is required or you can add --auto-approve to skip it
    kbcli cluster delete <name>
    
    # Uninstall KubeBlocks
    # A double-check is required or you can add --auto-approve to skip it
    kbcli kubeblocks uninstall --remove-pvcs --remove-pvs
    
  2. Destroy Playground.

    kbcli playground destroy
    
CAUTION

kbcli playground destroy deletes the Kubernetes cluster on the cloud, but there might be residual resources on the cloud, such as volumes and snapshots. Please delete them in time to avoid unexpected costs.

© 2025 ApeCloud PTE. Ltd.