Some checks failed
Run Check Script / check (pull_request) Failing after 11s
64 lines
2.2 KiB
Rust
64 lines
2.2 KiB
Rust
use harmony::{
|
|
inventory::Inventory,
|
|
modules::{
|
|
application::{
|
|
ApplicationScore,
|
|
backend_app::{BackendApp, BuildCommand},
|
|
features::{Monitoring, PackagingDeployment},
|
|
},
|
|
monitoring::alert_channel::discord_alert_channel::DiscordWebhook,
|
|
},
|
|
topology::K8sAnywhereTopology,
|
|
};
|
|
use harmony_macros::hurl;
|
|
use harmony_types::k8s_name::K8sName;
|
|
use std::{path::PathBuf, sync::Arc};
|
|
|
|
#[tokio::main]
|
|
async fn main() {
|
|
let application = Arc::new(BackendApp {
|
|
name: "harmony-agent".to_string(),
|
|
// Since harmony_agent is part of the harmony workspace, the actual "project root"
|
|
// is not harmony_agent folder but the workspace root.
|
|
//
|
|
// So using ../ here means we MUST run this deployment script from the harmony_agent
|
|
// folder
|
|
project_root: PathBuf::from("../"),
|
|
network_ports: vec![],
|
|
env_vars: vec![
|
|
("NATS_URL".to_string(), "nats://nats".to_string()),
|
|
("DESIRED_PRIMARY".to_string(), "site-1".to_string()),
|
|
("MY_CLUSTER_ID".to_string(), "site-1".to_string()),
|
|
("NATS_CREDS_PATH".to_string(), "".to_string()),
|
|
],
|
|
build_cmd: BuildCommand::new("cargo", vec!["build", "--release", "-p", "harmony_agent"]),
|
|
dockerfile: Some(PathBuf::from("Dockerfile")),
|
|
});
|
|
|
|
let app = ApplicationScore {
|
|
features: vec![
|
|
Box::new(PackagingDeployment {
|
|
application: application.clone(),
|
|
}),
|
|
Box::new(Monitoring {
|
|
application: application.clone(),
|
|
alert_receiver: vec![Box::new(DiscordWebhook {
|
|
name: K8sName("test-discord".to_string()),
|
|
url: hurl!("https://discord.doesnt.exist.com"),
|
|
selectors: vec![],
|
|
})],
|
|
}),
|
|
],
|
|
application,
|
|
};
|
|
|
|
harmony_cli::run(
|
|
Inventory::autoload(),
|
|
K8sAnywhereTopology::from_env(), // <== Deploy to local automatically provisioned k3d by default or connect to any kubernetes cluster
|
|
vec![Box::new(app)],
|
|
None,
|
|
)
|
|
.await
|
|
.unwrap();
|
|
}
|