TiDB on KubeSphere: Release a Cloud-Native Distributed Database to the KubeSphere App Store

Image for post
Image for post

Author: Will Zhang (SRE at iSoftStone)

KubeSphere, an open-source, distributed operating system with Kubernetes as its kernel, helps you manage cloud-native applications on a GUI container platform. TiDB is an open-source, cloud-native database that runs smoothly on Kubernetes.

In my last blog post, I talked about how to deploy TiDB on KubeSphere. If you want TiDB to be available to tenants across the workspace, you can release the TiDB app to the KubeSphere public repository, also known as the KubeSphere App Store. In this way, all tenants can easily deploy TiDB in their project, without having to repeat the same steps.

In this article, I will walk you through how to deploy TiDB on KubeSphere by app templates and release TiDB to the App Store.

Prerequisites

Before you try the steps in this post, make sure:

Prepare TiDB Helm Charts

To deploy TiDB on KubeSphere, you need TiDB Helm charts. Helm helps you create, install, and manage Kubernetes applications. A Helm chart contains files that describe the necessary collection of Kubernetes resources. In this section, I’ll demonstrate how to download the required Helm charts and upload them to KubeSphere.

Download TiDB Helm Charts

  1. Install Helm. Based on your operating system and tools, there are several ways to install Helm. For detailed information, see the Helm documentation. The simplest to install Helm is to execute the following command directly:
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash

2. Add the PingCAP TiDB Helm repository:

helm repo add pingcap https://charts.pingcap.org/

3. View all the Helm charts in this repository:

Image for post
Image for post

Note that in this article, I use v1.1.6 charts. You can also get the latest version released by PingCAP.

4. Download the charts you need. For example:

helm pull pingcap/tidb-operator --version=v1.1.6 &&
helm pull pingcap/tidb-cluster --version=v1.1.6

5. Make sure they have been successfully pulled:

$ ls | grep tidb

tidb-cluster-v1.1.6.tgz
tidb-operator-v1.1.6.tgz

Upload Helm charts to KubeSphere

Now that you have Helm charts ready, you can upload them to KubeSphere as app templates.

  1. Log in to the KubeSphere web console and create a workspace.

I. In the upper left corner of the current page, click Platform to display the Access Control page.

II. In Workspaces, click Create to create a new workspace and give it a name; for example, dev-workspace as shown below.

Image for post
Image for post

2. Go to your workspace. From the navigation bar, select App Templates, and, on the right, click Upload Template.

Image for post
Image for post

My last blog post explained how to deploy TiDB using an app repository. This time, let’s upload Helm charts as app templates.

3. Select the Helm charts you want to upload to KubeSphere. After they are successfully uploaded, they appear in the list below.

Image for post
Image for post

Deploy TiDB Operator and a TiDB cluster

  1. To deploy TiDB, you need to create a project (also known as a namespace) where all workloads of an app run.
Image for post
Image for post

2. After you create the project, navigate to Applications and click Deploy New Application.

Image for post
Image for post

3. In the Deploy New Application dialog box, select From App Templates.

Image for post
Image for post

4. Deploy TiDB Operator and the TiDB cluster. In the drop-down list, select From workspace and click tidb-cluster and tidb-operator respectively to deploy them. For more information about how to configure them, see my last post.

Image for post
Image for post

All Helm charts uploaded individually as app templates appear on the From workspace page. If you add an app repository to KubeSphere to provide app templates, they display in other repositories in the drop-down list.

Release TiDB to the App Store

App templates enable you to deploy and manage apps in a visual way. Internally, they play an important role as shared resources. Enterprises create these resources — which include databases, middleware, and operating systems — 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 deploy these apps if they have the necessary permissions, regardless of the workspace they belong to.

  1. In the top left corner, click Platform and select Access Control.
  2. On the Workspaces page, click the workspace where you uploaded the Helm charts.
Image for post
Image for post

3. From the navigation bar, click App Templates, and you can see the uploaded apps. To release it to the App Store, click tidb-operator.

Image for post
Image for post

4. On the Versions page, click the version number to expand the menu and click Submit Review.

Image for post
Image for post

KubeSphere allows you to manage an app across its entire lifecycle, including deleting the version, testing the deployment, or submitting the App for review. 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 of the life cycle as they manage an app version.

5. Approve the app submitted for review. In the top left corner, click Platform and select App Store Management.

Image for post
Image for post

6. In the App Reviews page, click the app you just submitted.

Image for post
Image for post

7. In the App Info page that appears, review the app information and chart files. To approve the app, click Pass.

Image for post
Image for post

8. After the app is approved, you can release it to the App Store. In the top left corner, click Platform and select Access Control.

9. Go back to your workspace. From the navigation bar, select App Templates and click tidb-operator.

Image for post
Image for post

10. On the Versions page, click the version number again, and you can see that the status has reached Passed. The Submit Review button has changed to Release to Store.

11. Click Release to Store, and in the confirmation box, click OK.

Image for post
Image for post

12. To view the app released, in the top left corner, click App Store, and you can see it in the App Store. Likewise, you can use the same steps to deploy tidb-cluster to the App Store.

Image for post
Image for post

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 learn more about how an app is managed across its entire lifecycle.

Summary

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 groups can continue to deliver efficient and effective cloud-native tools for us in production.

If you have any questions, don’t hesitate to contact us in Slack or GitHub.

References

Originally published at www.pingcap.com on Nov 17, 2020

Written by

PingCAP is the team behind TiDB, an open source MySQL compatible NewSQL HTAP database. Official website: https://pingcap.com/ GitHub: https://github.com/pingcap

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store