Skip to content

Commit cb0faed

Browse files
committed
docs: add self-hosted HA guidance
1 parent dbde565 commit cb0faed

File tree

6 files changed

+149
-6
lines changed

6 files changed

+149
-6
lines changed

docs/administration/license.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ Bytebase offers [3 pricing plans](https://www.bytebase.com/pricing): `Free`, `Pr
1414
**Pro plan is cloud-only.** Self-hosted deployments require an Enterprise license. Existing Pro self-host licenses are grandfathered. Self-hosted Free instances can start a [14-day Enterprise trial](https://www.bytebase.com/contact-us/).
1515
</Info>
1616

17+
<Note>
18+
Running more than one self-hosted Bytebase replica requires HA to be enabled in the license. If multiple replicas are detected without HA enabled, Bytebase disables backend runners for safety.
19+
</Note>
20+
1721
## Configure Workspace License
1822

1923
Go to **Settings > Subscription**, paste your license and click **Upload License**.

docs/docs.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"get-started/self-host/deploy-with-docker",
3737
"get-started/self-host/deploy-with-kubernetes",
3838
"get-started/self-host/external-postgres",
39+
"get-started/self-host/high-availability",
3940
"get-started/self-host/network-architecture",
4041
"get-started/self-host/external-access",
4142
"get-started/self-host/external-url",
@@ -603,4 +604,4 @@
603604
"tagId": "GTM-MMG29QS6"
604605
}
605606
}
606-
}
607+
}

docs/get-started/self-host/deploy-with-kubernetes.mdx

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ title: Deploy with Kubernetes
66
## Deployment
77

88
<Note>
9-
10-
Make sure to set the replicas to **1**, otherwise, it may cause data race issues.
9+
Single-replica deployment still works as before. For multi-replica deployment, see [High Availability](/get-started/self-host/high-availability/).
1110

1211
</Note>
1312

@@ -20,7 +19,6 @@ metadata:
2019
name: bytebase
2120
namespace: default
2221
spec:
23-
# To prevent data races, only request one replica.
2422
replicas: 1
2523
selector:
2624
matchLabels:
@@ -92,6 +90,10 @@ spec:
9290

9391
Bytebase provides an official Helm chart for simplified Kubernetes deployments. For comprehensive configuration options and advanced settings, visit the [Bytebase Helm Chart on Artifact Hub](https://artifacthub.io/packages/helm/bytebase/bytebase).
9492

93+
<Note>
94+
The current official Helm chart deploys a single replica and does not yet expose HA-specific settings such as replica count and the `--ha` flag. If you want to run Bytebase in HA mode today, use a custom manifest based on this guide or customize the chart template before deploying.
95+
</Note>
96+
9597
### Installation
9698

9799
Deploy Bytebase using Helm with your external PostgreSQL database:
@@ -110,3 +112,46 @@ To remove the Bytebase deployment:
110112
```bash
111113
helm delete --namespace <YOUR_NAMESPACE> <RELEASE_NAME>
112114
```
115+
116+
## HA Deployment
117+
118+
To run Bytebase with multiple replicas on Kubernetes:
119+
120+
1. Configure an external PostgreSQL database with `PG_URL`.
121+
2. Set `replicas` to more than `1`.
122+
3. Add the `--ha` flag to every Bytebase replica.
123+
4. Put the replicas behind one stable ingress, gateway, or service entrypoint.
124+
5. Make sure the workspace license has HA enabled.
125+
126+
Example:
127+
128+
```yaml
129+
apiVersion: apps/v1
130+
kind: StatefulSet
131+
metadata:
132+
name: bytebase
133+
namespace: default
134+
spec:
135+
replicas: 2
136+
selector:
137+
matchLabels:
138+
app: bytebase
139+
serviceName: bytebase
140+
template:
141+
metadata:
142+
labels:
143+
app: bytebase
144+
spec:
145+
containers:
146+
- name: bytebase
147+
image: bytebase/bytebase:latest
148+
env:
149+
- name: PG_URL
150+
value: 'postgresql://<<user>>:<<secret>>@<<host>>:<<port>>/<<dbname>>'
151+
args:
152+
- '--port'
153+
- '8080'
154+
- '--ha'
155+
ports:
156+
- containerPort: 8080
157+
```

docs/get-started/self-host/external-postgres.mdx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ import TerminalDockerRunPgUrl from '/snippets/install/terminal-docker-run-pg-url
88

99
PostgreSQL 14 or above.
1010

11+
<Note>
12+
External PostgreSQL is required for [High Availability](/get-started/self-host/high-availability/). HA mode is not supported with Bytebase's embedded PostgreSQL.
13+
</Note>
14+
1115
### Database
1216

1317
Create a database named `bytebase` with UTF-8 encoding. UTF-8 encoding is required for proper system operation.
@@ -128,4 +132,3 @@ spec:
128132
<Note>
129133
When using file-based secrets, Kubernetes automatically updates the mounted file content when the Secret is updated (typically within a minute). Bytebase monitors the file for changes and automatically reloads the connection string, enabling seamless secret rotation without downtime.
130134
</Note>
131-
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
title: High Availability
3+
---
4+
5+
Bytebase supports high availability (HA) for self-hosted deployments.
6+
7+
In HA mode, you run multiple Bytebase replicas behind the same external endpoint. The replicas coordinate through the shared metadata PostgreSQL database, so scheduled work such as rollout tasks, plan checks, schema sync, and cancellation handling remains safe across replicas.
8+
9+
## Requirements
10+
11+
- Use an external PostgreSQL database for Bytebase metadata
12+
- Start every replica with the `--ha` flag
13+
- Put all replicas behind the same load balancer / ingress / service
14+
- Configure the same External URL for the deployment
15+
- Use a license with HA enabled
16+
17+
<Warning>
18+
HA mode does not work with Bytebase's embedded PostgreSQL. If `PG_URL` is not set, Bytebase will refuse to start in HA mode.
19+
</Warning>
20+
21+
## How It Works
22+
23+
- Each replica sends heartbeats to the metadata PostgreSQL database
24+
- Distributed coordination uses PostgreSQL advisory locks and row-level claiming
25+
- Long-running tasks are owned by a replica; stale work is detected if that replica stops heartbeating
26+
- Cancel signals are propagated across replicas through PostgreSQL `NOTIFY/LISTEN`
27+
28+
## Kubernetes Example
29+
30+
The example below shows the minimum HA-specific changes compared with a single-replica deployment:
31+
32+
```yaml
33+
apiVersion: apps/v1
34+
kind: StatefulSet
35+
metadata:
36+
name: bytebase
37+
namespace: default
38+
spec:
39+
replicas: 2
40+
selector:
41+
matchLabels:
42+
app: bytebase
43+
serviceName: bytebase
44+
template:
45+
metadata:
46+
labels:
47+
app: bytebase
48+
spec:
49+
containers:
50+
- name: bytebase
51+
image: bytebase/bytebase:latest
52+
env:
53+
- name: PG_URL
54+
value: "postgresql://<<user>>:<<secret>>@<<host>>:<<port>>/<<dbname>>"
55+
args:
56+
- "--port"
57+
- "8080"
58+
- "--ha"
59+
ports:
60+
- containerPort: 8080
61+
```
62+
63+
Use an ingress, gateway, or load balancer in front of the replicas so clients always access Bytebase through one stable URL.
64+
65+
## Operational Notes
66+
67+
- HA is mainly for Kubernetes or other orchestrated environments. A single `docker run` deployment is still a single-node setup.
68+
- Replicas do not require embedded PostgreSQL or shared local metadata storage.
69+
- If multiple replicas are running without HA enabled in the license, Bytebase disables backend runners to avoid unsafe execution.
70+
71+
## Related Guides
72+
73+
- [Production Setup](/get-started/self-host/production-setup/)
74+
- [Deploy with Kubernetes](/get-started/self-host/deploy-with-kubernetes/)
75+
- [Configure External PostgreSQL](/get-started/self-host/external-postgres/)
76+
- [Configure External URL](/get-started/self-host/external-url/)

docs/get-started/self-host/production-setup.mdx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ This page provides a comprehensive checklist for setting up Bytebase in a produc
1717

1818
### Storage
1919

20-
Bytebase uses a PostgreSQL database to store SQL statements and other metadata.
20+
Bytebase uses a PostgreSQL database to store SQL statements and other metadata.
2121

2222
- If using cloud services (RDS, Cloud SQL) that support disk expansion, you can start with 20 GB and increase the size later as usage grows
2323
- Otherwise, start with 100 GB to avoid running out of space
@@ -28,6 +28,7 @@ Teams that frequently work with large SQL files may need more.
2828

2929
- Review system requirements (see above)
3030
- [Configure External PostgreSQL](/get-started/self-host/external-postgres/)
31+
- Decide whether you need [High Availability](/get-started/self-host/high-availability/)
3132
- [Configure External Access](/get-started/self-host/external-access)
3233
- [Configure External URL](/get-started/self-host/external-url)
3334
- Pin Docker image to specific version instead of `latest` ([changelog](https://docs.bytebase.com/changelog))
@@ -39,6 +40,16 @@ Teams that frequently work with large SQL files may need more.
3940
docker pull bytebase/bytebase:3.7.0@sha256:00b436855b08739aad02fd52e41b5d74c03db9c70c49ce5de42376347cd1403c
4041
```
4142

43+
## High Availability Checklist
44+
45+
If you plan to run Bytebase with multiple replicas:
46+
47+
- Use external PostgreSQL. HA is not supported with embedded PostgreSQL
48+
- Start every replica with `--ha`
49+
- Put replicas behind one ingress, gateway, or load balancer
50+
- Set the same External URL for the whole deployment
51+
- Confirm your license has HA enabled before scaling above one replica
52+
4253
### Monitoring
4354

4455
- Telemetry metrics available at `/metrics` endpoint
@@ -48,13 +59,16 @@ Teams that frequently work with large SQL files may need more.
4859
If deploying on a cloud provider, use the recommended stack:
4960

5061
#### AWS
62+
5163
- **Compute**: EC2 or ECS/EKS
5264
- **Database**: RDS for PostgreSQL
5365

5466
#### GCP
67+
5568
- **Compute**: GCE or GKE
5669
- **Database**: Cloud SQL for PostgreSQL
5770

5871
#### Azure
72+
5973
- **Compute**: Virtual Machines or AKS
6074
- **Database**: Azure Database for PostgreSQL

0 commit comments

Comments
 (0)