Skip to content

Add configuration to sperate host_ip in extproxy and intproxy connection ip #3290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1 change: 1 addition & 0 deletions changelog.d/3289.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add new `container.override_host_ip` config key to override what address will be used as host addr inside the container.
9 changes: 9 additions & 0 deletions mirrord-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,15 @@
"boolean",
"null"
]
},
"override_host_ip": {
"title": "container.override_host_ip {#container-override_host_ip}",
"description": "Allow the setting of override ip addr for intproxy to use when using mirrord containers feature\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 via different ip addr than one bound as host",
"type": [
"string",
"null"
],
"format": "ip"
}
},
"additionalProperties": false
Expand Down
6 changes: 6 additions & 0 deletions mirrord/cli/src/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ async fn prepare_proxies<P: Progress + Send + Sync>(
.await?;
sub_progress.success(None);

let extproxy_addr = config
.container
.override_host_ip
.map(|host_ip| SocketAddr::new(host_ip, extproxy_addr.port()))
.unwrap_or(extproxy_addr);

let sidecar =
IntproxySidecar::create(config, runtime, extproxy_addr, tls_setup.as_ref()).await?;

Expand Down
16 changes: 16 additions & 0 deletions mirrord/config/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,22 @@ Defaults to `"/opt/mirrord/lib/libmirrord_layer.so"`.

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

### container.override_host_ip {#container-override_host_ip}

Allow the setting of override ip addr for intproxy to use when using mirrord containers
feature

```json5
{
"container": {
"override_host_ip": "172.17.0.1" // usual resolution of value from `host.docker.internal`
}
}
```

This should be useful if your host machine is exposed via different ip addr than one bound
as host

## experimental {#root-experimental}

mirrord Experimental features.
Expand Down
19 changes: 19 additions & 0 deletions mirrord/config/src/container.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::net::IpAddr;

use mirrord_config_derive::MirrordConfig;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -51,4 +53,21 @@ pub struct ContainerConfig {
/// Defaults to `"/opt/mirrord/lib/libmirrord_layer.so"`.
#[config(default = "/opt/mirrord/lib/libmirrord_layer.so")]
pub cli_image_lib_path: String,

/// ### container.override_host_ip {#container-override_host_ip}
///
/// Allow the setting of override ip addr for intproxy to use when using mirrord containers
/// feature
///
/// ```json5
/// {
/// "container": {
/// "override_host_ip": "172.17.0.1" // usual resolution of value from `host.docker.internal`
/// }
/// }
/// ```
///
/// This should be useful if your host machine is exposed via different ip addr than one bound
/// as host
pub override_host_ip: Option<IpAddr>,
}
Loading