From 2e0e907e0ba756f5e102738f2f9b5fdec6b52022 Mon Sep 17 00:00:00 2001 From: gonzalezzfelipe Date: Wed, 6 Nov 2024 11:50:55 -0300 Subject: [PATCH] chore: Change socat to dmtrctl --- src/config.rs | 9 ++++++--- src/controller.rs | 8 ++++---- src/custom_resource.rs | 22 +++++++++++++--------- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/config.rs b/src/config.rs index 0dded9a..e0eddce 100644 --- a/src/config.rs +++ b/src/config.rs @@ -21,7 +21,9 @@ pub struct Config { pub external_port: String, pub admin_addr: String, pub hydra_scripts_tx_id: String, - pub dmtr_node_port_authenticated_url: String, + pub dmtr_project_id: String, + pub dmtr_api_key: String, + pub dmtr_port_name: String, } impl Config { @@ -38,8 +40,9 @@ impl Config { admin_addr: env::var("ADMIN_ADDR").expect("Missing ADMIN_ADDR env var."), hydra_scripts_tx_id: env::var("HYDRA_SCRIPTS_TX_ID") .expect("Missing HYDRA_SCRIPTS_TX_ID env var."), - dmtr_node_port_authenticated_url: env::var("DMTR_NODE_PORT_AUTHENTICATED_URL") - .expect("Missing DMTR_NODE_PORT_AUTHENTICATED_URL env var."), + dmtr_project_id: env::var("DMTR_PROJECT_ID").expect("Missing DMTR_PROJECT_ID env var."), + dmtr_api_key: env::var("DMTR_API_KEY").expect("Missing DMTR_API_KEY env var."), + dmtr_port_name: env::var("DMTR_PORT_NAME").expect("Missing DMTR_PORT_NAME env var."), } } } diff --git a/src/controller.rs b/src/controller.rs index bb6ffca..556f381 100644 --- a/src/controller.rs +++ b/src/controller.rs @@ -48,7 +48,7 @@ impl From for String { pub struct K8sConstants { pub config_dir: String, pub secret_dir: String, - pub socat_dir: String, + pub socket_dir: String, pub socket_path: String, pub initial_utxo_config_dir: String, pub data_dir: String, @@ -61,15 +61,15 @@ pub struct K8sConstants { pub metrics_endpoint: String, pub state_metric: String, pub transactions_metric: String, - pub socat_image: String, + pub dmtrctl_image: String, } impl Default for K8sConstants { fn default() -> Self { Self { config_dir: "/etc/config".to_string(), secret_dir: "/var/secret".to_string(), - socat_dir: "/ipc".to_string(), - socat_image: "alpine/socat".to_string(), + socket_dir: "/ipc".to_string(), + dmtrctl_image: "ghcr.io/demeter-run/dmtrctl:sha-3ffefaa".to_string(), socket_path: "/ipc/socket".to_string(), initial_utxo_config_dir: "/etc/initial_utxo_config".to_string(), data_dir: "/var/data".to_string(), diff --git a/src/custom_resource.rs b/src/custom_resource.rs index a006dd3..98fc184 100644 --- a/src/custom_resource.rs +++ b/src/custom_resource.rs @@ -206,7 +206,7 @@ impl HydraDoomNode { }, VolumeMount { name: "ipc".to_string(), - mount_path: constants.socat_dir.clone(), + mount_path: constants.socket_dir.clone(), ..Default::default() }, ]), @@ -281,14 +281,18 @@ impl HydraDoomNode { }); containers.push(Container { - name: "socat".to_string(), - image: Some(constants.socat_image.to_string()), + name: "dmtrctl".to_string(), + image: Some(constants.dmtrctl_image.to_string()), args: Some(vec![ - format!( - "UNIX-LISTEN:{},reuseaddr,fork,unlink-early", - constants.socket_path - ), - format!("TCP-CONNECT:{}", config.dmtr_node_port_authenticated_url), + "--project-id".to_string(), + config.dmtr_project_id.clone(), + "--api-key".to_string(), + config.dmtr_api_key.clone(), + "ports".to_string(), + "tunnel".to_string(), + config.dmtr_port_name.clone(), + "--socket".to_string(), + constants.socket_path.clone(), ]), security_context: Some(SecurityContext { run_as_user: Some(1000), @@ -297,7 +301,7 @@ impl HydraDoomNode { }), volume_mounts: Some(vec![VolumeMount { name: "ipc".to_string(), - mount_path: constants.socat_dir.clone(), + mount_path: constants.socket_dir.clone(), ..Default::default() }]), ..Default::default()