TiDB on KubeSphere: Release a Cloud-Native Distributed Database to the KubeSphere App Store
My last blog talked about how to deploy TiDB Operator and a TiDB cluster on KubeSphere. After you add an app repository to KubeSphere, apps within the repository are provided as app templates on the container platform. Tenants in the same workspace can deploy these app templates if they have necessary permissions. However, if you want these apps to be available to all workspace tenants, I recommend you release apps to the public repository of KubeSphere, also known as the KubeSphere App Store.
In this article, I will demonstrate another way to upload an app to KubeSphere and release it to the App Store.
Before You Begin
You have enabled the KubeSphere App Store.
Preparing TiDB Helm Charts
As I will upload individual Helm charts of TiDB later, I need to first download them using Helm. Helm helps you create, install and manage Kubernetes applications.
If you have not installed Helm, refer to the Helm documentation to install it or execute the following command directly.
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
Add the PingCAP TiDB Helm repository.
helm repo add pingcap https://charts.pingcap.org/
View all the Helm charts in this repository.
$ helm search repo pingcap --version=v1.1.6 NAME CHART VERSION APP VERSION DESCRIPTION pingcap/tidb-backup v1.1.6 A Helm chart for TiDB Backup or Restore pingcap/tidb-cluster v1.1.6 A Helm chart for TiDB Cluster pingcap/tidb-drainer v1.1.6 A Helm chart for TiDB Binlog drainer. pingcap/tidb-lightning v1.1.6 A Helm chart for TiDB Lightning pingcap/tidb-operator v1.1.6 v1.1.6 tidb-operator Helm chart for Kubernetes pingcap/tikv-importer release-1.1 A Helm chart for TiKV Importer
Note that the version I use in this article is v1.1.6. PingCAP released the v1.1.7 of the TiDB Operator recently, which is available in its GitHub repository.
Download the charts you need locally. For example:
helm pull pingcap/tidb-operator --version=v1.1.6 helm pull pingcap/tidb-cluster --version=v1.1.6
Make sure they have been successfully pulled.
$ ls | grep tidb tidb-cluster-v1.1.6.tgz tidb-operator-v1.1.6.tgz
Uploading Helm Charts to KubeSphere
Now that you have Helm charts ready, you can upload them to KubeSphere as app templates.
Log in to the web console of KubeSphere. As I described in my last blog, you need to create a workspace before you create any resources in it. You can see the official documentation of KubeSphere to learn how to create a workspace.
Go to your workspace, and you can see that KubeSphere provides two methods to add Helm charts. My last blog explained detailed steps of importing an app repository to KubeSphere and deploying apps in it. Let’s upload Helm charts as app templates this time. From the navigation bar, select App Templates and click Upload Template on the right.
Select the Helm chart you want to upload to KubeSphere. They will appear in the list below after successfully uploaded.
Deploying TiDB Operator and a TiDB Cluster
To deploy apps, you need to create a project (i.e. namespace) where all workloads of an app run.
After the project is created, navigate to Applications and click Deploy New Application.
Select From App Templates.
All Helm charts uploaded individually as app templates will appear in From workspace. If you add an app repository to KubeSphere to provide app templates, they will display in other repositories in the drop-down list, which is exactly what I demonstrated in my last blog. Select From workspace here and click tidb-cluster and tidb-operator respectively to deploy them. For more information about how to configure them, see my last blog.
Releasing Apps to the App Store
App templates enable users to deploy and manage apps in a visualized way. Internally, they play an important role as shared resources (e.g. databases, middleware and operating systems) created by enterprises for the coordination and cooperation within teams.
You can release apps you have uploaded to KubeSphere to the public repository, also known as the App Store. In this way, all tenants on the platform can see these apps and deploy them if they have necessary permissions regardless of the workspace they belong to.
Click Platform in the top left corner and select Access Control.
On the Workspaces page, click the workspace where you have uploaded the Helm charts above.
Click App Templates from the navigation bar and you can see the apps uploaded. Now I will use TiDB Operator as an example to demonstrate how to release it to the App Store. Click tidb-operator.
On the detail page, click the version number to expand the menu where you can delete the version, deploy the app to test it, or submit it for review. KubeSphere allows you to manage an app across its entire lifecycle. For an enterprise, this is very useful when different tenants need to be isolated from each other and are only responsible for their own part as they manage an app version. For demonstration purposes, I will use the account
adminto perform all the operations. As we do not need to test the app, click Submit Review directly.
After the app is submitted for review, I need to approve it before it can be released to the App Store. Click Platform in the top left corner and select App Store Management.
In App Review from the navigation bar, click the app submitted just now.
In the dialog that appears, inspect app information and chart files. Approve the app by clicking Pass if you think it is ready to be delivered.
After the app is approved, you can release it to the App Store. Click Platform in the top left corner, select Access Control, and go back to your workspace. Select App Templates from the navigation bar and click tidb-operator.
On the detail page, click the version number again and you can see that the status has reached Passed with the button Submit Review changed to Release to Store. Click Release to Store.
Click OK to confirm in the pop-up dialog.
To view the app released, click App Store in the top left corner and you can see it in the App Store. Likewise, you can deploy tidb-cluster to the App Store by following the same step.
For more information about how to deploy an app from the App Store, see the KubeSphere documentation. You can also see Application Lifecycle Management to know more about how an app is managed across its entire lifecycle.
Both TiDB and KubeSphere are powerful tools for us as we deploy containerized applications and use the distributed database on the cloud. As a big fan of open source, I hope both sides can continue to deliver efficient and effective cloud-native tools for us in production.