You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: improve GCP service account authentication documentation (#839)
- Rewrite GCP Secret Manager section to use GCE VM service accounts (most secure method)
- Create shared Prerequisites section for service account setup (GCE and GKE)
- Consolidate to single 'bytebase' service account instead of multiple accounts
- Add GKE with Workload Identity support
- Remove duplicate content between Cloud SQL and Secret Manager sections
- Fix IAM user creation methods (gcloud/Console, not SQL commands)
- Correct username formats for MySQL and PostgreSQL
- Reduce documentation wordiness by ~50%
- Remove 7 obsolete screenshot images
- Add comprehensive Google Cloud documentation references
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-authored-by: Claude <[email protected]>
@@ -301,150 +301,127 @@ Go to instance setting, specify `bytebase` as the Secret name and `DB_PASSWORD`
301
301
302
302
## GCP Configuration
303
303
304
-
### Cloud SQL with IAM Authentication
304
+
### Prerequisites: Service Account Setup
305
305
306
-
This guide demonstrates the most secure method for IAM authentication using GCE VM service accounts, which eliminates the need to manage service account keys.
307
-
308
-
For alternative authentication methods, refer to the official Google Cloud documentation:
309
-
-[Cloud SQL IAM database authentication overview](https://cloud.google.com/sql/docs/mysql/iam-authentication)
310
-
-[Using automatic IAM database authentication](https://cloud.google.com/sql/docs/mysql/iam-authentication#automatic)
311
-
-[Configuring instances for IAM database authentication](https://cloud.google.com/sql/docs/mysql/create-edit-iam-instances)
312
-
-[Managing users with IAM database authentication](https://cloud.google.com/sql/docs/mysql/iam-users)
313
-
314
-
#### Step 1: Create and Configure GCE VM with Service Account
315
-
316
-
1.**Create a Service Account**
317
-
- Go to [IAM & Admin → Service Accounts](https://console.cloud.google.com/iam-admin/serviceaccounts)
318
-
- Click **Create Service Account**
319
-
- Name: `bytebase-cloudsql`
320
-
- Description: "Service account for Bytebase to connect to Cloud SQL"
321
-
- Click **Create and Continue**
322
-
323
-
2.**Grant Required Permissions**
324
-
- Add these roles to the service account:
325
-
-`Cloud SQL Client` (for database connections)
326
-
-`Cloud SQL Instance User` (for IAM authentication)
327
-
- Click **Continue** and then **Done**
328
-
- Note the service account email: `bytebase-cloudsql@PROJECT_ID.iam.gserviceaccount.com`
329
-
330
-
3.**Create GCE VM with Service Account**
331
-
- Go to [Compute Engine → VM instances](https://console.cloud.google.com/compute/instances)
332
-
- Click **Create Instance**
333
-
- Under **Identity and API access**:
334
-
- Service account: Select `bytebase-cloudsql@PROJECT_ID.iam.gserviceaccount.com`
335
-
- Access scopes: Select "Allow full access to all Cloud APIs" or manually select Cloud SQL scopes
336
-
- Configure other VM settings as needed
337
-
- Click **Create**
338
-
339
-
> **Security Best Practice:** The VM automatically receives credentials through the metadata service. No service account keys are needed, reducing security risks. Learn more: [Service account impersonation](https://cloud.google.com/iam/docs/service-account-impersonation)
340
-
341
-
#### Step 2: Configure Cloud SQL Instance
342
-
343
-
1.**Enable IAM Authentication**
344
-
- Go to [Cloud SQL Instances](https://console.cloud.google.com/sql/instances)
345
-
- Select your instance or create a new one
346
-
- Click **Edit**
347
-
- Under **Customize your instance** → **Flags**:
348
-
- Add flag: `cloudsql_iam_authentication` = `on`
349
-
- Click **Save**
350
-
351
-
Reference: [Configuring instances for IAM authentication](https://cloud.google.com/sql/docs/mysql/create-edit-iam-instances)
306
+
Use attached service accounts for secure, key-free authentication on:
307
+
-**GCE** - VMs with attached service accounts
308
+
-**GKE** - Pods with Workload Identity
352
309
353
-
2.**Verify SSL/TLS Configuration**
354
-
- SSL is required for IAM authentication
355
-
- Cloud SQL enables SSL by default - no additional configuration needed
Connect to your Cloud SQL instance using the root user or an admin account:
314
+
1. Go to [IAM & Admin → Service Accounts](https://console.cloud.google.com/iam-admin/serviceaccounts)
315
+
2. Create service account named `bytebase`
316
+
3. Grant roles as needed:
317
+
-`Cloud SQL Client` and `Cloud SQL Instance User` - for Cloud SQL
318
+
-`Secret Manager Secret Accessor` - for Secret Manager
319
+
4. Note the email: `bytebase@PROJECT_ID.iam.gserviceaccount.com`
361
320
362
-
**Cloud SQL for MySQL:**
363
-
```sql
364
-
CREATE USER 'bytebase-cloudsql'@'%' IDENTIFIED WITH 'cloudsql_iam_user';
365
-
```
321
+
#### Attach Service Account
366
322
367
-
**Cloud SQL for PostgreSQL:**
368
-
```sql
369
-
CREATE USER "bytebase-cloudsql@PROJECT_ID.iam" WITH LOGIN;
370
-
GRANT cloudsqliamuser TO "bytebase-cloudsql@PROJECT_ID.iam";
371
-
```
323
+
**Option A: GCE VM**
324
+
1. Create VM in [Compute Engine](https://console.cloud.google.com/compute/instances)
325
+
2. Set service account: `bytebase@PROJECT_ID.iam.gserviceaccount.com`
326
+
3. Set access scopes: "Allow full access to all Cloud APIs"
372
327
373
-
Reference: [MySQL IAM users](https://cloud.google.com/sql/docs/mysql/iam-users) | [PostgreSQL IAM users](https://cloud.google.com/sql/docs/postgres/iam-users)
374
-
375
-
#### Step 4: Deploy Bytebase on GCE VM
328
+
**Option B: GKE with Workload Identity**
329
+
```bash
330
+
# Create Kubernetes service account
331
+
kubectl create serviceaccount bytebase-ksa
376
332
377
-
Deploy Bytebase on your GCE VM instance. The VM's attached service account credentials are automatically available to Bytebase through the metadata service - no GOOGLE_APPLICATION_CREDENTIALS configuration needed.
The GCE VM approach eliminates service account key management - credentials are automatically handled through the metadata service. Learn more: [Application Default Credentials](https://cloud.google.com/docs/authentication/application-default-credentials) | [Troubleshooting IAM authentication](https://cloud.google.com/sql/docs/mysql/iam-authentication#troubleshooting)
395
-
</Tip>
345
+
Deploy Bytebase on your resource - credentials are provided automatically.
396
346
397
-
###GCP Secret Manager
347
+
#### Alternative: Service Account Keys
398
348
399
-
#### Create a service account to access the Secret Manager
349
+
<Warning>
350
+
Use only when running Bytebase outside GCP. See [why to avoid service account keys](https://cloud.google.com/iam/docs/best-practices-for-managing-service-account-keys#avoid).
351
+
</Warning>
400
352
401
-
<Tip>
402
-
It's recommended to create a dedicated service account for Bytebase to retrieve the secrets. You only need to do this once.
Store database passwords securely in Google Cloud Secret Manager instead of Bytebase.
432
406
433
-
Restart Bytebase by specifying `GOOGLE_APPLICATION_CREDENTIALS`=`private key file` as an environment variable. The private key file is the JSON file downloaded before for the service account.
407
+
<Note>
408
+
Prerequisites: [Service account](#prerequisites-service-account-setup) with `Secret Manager Secret Accessor` role.
409
+
</Note>
434
410
435
-
<Tip>
436
-
If you run Bytebase in docker, you need to put the JSON file under the mounted directory. Otherwise, Bytebase won't be able to access the key file.
0 commit comments