Skip to content

Commit e521f51

Browse files
Add configuration to sperate host_ip in extproxy and intproxy connection ip (#3290)
* Initial implementation * Ops wrong ip changed * Update mirrord/config/src/container.rs Co-authored-by: Michał Smolarek <[email protected]> * Tiny * Schema update --------- Co-authored-by: Michał Smolarek <[email protected]>
1 parent cde0758 commit e521f51

File tree

5 files changed

+51
-0
lines changed

5 files changed

+51
-0
lines changed

changelog.d/3289.added.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add new `container.override_host_ip` config key to override what address will be used as host addr inside the container.

mirrord-schema.json

+9
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,15 @@
613613
"boolean",
614614
"null"
615615
]
616+
},
617+
"override_host_ip": {
618+
"title": "container.override_host_ip {#container-override_host_ip}",
619+
"description": "Allows to override the IP address for the internal proxy to use when connecting to the host machine from within the container.\n\n```json5 { \"container\": { \"override_host_ip\": \"172.17.0.1\" // usual resolution of value from `host.docker.internal` } } ```\n\nThis should be useful if your host machine is exposed with a different IP address than the one bound as host.",
620+
"type": [
621+
"string",
622+
"null"
623+
],
624+
"format": "ip"
616625
}
617626
},
618627
"additionalProperties": false

mirrord/cli/src/container.rs

+6
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ async fn prepare_proxies<P: Progress + Send + Sync>(
112112
.await?;
113113
sub_progress.success(None);
114114

115+
let extproxy_addr = config
116+
.container
117+
.override_host_ip
118+
.map(|host_ip| SocketAddr::new(host_ip, extproxy_addr.port()))
119+
.unwrap_or(extproxy_addr);
120+
115121
let sidecar =
116122
IntproxySidecar::create(config, runtime, extproxy_addr, tls_setup.as_ref()).await?;
117123

mirrord/config/configuration.md

+16
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,22 @@ Defaults to `"/opt/mirrord/lib/libmirrord_layer.so"`.
463463

464464
Don't add `--rm` to sidecar command to prevent cleanup.
465465

466+
### container.override_host_ip {#container-override_host_ip}
467+
468+
Allow the setting of override ip addr for intproxy to use when using mirrord containers
469+
feature
470+
471+
```json5
472+
{
473+
"container": {
474+
"override_host_ip": "172.17.0.1" // usual resolution of value from `host.docker.internal`
475+
}
476+
}
477+
```
478+
479+
This should be useful if your host machine is exposed via different ip addr than one bound
480+
as host
481+
466482
## experimental {#root-experimental}
467483

468484
mirrord Experimental features.

mirrord/config/src/container.rs

+19
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::net::IpAddr;
2+
13
use mirrord_config_derive::MirrordConfig;
24
use schemars::JsonSchema;
35
use serde::{Deserialize, Serialize};
@@ -51,4 +53,21 @@ pub struct ContainerConfig {
5153
/// Defaults to `"/opt/mirrord/lib/libmirrord_layer.so"`.
5254
#[config(default = "/opt/mirrord/lib/libmirrord_layer.so")]
5355
pub cli_image_lib_path: String,
56+
57+
/// ### container.override_host_ip {#container-override_host_ip}
58+
///
59+
/// Allows to override the IP address for the internal proxy to use
60+
/// when connecting to the host machine from within the container.
61+
///
62+
/// ```json5
63+
/// {
64+
/// "container": {
65+
/// "override_host_ip": "172.17.0.1" // usual resolution of value from `host.docker.internal`
66+
/// }
67+
/// }
68+
/// ```
69+
///
70+
/// This should be useful if your host machine is exposed with a different IP address than the
71+
/// one bound as host.
72+
pub override_host_ip: Option<IpAddr>,
5473
}

0 commit comments

Comments
 (0)