Setting Up a Cluster on Google Cloud Platform (GCP) With Terraform
Last updated
Last updated
News & Blog
BlogGet Support
Request Enterprise SolutionsExpanso (2024). All Rights Reserved.
Welcome to the guide for setting up your own Bacalhau cluster across multiple Google Cloud Platform (GCP) regions! This guide will walk you through creating a robust, distributed compute cluster that's perfect for running your Bacalhau workloads.
Think of this as building your own distributed supercomputer! Your cluster will provision compute nodes spread across different GCP regions for global coverage.
You'll need a few things ready:
Terraform (version 1.0.0 or newer)
A running Bacalhau orchestrator node
Google Cloud SDK installed and set up
An active GCP billing account
Your organization ID handy
An SSH key pair for securely accessing your nodes
Clone the examples repo to your machine and go into the GCP directory.
Now, make a copy of the example environment file:
Open up env.json
and fill in your GCP details (more on this below!)
Update your config/config.yaml
with your orchestrator information. Specifically, these lines:
L
Let Terraform get everything ready:
Launch your cluster:
The entire process takes about 8 minutes, but should end with something like the below:
You're good to go!
The env.json
file is where all the magic happens. Here's what you'll need to fill in:
bootstrap_project_id
: Your existing GCP project (just used for setup)
base_project_name
: What you want to call your new project
gcp_billing_account_id
: Where the charges should go
gcp_user_email
: Your GCP email address
org_id
: Your organization's ID
app_tag
: A friendly name for your resources (like "bacalhau-demo")
bacalhau_data_dir
: Where job data should be stored
bacalhau_node_dir
: Where node configs should live
username
: Your SSH username
public_key
: Path to your SSH public key
You can set up nodes in different regions with custom configurations:
Once everything's up and running, let's make sure it works!
First, make sure you have the Bacalhau CLI installed. You can read more about installing the CLI here.
First configure the CLI to use your cluster:
Check on the health of your nodes:
If you're using the Expanso Cloud hosted orchestrator (Recommended!), you can look at your nodes on the Expanso Cloud dashboard in real-time.
Run a simple test job:
Check on your jobs:
Get your results:
Having issues? Here are some common solutions:
Double-check your GCP permissions
Make sure your billing account is active
Verify that all needed APIs are turned on in GCP
Look at the logs on a node: journalctl -u bacalhau-startup.service
Check Docker logs on a node: docker logs <container-id>
Make sure that port 4222 isn't blocked
Verify your NATS connection settings
Check if nodes are properly registered
Make sure compute is enabled in your config
When you're done, clean everything up with:
If you need to peek under the hood, here's how:
Find your node IPs:
SSH into a node:
Check on Docker:
Go into the container on the node:
Here's what each important file does in your setup:
main.tf
: Your main Terraform configuration
variables.tf
: Where input variables are defined
outputs.tf
: What information Terraform will show you
config/config.yaml
: How your Bacalhau nodes are configured
scripts/startup.sh
: Gets your nodes ready to run
scripts/bacalhau-startup.service
: Manages the Bacalhau service
cloud-init/init-vm.yml
: Sets up your VM environment, installs packages, and gets services running
config/docker-compose.yml
: Runs Bacalhau in a privileged container with all the right volumes and health checks
The neat thing is that most of your configuration happens in just one file: env.json
. Though if you want to get fancy, there's lots more you can customize!
If you get stuck or have questions:
Check out the official Bacalhau Documentation
Open an issue in our GitHub repository
Join our Slack
We're here to help you get your cluster running smoothly! 🌟
We recommend using Expanso Cloud to create your network! But if you'd like to set up a cluster on your own, you can use our tool Andaime to do this too.
If you have any questions about the platform - please contact us on Slack or Email us!