Tip:

KubeBlocks 是基于 Kubernetes 的云原生数据基础设施 ,KubeBlocks 引入了 ReplicationSet 和 ConsensusSet,具备以下能力:

  • 基于角色的更新顺序可减少因升级版本、缩放和重新启动而导致的停机时间。
  • 维护数据复制的状态,并自动修复复制错误或延迟。


1、安装 kbcli

curl -fsSL https://kubeblocks.io/installer/install_cli.sh | bash
  • 1.

在初始化过程中,kbcli 会将 GitHub 仓库克隆到 ~/.kbcli/playground 目录,安装 KubeBlocks,并创建一个 MySQL 集群。执行 kbcli playground init 命令后,kbcli 会自动将 kubeconfig 的 context 切换到新的 Kubernetes 集群。

2、使用命令 # kbcli kubeblocks install --set storageClass=rook-ceph-block 安装Warn提示:- The default storage class was not found. You can use option --set storageClass=<storageClassName> when creating cluster

To specify a default StorageClass when installing KubeBlocks, you can use --set storageClass.name=rook-ceph-block. 
Additionally, if you don't need KubeBlocks to create the StorageClass, add --set storageClass.create=false as well.
The complete command for your case should be:
# kbcli kubeblocks install --set storageClass.name=rook-ceph-block --set storageClass.create=false
KubeBlocks will be installed to namespace "kb-system"
Kubernetes version 1.28.4
kbcli version 0.9.0
Collecting data from cluster                       OK
Kubernetes cluster preflight                       OK
  Warn
  - The default storage class was not found. You can use option --set storageClass=<storageClassName> when creating cluster
Create CRDs                                        OK
Add and update repo kubeblocks                     OK
Install KubeBlocks 0.9.0                           OK
Wait for addons to be enabled
  apecloud-mysql                                   OK
  kafka                                            OK
  mongodb                                          OK
  mysql                                            OK
  postgresql                                       OK
  pulsar                                           OK
  redis                                            OK
  snapshot-controller                              OK
KubeBlocks 0.9.0 installed to namespace kb-system SUCCESSFULLY!
-> Basic commands for cluster:
    kbcli cluster create -h     # help information about creating a database cluster
    kbcli cluster list          # list all database clusters
    kbcli cluster describe <cluster name>  # get cluster information
-> Uninstall KubeBlocks:
    kbcli kubeblocks uninstall
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 此提示建议在创建集群时使用该选项,例如kbcli cluster create mysql --set storageClass=xxx。它不适用于KubeBlocks安装。命令帮助,格式是--storage-class-name=''
# kbcli cluster create mysql  -n kb-system  --storage-class-name='rook-ceph-block'
Info: --version is not specified, ac-mysql-8.0.30 is applied by default.
Cluster orange62 created
# k -n kb-system get pod 
NAME                                            READY   STATUS    RESTARTS   AGE
kb-addon-snapshot-controller-7df64b4d5b-5sk69   1/1     Running   0          11m
kubeblocks-dataprotection-5f465c7d59-kmmcw      1/1     Running   0          11m
kubeblocks-dcfdb6466-g4wxg                      1/1     Running   0          11m
orange62-mysql-0                                4/4     Running   0          93s
[root@k8s-master01 cephfs]# k -n kb-system get pvc
NAME                    STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS      AGE
data-orange62-mysql-0   Bound    pvc-2e25efde-57c1-4ce8-ae21-2d59e04c42ca   20Gi       RWO            rook-ceph-block   101s
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.

values.yaml:(# helm install kubeblocks --namespace kb-system --create-namespace --set storageClass.name="rook-ceph-block" .)

## @section KubeBlocks default storageClass Parameters for cloud provider.
storageClass:
  ## @param storageClass.name -- Specifies the name of the default storage class.
  ## If name is not specified and KubeBlocks deployed in a cloud, a default name will be generated.
  ##
  name: "rook-ceph-block"
  ## @param storageClass.create -- Specifies whether the storage class should be created. If storageClass.name is not
  ## specified or generated, this value will be ignored.
  ##
  create: true
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.