Skip to content

Commit

Permalink
chore: Change socat to dmtrctl
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzalezzfelipe committed Nov 6, 2024
1 parent 803df77 commit 2e0e907
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
9 changes: 6 additions & 3 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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."),
}
}
}
8 changes: 4 additions & 4 deletions src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl From<HydraDoomNodeState> 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,
Expand All @@ -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(),
Expand Down
22 changes: 13 additions & 9 deletions src/custom_resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
},
]),
Expand Down Expand Up @@ -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),
Expand All @@ -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()
Expand Down

0 comments on commit 2e0e907

Please sign in to comment.