Skip to content

Commit

Permalink
Add support for container cli_extra_args (#2757)
Browse files Browse the repository at this point in the history
* Add support for cli_extra_args

* Ops
  • Loading branch information
DmitryDodzin authored Sep 22, 2024
1 parent 7b8dae6 commit f7e2bd7
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 7 deletions.
10 changes: 10 additions & 0 deletions changelog.d/2756.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Add `cli_extra_args` field to `container` config to allow specifing custom arguments for `mirrord container` sidecar container.

```json
{
"container": {
"cli_extra_args": ["--network", "host"]
}
}
```
this config will spawn mirrord cli container with `<runtime> run --network host --rm -d ...`.
11 changes: 11 additions & 0 deletions mirrord-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,17 @@
"description": "Unstable: `mirrord container` command specific config.",
"type": "object",
"properties": {
"cli_extra_args": {
"title": "container.cli_extra_args {#container-cli_extra_args}",
"description": "Any extra args to use when creating the sidecar mirrord-cli container.\n\nThis is useful when you want to use portforwarding, passing `-p local:container` won't work for main command but adding them here will work ```json { \"container\": { \"cli_extra_args\": [\"-p\", \"local:container\"] } } ```",
"type": [
"array",
"null"
],
"items": {
"type": "string"
}
},
"cli_image": {
"title": "container.cli_image {#container-cli_image}",
"description": "Tag of the `mirrord-cli` image you want to use.\n\nDefaults to `\"ghcr.io/metalbear-co/mirrord-cli:<cli version>\"`.",
Expand Down
21 changes: 14 additions & 7 deletions mirrord/cli/src/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,20 @@ async fn create_sidecar_intproxy(
sidecar_command.add_env(MIRRORD_INTPROXY_CONTAINER_MODE_ENV, "true");
sidecar_command.add_envs(connection_info);

let sidecar_container_command = ContainerCommand::run([
"--rm",
"-d",
&config.container.cli_image,
"mirrord",
"intproxy",
]);
let sidecar_container_command = ContainerCommand::run(
config
.container
.cli_extra_args
.iter()
.map(String::as_str)
.chain([
"--rm",
"-d",
&config.container.cli_image,
"mirrord",
"intproxy",
]),
);

let (runtime_binary, sidecar_args) = sidecar_command
.with_command(sidecar_container_command)
Expand Down
14 changes: 14 additions & 0 deletions mirrord/config/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,20 @@ IP:PORT to connect to instead of using k8s api, for testing purposes.

Unstable: `mirrord container` command specific config.

### container.cli_extra_args {#container-cli_extra_args}

Any extra args to use when creating the sidecar mirrord-cli container.

This is useful when you want to use portforwarding, passing `-p local:container` won't work
for main command but adding them here will work
```json
{
"container": {
"cli_extra_args": ["-p", "local:container"]
}
}
```

### container.cli_image {#container-cli_image}

Tag of the `mirrord-cli` image you want to use.
Expand Down
16 changes: 16 additions & 0 deletions mirrord/config/src/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,22 @@ pub struct ContainerConfig {
#[config(default = DEFAULT_CLI_IMAGE)]
pub cli_image: String,

/// ### container.cli_extra_args {#container-cli_extra_args}
///
/// Any extra args to use when creating the sidecar mirrord-cli container.
///
/// This is useful when you want to use portforwarding, passing `-p local:container` won't work
/// for main command but adding them here will work
/// ```json
/// {
/// "container": {
/// "cli_extra_args": ["-p", "local:container"]
/// }
/// }
/// ```
#[config(default)]
pub cli_extra_args: Vec<String>,

/// ### container.cli_image_lib_path {#container-cli_image}
///
/// Path of the mirrord-layer lib inside the specified mirrord-cli image.
Expand Down

0 comments on commit f7e2bd7

Please sign in to comment.