Bacalhau Docs
GithubSlackBlogEnterprise
  • Documentation
  • Use Cases
  • CLI & API
  • References
  • Community
  • Operators & Deployment
    • Deployment Guide
      • Setting Up a Cluster on Amazon Web Services (AWS) with Terraform 🚀
      • Setting Up a Cluster on Google Cloud Platform (GCP) With Terraform 🚀
      • Setting Up a Cluster on Azure with Terraform 🚀
      • Marketplace Deployments
        • Google Cloud Marketplace
  • Setting Up
    • Running Nodes
      • Node Onboarding
      • GPU Installation
      • Job selection policy
      • Access Management
      • Persistent State
      • Configuring Your Input Sources
      • Configuring Transport Level Security
      • Limits and Timeouts
      • Bacalhau WebUI
    • Workload Onboarding
      • Container
        • Docker Workload Onboarding
        • Bacalhau Docker Image
        • How To Work With Custom Containers in Bacalhau
        • Run CUDA programs on Bacalhau
      • WebAssembly (Wasm) Workloads
        • Running Rust programs as WebAssembly (WASM)
      • Python
        • Running a Python Script
    • Networking Instructions
      • Accessing the Internet from Jobs
    • GPU Workloads Setup
    • Automatic Update Checking
    • Node Management
    • Authentication & Authorization
    • Inter-Nodes TLS
    • Hardware Setup
  • Developer Resources
    • Running Locally In Devstack
  • Guides
    • Jobs Guide
      • Queuing
      • Labels and Constraints
    • Configuration Management
      • Write a config.yaml
  • Help & FAQ
    • Bacalhau FAQs
    • Glossary
Powered by GitBook
LogoLogo

Use Cases

  • Distributed ETL
  • Edge ML
  • Distributed Data Warehousing
  • Fleet Management

About Us

  • Who we are
  • What we value

News & Blog

  • Blog

Get Support

  • Request Enterprise Solutions

Expanso (2025). All Rights Reserved.

On this page
  • What You'll Build
  • Before You Start
  • Quick Setup Guide
  • Understanding the Configuration
  • Taking Your Cluster for a Test Drive
  • Troubleshooting Tips
  • Cleaning Up
  • Need to Check on Things?
  • Understanding the Configuration Files
  • Azure Specific Commands
  • Need Help?

Was this helpful?

Export as PDF
  1. Operators & Deployment
  2. Deployment Guide

Setting Up a Cluster on Azure with Terraform 🚀

PreviousSetting Up a Cluster on Google Cloud Platform (GCP) With Terraform 🚀NextMarketplace Deployments

Last updated 2 months ago

Was this helpful?

Welcome to the guide for setting up your own Bacalhau cluster across multiple Azure regions! This guide will walk you through creating a robust, distributed compute cluster that's perfect for running your Bacalhau workloads.

What You'll Build

Think of this as building your own distributed supercomputer! Your cluster will provision compute nodes spread across different Azure regions for global coverage.

Before You Start

You'll need a few things ready:

  • Terraform (version 1.0.0 or newer)

  • A running Bacalhau orchestrator node

  • Azure CLI installed and set up

  • An active Azure subscription

  • Your subscription ID handy

  • An SSH key pair for securely accessing your nodes

Quick Setup Guide

  1. First, create a terraform.tfvars.json file with your Azure details:

    cp terraform.tfvars.example.json terraform.tfvars.json
  2. Open up terraform.tfvars.json and fill in your Azure details:

     "subscription_id": "f67231aa-8387-498b-9ca3-EXAMPLE",
     "app_tag": "bacalhau-cluster",
     "resource_group_region": "eastus",
     "username": "bacalhau-runner",
     "public_key": "~/.ssh/id_rsa.pub",
     "bacalhau_data_dir": "/bacalhau_data",
     "bacalhau_node_dir": "/bacalhau_node",
     "bacalhau_config_file_path": "./config/config.yaml",
    
     "locations": {
         "eastus": {
             "machine_type": "Standard_D4_v4",
             "node_count": 1
         }
    }
  3. Update your config/config.yaml with your orchestrator information. Specifically, these lines:

  Orchestrators:
    - nats://EXAMPLE-7a02-4083-bf08-bcc2f5fbc025.us1.cloud.expanso.dev:4222
  Auth:
    Token: "EXAMPLE-aEEFukWVffnf5jb9QkpNnwfiBWEk3475csM7ysudpbFTzYBap5c7sWr6"
  1. Let Terraform get everything ready:

    terraform init
  2. Launch your cluster:

    terraform apply

Understanding the Configuration

The infrastructure is organized into modules:

  • Network: Creates VNets and subnets in each region

  • Security Group: Sets up NSGs with rules for SSH, HTTP, and NATS

  • Instance: Provisions VMs with cloud-init configuration

Taking Your Cluster for a Test Drive

Once everything's up and running, let's make sure it works!

  1. Setup your configuration to point at your orchestrator node:

    bacalhau config set -c API.Host=<ip-address-of-orchestrator>
  2. Check on the health of your nodes:

    bacalhau node list
  3. Run a simple test job:

    bacalhau docker run docker.io/bacalhauproject/hello-world
  4. Check on your jobs:

    bacalhau list
  5. Get your results:

    bacalhau get <job-id>

Troubleshooting Tips

Having issues? Here are some common solutions:

Deployment Problems

  • Double-check your Azure permissions

  • Make sure your subscription is active

  • Verify that all needed resource providers are registered

Node Health Issues

  • 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

Job Running Troubles

  • Verify your NATS connection settings

  • Check if nodes are properly registered

  • Make sure compute is enabled in your config

Cleaning Up

When you're done, clean everything up with:

terraform destroy

Need to Check on Things?

If you need to peek under the hood, here's how:

  1. Find your node IPs:

    terraform output deployment_status
  2. SSH into a node:

    ssh -i ~/.ssh/id_rsa <username>@<public-ip>
  3. Check on Docker:

    docker ps
  4. Go into the container on the node:

    CONTAINER_ID=$(docker ps --filter name=^/bacalhau_node --format '{{.ID}}' | head -n1)
    docker exec -it $CONTAINER_ID /bin/bash

Understanding the Configuration Files

Here's what each important file does in your setup:

Core Files

  • main.tf: Your main Terraform configuration

  • variables.tf: Where input variables are defined

  • outputs.tf: What information Terraform will show you

Modules

  • modules/network: Handles VNet and subnet creation

  • modules/securityGroup: Manages network security groups

  • modules/instance: Provisions VMs with cloud-init

Cloud-Init and Docker Setup

  • 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

Azure Specific Commands

For ensuring that you have configured your Azure CLI correctly, here are some commands you can use:

Get available Azure locations

az account list-locations --query "[].{Name:name, DisplayName:displayName}" -o table

Get available VM sizes in a region

az vm list-sizes --location eastus --query "[].{Name:name, vCPUs:numberOfCores, MemoryGB:memoryInMb, GPUs:gpus}" --output table

Get your subscription ID

az account show --query "id"

Need Help?

If you get stuck or have questions:

We're here to help you get your cluster running smoothly! 🌟

First, make sure you have the Bacalhau CLI installed. You can read more about installing the CLI .

Open an issue in our

Join our

here
GitHub repository
Slack