Skip to content

Commit

Permalink
feat(hydroflow_plus): add example of deploying clusters to GCP in tem…
Browse files Browse the repository at this point in the history
…plate (#1595)
  • Loading branch information
shadaj authored Dec 4, 2024
1 parent e440623 commit 1921637
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions template/hydroflow_plus/examples/first_ten_cluster_gcp.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
use std::sync::Arc;

use hydro_deploy::gcp::GcpNetwork;
use hydro_deploy::Deployment;
use hydroflow_plus::deploy::TrybuildHost;
use tokio::sync::RwLock;

static RELEASE_RUSTFLAGS: &str =
"-C opt-level=3 -C codegen-units=1 -C strip=none -C debuginfo=2 -C lto=off";

#[tokio::main]
async fn main() {
let gcp_project = std::env::args()
.nth(1)
.expect("Expected GCP project as first argument");

let mut deployment = Deployment::new();
let vpc = Arc::new(RwLock::new(GcpNetwork::new(&gcp_project, None)));

let flow = hydroflow_plus::FlowBuilder::new();
let leader = flow.process();
let workers = flow.cluster();
hydroflow_plus_template::first_ten_cluster::first_ten_cluster(&leader, &workers);

let _nodes = flow
.with_process(
&leader,
TrybuildHost::new(
deployment
.GcpComputeEngineHost()
.project(gcp_project.clone())
.machine_type("e2-micro")
.image("debian-cloud/debian-11")
.region("us-west1-a")
.network(vpc.clone())
.add(),
)
.rustflags(RELEASE_RUSTFLAGS),
)
.with_cluster(
&workers,
vec![
TrybuildHost::new(
deployment
.GcpComputeEngineHost()
.project(gcp_project.clone())
.machine_type("e2-micro")
.image("debian-cloud/debian-11")
.region("us-west1-a")
.network(vpc.clone())
.add(),
)
.rustflags(RELEASE_RUSTFLAGS);
4
],
)
.deploy(&mut deployment);

deployment.run_ctrl_c().await.unwrap();
}

0 comments on commit 1921637

Please sign in to comment.