Set up the data plane
Deploy the Braintrust data plane infrastructure in your Google Cloud project.Configure the Terraform module
The Braintrust Terraform module contains all the necessary resources for a self-hosted Braintrust data plane. A dedicated Google Cloud project for your Braintrust deployment is recommended but not required.
-
Copy the entire contents of the
examples/braintrust-data-planedirectory from the terraform-google-braintrust-data-plane repository into your own repository. -
In
provider.tf, configure your Google Cloud project and region. -
In
backend.tf, set up your remote backend (typically a GCS bucket). -
In
main.tf, customize the Braintrust deployment settings. The defaults are for suitable for a large production-sized deployment. Adjust them based on your needs, but keep in mind the hardware requirements.
Enable Google Cloud APIs
Before deploying, enable the required Google Cloud services. Run the following in Cloud Shell:
-
In a Cloud Shell, set the project to deploy Braintrust into:
-
Enable the required services:
Deploy the Terraform module
Initialize and apply the Terraform configuration:This will create all necessary GCP resources including:
- GKE cluster for running Braintrust services
- Cloud SQL PostgreSQL database
- Cloud Memorystore Redis cache
- Cloud Storage buckets
- VPC network and subnets
- Cloud KMS key for encryption
Connect to GKE cluster
After the Terraform deployment completes, connect to your GKE cluster:Verify the connection:
Create Kubernetes secrets
Create the required Kubernetes secrets for your deployment. The secrets needed depend on your GCS authentication method. See that section below for the specific commands.
Configure Helm values
Create a
helm-values.yaml file for your deployment. Refer to the Helm chart documentation for configuration options.Deploy Helm chart
Deploy the Braintrust Helm chart to your cluster. Refer to the Helm chart documentation for configuration options.
Get your API URL
The dataplane requires a HTTPS connection to the API pods. This connection will require a valid HTTPS certificate that is trusted by the clients connecting to the data plane. Although Google doesn’t have a native service, there are several ways to provide a DNS name with a SSL certificate.
- Use Cloud Run to run a NGINX container to do SSL termination.
- Use a Load balancer for the API service with a certificate from an internal CA or with Let’s Encrypt.
GCS authentication options
Braintrust services use different authentication methods for Google Cloud Storage:- API: Can use either native GCS authentication (recommended) or S3 compatibility mode with HMAC keys (legacy)
- Brainstore: Always uses native GCS authentication via Workload Identity
Workload Identity setup
The Terraform module automatically configures Workload Identity for your GKE cluster and creates service accounts with storage permissions for both the API and Brainstore services.API authentication configuration
Choose one of the following authentication methods for the API service:- Native GCS auth (recommended)
- S3 compatibility mode (legacy)
Native GCS authentication uses the Helm configuration:In your Helm values file, enable native GCS authentication and configure the Google service account:
@google-cloud/storage SDK and Workload Identity. This is the recommended approach for enhanced security as it eliminates the need to manage service account keys.Requirements:- Helm chart version 3.1.0 or later
- Workload Identity configured (automatic with Terraform module)
Refer to the Terraform outputs for the connection strings. The Brainstore license key can be found in your Braintrust organization’s Settings > Data plane page.
The Terraform module outputs the service account email as
braintrust_service_account. Run terraform output braintrust_service_account to get the full email address.The enableGcsAuth setting defaults to false for backwards compatibility, but will default to true in a future release.Brainstore configuration
Brainstore always uses native GCS authentication. In your Helm values file, configure the Google service account for Workload Identity:The Terraform module outputs the service account email as
brainstore_service_account. Run terraform output brainstore_service_account to get the full email address.Configure your organization
Connect your Braintrust organization to your newly deployed data plane.Point your organization to your data plane
- In the Braintrust UI, go to Settings > Data plane.
- In API URL area, select Edit.
- Enter the API URL from the last step.
- Leave the other fields blank.
- Select Save.
Update the deployment
Updating your GCP deployment involves two steps: updating infrastructure with Terraform and updating services with Helm.Update infrastructure (Terraform)
Runterraform apply to update infrastructure components (database, Redis, networking, storage, etc.):
?ref=<version> to the module source:
Update services (Helm)
After updating infrastructure, upgrade the Helm chart to update service containers and configurations:In some cases, Terraform changes must be applied before Helm upgrades. Check the release notes for any specific upgrade ordering requirements.