From 66474cd2c888e1228f38e0098a360ea3a526d96e Mon Sep 17 00:00:00 2001 From: Nick Petrovic Date: Thu, 18 Jan 2024 21:50:02 -0500 Subject: [PATCH] add crusoe cloud deployment --- .gitignore | 5 ++++- deploy/crusoe/README.md | 25 +++++++++++++++++++++++ deploy/crusoe/config.tf | 8 ++++++++ deploy/crusoe/main.tf | 42 ++++++++++++++++++++++++++++++++++++++ deploy/crusoe/outputs.tf | 3 +++ deploy/crusoe/variables.tf | 20 ++++++++++++++++++ 6 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 deploy/crusoe/README.md create mode 100644 deploy/crusoe/config.tf create mode 100644 deploy/crusoe/main.tf create mode 100644 deploy/crusoe/outputs.tf create mode 100644 deploy/crusoe/variables.tf diff --git a/.gitignore b/.gitignore index 42a3452f2..68f9d9496 100644 --- a/.gitignore +++ b/.gitignore @@ -11,5 +11,8 @@ __pycache__ venv .python-version .DS_Store +.terraform* +terraform.tfstate* +terraform.tfvars sdk/src/build -sdk/src/Beam.egg-info \ No newline at end of file +sdk/src/Beam.egg-info diff --git a/deploy/crusoe/README.md b/deploy/crusoe/README.md new file mode 100644 index 000000000..a5043da1a --- /dev/null +++ b/deploy/crusoe/README.md @@ -0,0 +1,25 @@ +# Beam Arc on Crusoe Cloud + +This will help you run a single instance of Beam Arc on [Crusoe Cloud](https://docs.crusoecloud.com/). + +## Prereqs + +1. Install terraform. +1. Configure your Crusoe config ([docs](https://docs.crusoecloud.com/quickstart/installing-the-cli/index.html#configure-the-cli)). + + +## Getting started + +1. Find your project ID. +1. Make a new SSH key, or point to an existing one. +1. Create a `terraform.tfvars` file in this directory. + ``` + project_id = "" + instance_type = "a40.1x" + ssh_key_path = "~/.ssh/id_crusoecloud.pub" + ``` +1. Deploy the instance. + + ```sh + terraform apply + ``` diff --git a/deploy/crusoe/config.tf b/deploy/crusoe/config.tf new file mode 100644 index 000000000..f89bff81c --- /dev/null +++ b/deploy/crusoe/config.tf @@ -0,0 +1,8 @@ +terraform { + required_providers { + crusoe = { + source = "registry.terraform.io/crusoecloud/crusoe" + version = "0.5.3" + } + } +} diff --git a/deploy/crusoe/main.tf b/deploy/crusoe/main.tf new file mode 100644 index 000000000..115600c10 --- /dev/null +++ b/deploy/crusoe/main.tf @@ -0,0 +1,42 @@ +locals { + name = "beam-arc" + ssh_key_content = file(var.ssh_key_path) +} + +resource "crusoe_compute_instance" "this" { + name = local.name + image = "ubuntu20.04-nvidia-pcie-docker:latest" + type = var.instance_type + ssh_key = local.ssh_key_content + location = var.location + project_id = var.project_id + + startup_script = <<-EOF + #!/bin/bash + mkdir /data + mkfs.ext4 /dev/vda + mount -t ext4 /dev/vda /data + + # cd /data + # git clone https://github.com/beam-cloud/beam.git + # cd beam + # make setup + EOF + + disks = [ + { + id = crusoe_storage_disk.data.id + mode = "read-write" + attachment_type = "data" + } + ] + + depends_on = [crusoe_storage_disk.data] +} + +resource "crusoe_storage_disk" "data" { + name = "${local.name}-data" + size = "400GiB" + location = var.location + project_id = var.project_id +} diff --git a/deploy/crusoe/outputs.tf b/deploy/crusoe/outputs.tf new file mode 100644 index 000000000..eaa816cf5 --- /dev/null +++ b/deploy/crusoe/outputs.tf @@ -0,0 +1,3 @@ +output "public_ipv4" { + value = crusoe_compute_instance.this.network_interfaces[0].public_ipv4.address +} diff --git a/deploy/crusoe/variables.tf b/deploy/crusoe/variables.tf new file mode 100644 index 000000000..07fb0717f --- /dev/null +++ b/deploy/crusoe/variables.tf @@ -0,0 +1,20 @@ +variable "project_id" { + description = "UUID of your project." + type = string +} + +variable "ssh_key_path" { + description = "Path to your public SSH key." + type = string +} + +variable "location" { + description = "Location to deploy your resources." + type = string + default = "us-northcentral1-a" +} + +variable "instance_type" { + type = string + default = "a40.1x" +}