-
Notifications
You must be signed in to change notification settings - Fork 688
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add TiDB serverless branching in Vercel integration #14835
Merged
Merged
Changes from 11 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
6aec2de
Add TiDB serverless branching in Vercel integration
xuanyu66 774aea6
Add pics
xuanyu66 e423783
polish
xuanyu66 a6ca004
Change connect type
xuanyu66 98573da
rearrange the doc structure
xuanyu66 4de8e72
polish
xuanyu66 422736e
Apply suggestions from code review
xuanyu66 1024c03
polish
xuanyu66 522138d
Add note
xuanyu66 fcbfb06
Apply suggestions from code review
ran-huang c193244
Update tidb-cloud/integrate-tidbcloud-with-vercel.md
xuanyu66 8d99edf
Apply suggestions from code review
xuanyu66 7d0806b
Use Git
xuanyu66 e3618f2
Apply suggestions from code review
ran-huang 9544432
fix lint
xuanyu66 656e46a
Add missing env
xuanyu66 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-8.23 KB
(76%)
media/tidb-cloud/vercel/integration-vercel-configuration-page.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -18,7 +18,7 @@ This guide describes how to connect your TiDB Cloud clusters to Vercel projects | |||||
|
||||||
For both of the preceding methods, TiDB Cloud provides the following options for programmatically connecting to your database: | ||||||
|
||||||
- Direct connection: connect your TiDB Cloud cluster to your Vercel project directly using MySQL's standard connection system. | ||||||
- Cluster: connect your TiDB Cloud cluster to your Vercel project with direct connections or [serverless driver](/tidb-cloud/serverless-driver.md). | ||||||
- [Data App](/tidb-cloud/data-service-manage-data-app.md): access data of your TiDB Cloud cluster through a collection of HTTP endpoints. | ||||||
|
||||||
## Prerequisites | ||||||
|
@@ -48,7 +48,7 @@ You are expected to have an account and a cluster in TiDB Cloud. If you do not h | |||||
|
||||||
> **Note:** | ||||||
> | ||||||
> For TiDB Dedicated clusters, make sure that the traffic filter of the cluster allows all IP addresses (set to `0.0.0.0/0`) for connection, because Vercel deployments use [dynamic IP addresses](https://vercel.com/guides/how-to-allowlist-deployment-ip-address). If you use the TiDB Cloud Vercel integration, TiDB Cloud automatically adds a `0.0.0.0/0` traffic filter to your cluster in the integration workflow if there is none. | ||||||
> For TiDB Dedicated clusters, make sure that the traffic filter of the cluster allows all IP addresses (set to `0.0.0.0/0`) for connection, because Vercel deployments use [dynamic IP addresses](https://vercel.com/guides/how-to-allowlist-deployment-ip-address). | ||||||
|
||||||
To [integrate with Vercel via the TiDB Cloud Vercel Integration](#connect-via-the-tidb-cloud-vercel-integration), you are expected to be in the `Organization Owner` role of your organization or the `Project Owner` role of the target project in TiDB Cloud. For more information, see [User roles](/tidb-cloud/manage-user-access.md#user-roles). | ||||||
|
||||||
|
@@ -69,10 +69,14 @@ One Vercel project can only connect to one TiDB Cloud Data App. To change the Da | |||||
|
||||||
To connect via the TiDB Cloud Vercel integration, go to the [TiDB Cloud integration](https://vercel.com/integrations/tidb-cloud) page from the [Vercel's Integrations Marketplace](https://vercel.com/integrations). Using this method, you can choose which cluster to connect to, and TiDB Cloud will automatically generate all the necessary environment variables for your Vercel projects. | ||||||
|
||||||
> **Note:** | ||||||
> | ||||||
> This method is only available for TiDB Serverless clusters. If you want to use a TiDB Dedicated cluster, use the [manual method](#connect-via-manually-setting-environment-variables). | ||||||
xuanyu66 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
The detailed steps are as follows: | ||||||
xuanyu66 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
<SimpleTab> | ||||||
<div label="Direct connection"> | ||||||
<div label="Cluster"> | ||||||
|
||||||
1. Click **Add Integration** in the upper-right area of the [TiDB Cloud Vercel integration](https://vercel.com/integrations/tidb-cloud) page. The **Add TiDB Cloud** dialog is displayed. | ||||||
2. Select the scope of your integration in the drop-down list and click **Continue**. | ||||||
|
@@ -84,8 +88,10 @@ The detailed steps are as follows: | |||||
2. Select your target TiDB Cloud organization and project. | ||||||
3. Select **Cluster** as your connection type. | ||||||
4. Select your target TiDB Cloud cluster. If the **Cluster** drop-down list is empty or you want to select a new TiDB Serverless cluster, click **+ Create Cluster** in the list to create one. | ||||||
5. Select the framework that your Vercel projects are using. If the target framework is not listed, select **General**. Different frameworks determine different environment variables. | ||||||
6. Click **Add Integration and Return to Vercel**. | ||||||
5. Select the database that you want to connect to. If the **Database** drop-down list is empty or you want to select a new Database, click **+ Create Database** in the list to create one. | ||||||
6. Select the framework that your Vercel projects are using. If the target framework is not listed, select **General**. Different frameworks determine different environment variables. | ||||||
7. Choose whether to create new branches for preview environments. | ||||||
xuanyu66 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
8. Click **Add Integration and Return to Vercel**. | ||||||
|
||||||
![Vercel Integration Page](/media/tidb-cloud/vercel/integration-link-cluster-page.png) | ||||||
|
||||||
|
@@ -102,13 +108,13 @@ The detailed steps are as follows: | |||||
TIDB_PASSWORD | ||||||
``` | ||||||
|
||||||
For TiDB Dedicated clusters, the root CA is set in this variable: | ||||||
**Prisma** | ||||||
|
||||||
``` | ||||||
TIDB_SSL_CA | ||||||
DATABASE_URL | ||||||
``` | ||||||
|
||||||
**Prisma** | ||||||
xuanyu66 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
**TiDB Cloud Serverless Driver** | ||||||
|
||||||
``` | ||||||
DATABASE_URL | ||||||
|
@@ -145,19 +151,74 @@ The detailed steps are as follows: | |||||
</div> | ||||||
</SimpleTab> | ||||||
|
||||||
### Configure connections | ||||||
|
||||||
If you have installed [TiDB Cloud Vercel integration](https://vercel.com/integrations/tidb-cloud), you can add or remove connections inside the integration. | ||||||
|
||||||
1. In your Vercel dashboard, click **Integrations**. | ||||||
2. Click **Manage** in the TiDB Cloud entry. | ||||||
3. Click **Configure**. | ||||||
4. Click **Add Link** or **Remove** to add or remove connections. | ||||||
|
||||||
![Vercel Integration Configuration Page](/media/tidb-cloud/vercel/integration-vercel-configuration-page.png) | ||||||
|
||||||
When you remove a connection, the environment variables set by the integration workflow are removed from the Vercel project, too. However, this action does not affect the data of the TiDB Serverless cluster. | ||||||
|
||||||
### Connect with TiDB Serverless branching | ||||||
|
||||||
Vercel's [Preview Deployments](https://vercel.com/docs/deployments/preview-deployments) feature allows you to preview changes to your app in a live deployment without merging those changes to your Git project's production branch. With [TiDB Serverless Branching](/tidb-cloud/branch-overview.md), you can create a new instance for each branch of your Vercel project. This allows you to preview app changes in a live deployment without affecting your production data. | ||||||
|
||||||
> **Note:** | ||||||
> | ||||||
> Currently, TiDB Serverless branching only supports [Vercel projects associated with GitHub repositories](https://vercel.com/docs/deployments/git/vercel-for-github). | ||||||
|
||||||
To enable TiDB Serverless Branching, you need to: | ||||||
xuanyu66 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
1. Select **Cluster** as your connection type. | ||||||
2. Enable TiDB Serverless Branching in the TiDB Cloud Vercel integration workflow. | ||||||
xuanyu66 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
After you push changes to GitHub repository, Vercel will trigger a preview deployment. And then TiDB Cloud integration will automatically create a TiDB Serverless branch for the branch and set environment variables. The detailed steps are as follows: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
1. Create a new branch in your Git repository. | ||||||
xuanyu66 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
```shell | ||||||
cd tidb-prisma-vercel-demo1 | ||||||
git checkout -b new-branch | ||||||
``` | ||||||
|
||||||
2. Add some changes and push the changes to the remote repository. | ||||||
3. Vercel will trigger a preview deployment for the new branch. | ||||||
|
||||||
![Vercel Preview_Deployment](/media/tidb-cloud/vercel/vercel-preview-deployment.png) | ||||||
xuanyu66 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
1. During the deployment, TiDB Cloud integration will automatically create a TiDB Serverless branch with the same name as the git branch. If the TiDB Serverless branch already exists, TiDB Cloud integration will skip this step. | ||||||
xuanyu66 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
![TiDB_Cloud_Branch_Check](/media/tidb-cloud/vercel/tidbcloud-branch-check.png) | ||||||
|
||||||
2. After the TiDB Serverless branch is ready, TiDB Cloud integration will set environment variables in the preview deployment for the Vercel project. | ||||||
|
||||||
![Preview_Envs](/media/tidb-cloud/vercel/preview-envs.png) | ||||||
|
||||||
3. TiDB Cloud integration will also register a blocking check to wait for the TiDB Serverless branch to be ready. You can rerun the check manually. | ||||||
4. After the check is passed, you can visit the preview deployment to see the changes. | ||||||
|
||||||
> **Note:** | ||||||
> | ||||||
> Due to the limitation of Vercel deployment workflow, the environment variable can't be ensured to be set in the deployment. Please redeploy if facing this issue. | ||||||
xuanyu66 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
> **Note:** | ||||||
> | ||||||
> For each organization in TiDB Cloud, you can create a maximum of five TiDB Serverless branches by default. To avoid exceeding the limit, you can delete the TiDB Serverless branches that are no longer needed. For more information, see [Manage TiDB Serverless branches](/tidb-cloud/branch-manage.md). | ||||||
|
||||||
## Connect via manually setting environment variables | ||||||
|
||||||
<SimpleTab> | ||||||
<div label="Direct connection"> | ||||||
<div label="Cluster"> | ||||||
|
||||||
1. Get the connection information of your TiDB cluster. | ||||||
|
||||||
You can get the connection information from the connection dialog of your cluster. To open the dialog, go to the [**Clusters**](https://tidbcloud.com/console/clusters) page of your project, click the name of your target cluster to go to its overview page, and then click **Connect** in the upper-right corner. | ||||||
|
||||||
> **Note:** | ||||||
> | ||||||
> For TiDB Dedicated clusters, make sure that you have set the **Allow Access from Anywhere** traffic filter in this step. | ||||||
|
||||||
2. Go to your Vercel dashboard > Vercel project > **Settings** > **Environment Variables**, and then [declare each environment variable value](https://vercel.com/docs/concepts/projects/environment-variables#declare-an-environment-variable) according to the connection information of your TiDB cluster. | ||||||
|
||||||
![Vercel Environment Variables](/media/tidb-cloud/vercel/integration-vercel-environment-variables.png) | ||||||
|
@@ -200,16 +261,3 @@ You can get the information of `<User>`, `<Password>`, `<Endpoint>`, `<Port>`, a | |||||
|
||||||
</div> | ||||||
</SimpleTab> | ||||||
|
||||||
## Configure connections | ||||||
|
||||||
If you have installed [TiDB Cloud Vercel integration](https://vercel.com/integrations/tidb-cloud), you can add or remove connections inside the integration. | ||||||
|
||||||
1. In your Vercel dashboard, click **Integrations**. | ||||||
2. Click **Manage** in the TiDB Cloud entry. | ||||||
3. Click **Configure**. | ||||||
4. Click **Add Link** or **Remove** to add or remove connections. | ||||||
|
||||||
![Vercel Integration Configuration Page](/media/tidb-cloud/vercel/integration-vercel-configuration-page.png) | ||||||
|
||||||
When you remove a connection, environment variables set by the integration workflow are removed from the Vercel project either. The traffic filter and the data of the TiDB Cloud cluster are not affected. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
预览里这张图片看起来有点模糊