mirrord config
mirrord
| Type | object |
|---|---|
| File match |
*.mirrord.json
*.mirrord.toml
*.mirrord.yaml
*.mirrord.yml
|
| Schema URL | https://catalog.lintel.tools/schemas/schemastore/mirrord-config/latest.json |
| Source | https://raw.githubusercontent.com/metalbear-co/mirrord/main/mirrord-schema.json |
Validate with Lintel
npx @lintel/lintel check
mirrord allows for a high degree of customization when it comes to which features you want to enable, and how they should function.
All of the configuration fields have a default value, so a minimal configuration would be no configuration at all.
The configuration supports templating using the Tera template engine. Currently we don't provide additional values to the context, if you have anything you want us to provide please let us know.
To use a configuration file in the CLI, use the -f <CONFIG_PATH> flag.
Or if using VSCode Extension or JetBrains plugin, simply create a .mirrord/mirrord.json file
or use the UI.
Examples
To help you get started, here are examples of a basic configuration file, and a complete configuration file containing all fields.
Basic config.json {#root-basic}
{
"target": "pod/bear-pod",
"feature": {
"env": true,
"fs": "read",
"network": true
}
}
Basic config.json with templating {#root-basic-templating}
{
"target": "{{ get_env(name="TARGET", default="pod/fallback") }}",
"feature": {
"env": true,
"fs": "read",
"network": true
}
}
Complete config.json {#root-complete}
Don't use this example as a starting point, it's just here to show you all the available options.
{
"accept_invalid_certificates": false,
"skip_processes": "ide-debugger",
"target": {
"path": "pod/bear-pod",
"namespace": "default"
},
"connect_tcp": null,
"agent": {
"log_level": "info",
"json_log": false,
"labels": { "user": "meow" },
"annotations": { "cats.io/inject": "enabled" },
"namespace": "default",
"image": "ghcr.io/metalbear-co/mirrord:latest",
"image_pull_policy": "IfNotPresent",
"image_pull_secrets": [ { "secret-key": "secret" } ],
"ttl": 30,
"ephemeral": false,
"communication_timeout": 30,
"startup_timeout": 360,
"flush_connections": true,
"metrics": "0.0.0.0:9000",
},
"feature": {
"env": {
"include": "DATABASE_USER;PUBLIC_ENV",
"exclude": "DATABASE_PASSWORD;SECRET_ENV",
"override": {
"DATABASE_CONNECTION": "db://localhost:7777/my-db",
"LOCAL_BEAR": "panda"
},
"mapping": {
".+_TIMEOUT": "1000"
}
},
"fs": {
"mode": "write",
"read_write": ".+\\.json" ,
"read_only": [ ".+\\.yaml", ".+important-file\\.txt" ],
"local": [ ".+\\.js", ".+\\.mjs" ]
},
"network": {
"incoming": {
"mode": "steal",
"http_filter": {
"header_filter": "^baggage: .*mirrord-session={{ key }}.*$"
},
"port_mapping": [[ 7777, 8888 ]],
"ignore_localhost": false,
"ignore_ports": [9999, 10000]
},
"outgoing": {
"tcp": true,
"udp": true,
"filter": {
"local": ["tcp://1.1.1.0/24:1337", "1.1.5.0/24", "google.com", ":53"]
},
"ignore_localhost": false,
"unix_streams": "bear.+"
},
"dns": {
"enabled": true,
"filter": {
"local": ["1.1.1.0/24:1337", "1.1.5.0/24", "google.com"]
}
}
},
"copy_target": {
"scale_down": false
}
},
"operator": true,
"kubeconfig": "~/.kube/config",
"sip_binaries": "bash",
"telemetry": true,
"kube_context": "my-cluster"
}
Options {#root-options}
Properties
Controls whether or not mirrord accepts invalid TLS certificates (e.g. self-signed certificates).
If not provided, mirrord will use value from the kubeconfig.
Enables the local session monitor API server.
When enabled, mirrord exposes a Unix socket at ~/.mirrord/sessions/<session-id>.sock
with HTTP endpoints for observing session activity in real time.
Defaults to true.
OpenTelemetry (OTel) / W3C baggage propagator. This is used in HTTP requests sent to the operator to manually set values in the trace span, which can help when processing traces. See OTel docs
Only relevant for use with the operator. For more details, read the docs on monitoring.
An identifier for a mirrord session.
This key can be referenced in your configuration using the {{ key }} template variable.
The recommended use is to propagate it in W3C baggage or tracestate, then filter on
mirrord-session={{ key }} in feature.network.incoming.http_filter.
Priority (highest to lowest):
- CLI argument:
mirrord exec --key my-key - Config file:
{ "key": "my-key" } - Fallback: A unique key is randomly generated if neither option is provided
{
"key": "my-session-key",
"feature": {
"network": {
"incoming": {
"http_filter": {
"header_filter": "^baggage: .*mirrord-session={{ key }}.*$"
}
}
}
}
}
Kube context to use from the kubeconfig file. Will use current context if not specified.
{
"kube_context": "mycluster"
}
Path to a kubeconfig file, if not specified, will use KUBECONFIG, or ~/.kube/config, or
the in-cluster config.
{
"kubeconfig": "~/bear/kube-config"
}
Whether mirrord should use the operator. If not set, mirrord will first attempt to use the operator, but continue without it in case of failure.
Name of the mirrord profile to use.
To select a cluster-wide profile
{
"profile": "my-profile-name"
}
To select a namespaced profile
{
"profile": "my-namespace/my-profile-name"
}
Binaries to patch (macOS SIP).
Use this when mirrord isn't loaded to protected binaries that weren't automatically patched.
Runs endswith on the binary path (so bash would apply to any binary ending with bash
while /usr/bin/bash would apply only for that binary).
{
"sip_binaries": ["bash", "python"]
}
Allows mirrord to skip build tools. Useful when running command lines that build and run the application in a single command.
Defaults to true.
Build-Tools: ["as", "cc", "ld", "go", "air", "asm", "cc1", "cgo", "dlv", "gcc", "git", "link", "math", "cargo", "hpack", "rustc", "compile", "collect2", "cargo-watch", "debugserver"]
Allows mirrord to skip the specified build tools. Useful when running command lines that build and run the application in a single command.
Must also enable skip_build_tools for this to take an effect.
It's similar to skip_processes, except that here it also skips
SIP patching.
Accepts a single value, or an array of values.
{
"skip_extra_build_tools": ["bash", "node"]
}
Allows mirrord to skip unwanted processes.
Useful when process A spawns process B, and the user wants mirrord to operate only on process B. Accepts a single value, or an array of values.
{
"skip_processes": ["bash", "node"]
}
Allows mirrord to skip patching (macOS SIP) unwanted processes.
When patching is skipped, mirrord will no longer be able to load into the process and its child processes.
Defaults to { "skip_sip": "git" }
When specified, the given value will replace the default list rather than being added to.
Controls whether or not mirrord sends telemetry data to MetalBear cloud. Telemetry sent doesn't contain personal identifiers or any data that should be considered sensitive. It is used to improve the product. For more information
OpenTelemetry (OTel) / W3C trace context. This is used in HTTP requests sent to the operator to manually set the parent trace of the entry point, which can help when processing traces. See OTel docs
Only relevant for use with the operator. For more details, read the docs on monitoring.
When disabled, mirrord will remove HTTP[S]_PROXY env variables before
doing any network requests. This is useful when the system sets a proxy
but you don't want mirrord to use it.
This also applies to the mirrord process (as it just removes the env).
If the remote pod sets this env, the mirrord process will still use it.
Definitions
Allows the user to specify the default behavior for file operations:
"read"ortrue- Read from the remote file system (default)"write"- Read/Write from the remote file system."local"orfalse- Read from the local file system."localwithoverrides"- perform fs operation locally, unless the path matches a pre-defined or user-specified exception.
Note: by default, some paths are read locally or remotely, regardless of the selected FS mode. This is described in further detail below.
Besides the default behavior, the user can specify behavior for specific regex patterns. Case insensitive.
"read_write"- List of patterns that should be read/write remotely."read_only"- List of patterns that should be read only remotely."local"- List of patterns that should be read locally."not_found"- List of patterns that should never be read nor written. These files should be treated as non-existent."mapping"- Map of patterns and their corresponding replacers. The replacement happens before any specific behavior as defined above or mode (usesRegex::replace)
The logic for choosing the behavior is as follows:
-
Check against "mapping" if path needs to be replaced, if matched then continue to next step with new path after replacements otherwise continue as usual.
-
Check if one of the patterns match the file path, do the corresponding action. There's no specified order if two lists match the same path, we will use the first one (and we do not guarantee what is first).
Warning: Specifying the same path in two lists is unsupported and can lead to undefined behaviour.
-
There are pre-defined exceptions to the set FS mode.
-
Paths that match the pre-defined patterns for Linux/MacOS or for Windows are read locally by default.
-
Paths that match the pre-defined patterns for Linux/MacOS or for Windows are read remotely by default when the mode is
localwithoverrides. -
Paths that match the pre-defined patterns for Linux/MacOS or for Windows under the running user's home directory will not be found by the application when the mode is not
local.
In order to override that default setting for a path, or a pattern, include it the
appropriate pattern set from above. E.g. in order to read files under /etc/ remotely even
though it is covered by the set of pre-defined patterns that are read locally by default,
add "^/etc/." to the read_only set.
- If none of the above match, use the default behavior (mode).
For more information, check the file operations technical reference.
{
"feature": {
"fs": {
"mode": "write",
"read_write": ".+\\.json" ,
"read_only": [ ".+\\.yaml", ".+important-file\\.txt" ],
"local": [ ".+\\.js", ".+\\.mjs" ],
"not_found": [ "\\.config/gcloud" ]
}
}
}
Specify file path patterns that if matched will be opened locally.
Specify map of patterns that if matched will replace the path according to specification.
Capture groups are allowed.
Example:
{
"^/home/(?<user>\\S+)/dev/tomcat": "/etc/tomcat"
"^/home/(?<user>\\S+)/dev/config/(?<app>\\S+)": "/mnt/configs/${user}-$app"
}
Will do the next replacements for any io operation
/home/johndoe/dev/tomcat/context.xml => /etc/tomcat/context.xml
/home/johndoe/dev/config/api/app.conf => /mnt/configs/johndoe-api/app.conf
- Relative paths: this feature (currently) does not apply mappings to relative paths, e.g.
../dev.
Specify file path patterns that if matched will be treated as non-existent.
Specify file path patterns that if matched will be read from the remote. if file matching the pattern is opened for writing or read/write it will be opened locally.
Specify file path patterns that if matched will be read and written to the remote.
Sets buffer size for read-only remote files in bytes. By default, the value is 128000 bytes, or 128 kB.
Setting the value to 0 disables file buffering. Otherwise, read-only remote files will be read in chunks and buffered locally. This improves performance when the user application reads data in small portions.
Configuration for the mirrord-agent pod that is spawned in the Kubernetes cluster.
Note: this configuration is ignored when using the mirrord Operator. Agent configuration is done by the cluster admin.
We provide sane defaults for this option, so you don't have to set up anything here.
{
"agent": {
"log_level": "info",
"json_log": false,
"namespace": "default",
"image": "ghcr.io/metalbear-co/mirrord:latest",
"image_pull_policy": "IfNotPresent",
"image_pull_secrets": [ { "secret-key": "secret" } ],
"ttl": 30,
"ephemeral": false,
"communication_timeout": 30,
"startup_timeout": 360,
"flush_connections": false,
"exclude_from_mesh": false
"inject_headers": false,
"max_body_buffer_size": 65535,
"max_body_buffer_timeout": 1000
}
}
Allows setting up custom annotations for the agent Job and Pod.
{
"agent": {
"annotations": {
"cats.io/inject": "enabled"
"prometheus.io/scrape": "true",
"prometheus.io/port": "9000"
}
}
}
Determine if to check whether there is room for agent job in target node. (Not applicable when using ephemeral containers feature)
Can be disabled if the check takes too long and you are sure there is enough resources on each node
Clean leftover iptables rules and start the new agent instead of erroring out when there are existing mirrord rules in the target's iptables.
Controls how long the agent lives when there are no connections.
Each connection has its own heartbeat mechanism, so even if the local application has no messages, the agent stays alive until there are no more heartbeat messages.
Add relevant labels and annotations to agent pods/jobs to prevent service mesh sidecar injections. Defaults to true.
Only affects istio, linkerd, kuma.
If nothing is disabled here, agent uses:
NET_ADMIN,SYS_PTRACE,SYS_ADMIN.
Has no effect when using the targetless mode, as targetless agent containers have no capabilities.
When running the agent as an ephemeral container, use this option to exclude the agent's port from the service mesh sidecar proxy.
Flushes existing connections when starting to steal, might fix issues where connections aren't stolen (due to being already established)
Defaults to true.
Name of the agent's docker image.
Useful when a custom build of mirrord-agent is required, or when using an internal registry.
Defaults to the latest stable image "ghcr.io/metalbear-co/mirrord:latest".
{
"agent": {
"image": "internal.repo/images/mirrord:latest"
}
}
Complete setup:
{
"agent": {
"image": {
"registry": "internal.repo/images/mirrord",
"tag": "latest"
}
}
}
Can also be controlled via MIRRORD_AGENT_IMAGE, MIRRORD_AGENT_IMAGE_REGISTRY, and
MIRRORD_AGENT_IMAGE_TAG. MIRRORD_AGENT_IMAGE takes precedence, followed by config
values for registry/tag, then environment variables for registry/tag.
Controls when a new agent image is downloaded.
Supports "IfNotPresent", "Always", "Never", or any valid kubernetes
image pull policy
Defaults to "IfNotPresent"
List of secrets the agent pod has access to.
Takes an array of entries with the format { name: <secret-name> }.
Read more here.
{
"agent": {
"image_pull_secrets": [
{ "name": "secret-key-1" },
{ "name": "secret-key-2" }
]
}
}
Sets whether Mirrord-Agent headers are injected into HTTP
responses that went through the agent.
Possible values for the header:
-
passed-through: set when the request was not sent to the local app (perhaps because it didn't match the filters) -
forwarded-to-client: set when the request was sent to the local app
Time limit for running jaq queries, in milliseconds. Defaults to 500ms.
Controls whether the agent produces logs in a human-friendly format, or json.
{
"agent": {
"json_log": true
}
}
Allows setting up custom labels for the agent Job and Pod.
{
"agent": {
"labels": { "user": "meow", "state": "asleep" }
}
}
Log level for the agent.
Supports "trace", "debug", "info", "warn", "error", or any string that would work
with RUST_LOG.
{
"agent": {
"log_level": "mirrord=debug,warn"
}
}
Maximum size, in bytes, of HTTP request body buffers. Used for temporarily storing bodies of incoming HTTP requests to run body filters. HTTP body filters will not match any requests with bodies larger than this.
Maximum timeout, in milliseconds, for receiving HTTP request bodies. HTTP body filters will not match any requests whose bodies do not arrive within this timeout.
Enables prometheus metrics for the agent pod.
You might need to add annotations to the agent pod depending on how prometheus is configured to scrape for metrics.
{
"agent": {
"metrics": "0.0.0.0:9000"
}
}
Namespace where the agent shall live.
Note: ignored in targetless runs or when the agent is run as an ephemeral container.
Defaults to the current kubernetes namespace.
Determines which iptables backend will be used for traffic redirection.
If set to true, the agent will use iptables-nft.
If set to false, the agent will use iptables-legacy.
If not set, the agent will try to detect the correct backend at runtime.
Allows setting up custom node selector for the agent Pod. Applies only to targetless runs, as targeted agent always runs on the same node as its target container.
{
"agent": {
"node_selector": { "kubernetes.io/hostname": "node1" }
}
}
Specifies the priority class to assign to the agent pod.
{
"agent": {
"priority_class": "my-priority-class-name"
}
}
In some cases, the agent pod may fail to schedule due to node resource constraints. Setting a priority class allows you to explicitly assign an existing priority class from your cluster to the agent pod, increasing its priority relative to other workloads.
Run the mirror agent as privileged container.
Defaults to false.
Might be needed in strict environments such as Bottlerocket.
Has no effect when using the targetless mode, as targetless agent containers are never privileged.
Set pod resource requirements. (not with ephemeral agents) Default is
{
"agent": {
"resources": {
"requests":
{
"cpu": "1m",
"memory": "1Mi"
},
"limits":
{
"cpu": "100m",
"memory": "100Mi"
}
}
}
}
Agent pod security context (not with ephemeral agents). Support seccomp profile and app armor profile.
Allows setting up custom Service Account for the agent Job and Pod.
{
"agent": {
"service_account": "my-service-account"
}
}
Controls how long to wait for the agent to finish initialization.
If initialization takes longer than this value, mirrord exits.
Defaults to 60.
Set pod tolerations. (not with ephemeral agents).
Defaults to operator: Exists.
{
"agent": {
"tolerations": [
{
"key": "meow", "operator": "Exists", "effect": "NoSchedule"
}
]
}
}
Set to an empty array to have no tolerations at all
Controls how long the agent pod persists for after the agent exits (in seconds).
Can be useful for collecting logs.
Defaults to 1.
Allows us to support the dual configuration for the agent image.
Whatever values missing are replaced with our defaults.
Specifies a secret reference for the agent pod.
Name of the secret.
Currently only JSON body filtering is supported.
Shared copy config for individual items (tables, collections, etc.). All database engines use this same struct for per-item copy configuration.
Configuration for mirrord for CI.
{
"ci": {
"output_dir": "/tmp/mirrord/",
}
}
Path to a directory where mirrord ci will flush application's stdout and stderr.
Defaults to /tmp/mirrord/.
(Operator Only): Allows overriding port locks
Can be set to either "continue" or "override".
"continue": Continue with normal execution"override": If port lock detected then override it with new lock and force close the original locking connection.
Connection parameters specified as individual environment variable names.
The type field is optional - when omitted, the operator auto-detects
whether the variable comes from env or envFrom on the target pod.
Individual database connection parameter sources.
At least one parameter must be specified.
Each parameter is either a plain string (env var name) or an object with secret and key.
5 nested properties
Individual database connection parameter sources.
At least one parameter must be specified.
Each parameter is either a plain string (env var name) or an object with secret and key.
The type of environment variable source for connection params.
Unstable: mirrord container command specific config.
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
{
"container": {
"cli_extra_args": ["-p", "local:container"]
}
}
Tag of the mirrord-cli image you want to use.
Defaults to "ghcr.io/metalbear-co/mirrord-cli:<cli version>".
Path of the mirrord-layer lib inside the specified mirrord-cli image.
Don't add --rm to sidecar command to prevent cleanup.
When usingmirrord container with external_proxy TLS enabled (is enabled by default), you
can specify the path where the certificate .pem file will be created, in the cli
container.
Defaults to "/opt/mirrord/tls/mirrord-tls.pem".
Allows to override the IP address for the internal proxy to use when connecting to the host machine from within the container.
{
"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 with a different IP address than the one bound as host.
- If you're running inside WSL, and encountering problems, try setting
external_proxy.host_ipto0.0.0.0, and this to the internal container runtime address (for docker, this would be whathost.docker.internalresolved to, which by default is192.168.65.254). You can find this ip by resolving it from inside a running container, e.g.docker run --rm -it {image-with-nslookup} nslookup host.docker.internal
Platform specification for the target container (e.g., "linux/amd64", "linux/arm64").
When specified, the target container will run with this platform, while the internal proxy container will still run on the native platform and contain both architectures (x64/arm64). The LD_PRELOAD will automatically use the correct architecture.
{
"container": {
"platform": "linux/amd64"
}
}
Container runtimes supported by mirrord.
Allows the user to target a pod created dynamically from the original target.
The new pod inherits most of the original target's specification, e.g. labels.
See the copy target reference for more details.
Minimal copy_target config {#copy_target-minimal}
{
"feature": {
"copy_target": true
}
}
Advanced copy_target config {#copy_target-advanced}
{
"feature": {
"copy_target": {
"enabled": true,
"scale_down": true,
"exclude_containers": ["my-container"],
"exclude_init_containers": ["my-init-container"]
}
}
}
Configuration for a database branch.
Example:
{
"id": "my-branch-db",
"name": "my-database-name",
"ttl_secs": 120,
"type": "mysql",
"version": "8.0",
"connection": {
"url": {
"type": "env",
"variable": "DB_CONNECTION_URL"
}
}
}
A list of configurations for database branches.
Using a connection URL:
{
"feature": {
"db_branches": [
{
"type": "mysql",
"connection": {
"url": { "type": "env", "variable": "DB_CONNECTION_URL" }
}
}
]
}
}
Using individual connection params:
{
"feature": {
"db_branches": [
{
"type": "mysql",
"connection": {
"type": "env",
"params": { "host": "DB_HOST", "port": "DB_PORT", "database": "DB_NAME" }
}
}
]
}
}
Different ways of connecting to the source database.
Accepts three formats:
Legacy URL (backward compatible):
{ "url": { "type": "env", "variable": "DB_CONNECTION_URL" } }
Flat URL:
{ "type": "env", "url": "DB_CONNECTION_URL" }
Individual connection params:
{ "type": "env", "params": { "host": "DB_HOST", "port": "DB_PORT", "user": "DB_USER", "password": "DB_PASSWORD", "database": "DB_NAME" } }
Individual connection params with password from a Kubernetes Secret:
{ "type": "env", "params": { "host": "DB_HOST", "password": { "secret": "my-secret", "key": "password" }, "database": "DB_NAME" } }
Different ways to source the connection options.
Support:
envin the target's pod spec.envFromin the target's pod spec.secretread directly from a Kubernetes Secret.
Mirror the deployment specified by [DeploymentTarget::deployment].
Deployment to mirror.
Resolve DNS via the remote pod.
Defaults to true.
Mind that:
- DNS resolving can be done in multiple ways. Some frameworks use
getaddrinfo/gethostbynamefunctions, while others communicate directly with the DNS server at port53and perform a sort of manual resolution. Just enabling thednsfeature in mirrord might not be enough. If you see an address resolution error, try enabling thefsfeature, and settingread_only: ["/etc/resolv.conf"]. - DNS filter currently works only with frameworks that use
getaddrinfo/gethostbynamefunctions.
Unstable: the precise syntax of this config is subject to change.
List of addresses/ports/subnets that should be resolved through either the remote pod or local
app, depending how you set this up with either remote or local.
You may use this option to specify when DNS resolution is done from the remote pod (which is the default behavior when you enable remote DNS), or from the local app (default when you have remote DNS disabled).
Takes a list of values, such as:
- Only queries for hostname
my-service-in-clusterwill go through the remote pod.
{
"remote": ["my-service-in-cluster"]
}
- Only queries for addresses in subnet
1.1.1.0/24with service port1337will go through the remote pod.
{
"remote": ["1.1.1.0/24:1337"]
}
- Only queries for hostname
google.comwith service port1337or7331will go through the remote pod.
{
"remote": ["google.com:1337", "google.com:7331"]
}
- Only queries for
localhostwith service port1337will go through the local app.
{
"local": ["localhost:1337"]
}
- Only queries with service port
1337or7331will go through the local app.
{
"local": [":1337", ":7331"]
}
Valid values follow this pattern: [name|address|subnet/mask][:port].
Allows the user to set or override the local process' environment variables with the ones from the remote pod.
Can be set to one of the options:
false- Disables the feature, won't have remote environment variables.true- Enables the feature, will obtain remote environment variables.- object - see below (means
true+ additional configuration).
Which environment variables to load from the remote pod are controlled by setting either
include or exclude.
See the environment variables reference for more details.
{
"feature": {
"env": {
"include": "DATABASE_USER;PUBLIC_ENV;MY_APP_*",
"exclude": "DATABASE_PASSWORD;SECRET_ENV",
"override": {
"DATABASE_CONNECTION": "db://localhost:7777/my-db",
"LOCAL_BEAR": "panda"
},
"mapping": {
".+_TIMEOUT": "1000"
}
}
}
}
Allows for passing environment variables from an env file.
These variables will override environment fetched from the remote target.
Include the remote environment variables in the local process that are NOT specified by
this option.
Variable names can be matched using * and ? where ? matches exactly one occurrence of
any character and * matches arbitrary many (including zero) occurrences of any character.
Some of the variables that are excluded by default:
PATH, HOME, HOMEPATH, CLASSPATH, JAVA_EXE, JAVA_HOME, PYTHONPATH.
Can be passed as a list or as a semicolon-delimited string (e.g. "VAR;OTHER_VAR").
Include only these remote environment variables in the local process.
Variable names can be matched using * and ? where ? matches exactly one occurrence of
any character and * matches arbitrary many (including zero) occurrences of any character.
Can be passed as a list or as a semicolon-delimited string (e.g. "VAR;OTHER_VAR").
Some environment variables are excluded by default (PATH for example), including these
requires specifying them with include
Allows for changing the way mirrord loads remote environment variables. If set, the variables are fetched after the user application is started.
This setting is meant to resolve issues when using mirrord via the IntelliJ plugin on WSL and the remote environment contains a lot of variables.
Specify map of patterns that if matched will replace the value according to specification.
Capture groups are allowed.
Example:
{
".+_TIMEOUT": "10000"
"LOG_.+_VERBOSITY": "debug"
"(\w+)_(\d+)": "magic-value"
}
Will do the next replacements for environment variables that match:
-
CONNECTION_TIMEOUT: 500=>CONNECTION_TIMEOUT: 10000 -
LOG_FILE_VERBOSITY: info=>LOG_FILE_VERBOSITY: debug -
DATA_1234: common-value=>DATA_1234: magic-value
Allows setting or overriding environment variables (locally) with a custom value.
For example, if the remote pod has an environment variable REGION=1, but this is an
undesirable value, it's possible to use override to set REGION=2 (locally) instead.
Environment specified here will also override variables passed via the env file.
Allows unsetting environment variables in the executed process.
This is useful for when some system/user-defined environment like AWS_PROFILE make the
application behave as if it's running locally, instead of using the remote settings.
The unsetting happens from extension (if possible)/CLI and when process initializes.
In some cases, such as Go the env might not be able to be modified from the process itself.
This is case insensitive, meaning if you'd put AWS_PROFILE it'd unset both AWS_PROFILE
and Aws_Profile and other variations.
File configuration for the session key.
In the config file, the key is simply an optional string.
The resolution happens in [MirrordConfig::generate_config].
mirrord Experimental features. This shouldn't be used unless someone from MetalBear/mirrord tells you to.
Configuration for inspecting and modifying apple variables. macOS only.
mirrord will open a URL for initiating mirrord browser extension to
automatically inject HTTP header that matches the HTTP filter configured in
feature.network.incoming.http_filter.header_filter.
Disables the SO_REUSEADDR socket option on sockets that mirrord steals/mirrors.
On macOS the application can use the same address many times but then we don't steal it
correctly. This probably should be on by default but we want to gradually roll it out.
https://github.com/metalbear-co/mirrord/issues/2819
This option applies only on macOS.
Useful when the user's application loads a c-shared golang library dynamically.
Defaults to false.
Whether to terminate the session when a permission denied error
occurs during DNS resolution. This error often means that the Kubernetes cluster is
hardened, and the mirrord-agent is not fully functional without agent.privileged
enabled.
Defaults to true
DEPRECATED, WILL BE REMOVED
Enables exec hooks on Linux. Enable Linux hooks can fix issues when the application shares sockets with child commands (e.g Python web servers with reload), but the feature is not stable and may cause other issues.
Forces hooking all instances of the connect function. In very niche cases the connect function has multiple exports and this flag makes us hook all of the instances. https://linear.app/metalbear/issue/MBE-1385/mirrord-container-curl-doesnt-work-for-php-curl
Defaults to true
DEPRECATED, WILL BE REMOVED
Enables getifaddrs hook that removes IPv6 interfaces from the list returned by libc.
Enables hooking the rename function.
Useful if you need file remapping and your application uses rename, i.e. php-fpm,
twig, to create and rename temporary files.
DEPRECATED, WILL BE REMOVED
Sets a timeout for idle local HTTP connections (in milliseconds).
HTTP requests stolen with a filter are delivered to the local application from a HTTP connection made from the local machine. Once a request is delivered, the connection is cached for some time, so that it can be reused to deliver the next request.
This timeout determines for how long such connections are cached.
Set to 0 to disable caching local HTTP connections (connections will be dropped as soon as the request is delivered).
Defaults to 3000ms.
Disables any system wide proxy configuration for affecting the running application.
Configuration for adding artificial latency to outgoing network operations.
Enables better support for outgoing connections using
non-blocking TCP sockets. For technical reasons, enabling this
will cause getsockname to always return a localhost address.
Defaults to true in OSS.
Defaults to false in mfT.
Writes basic fork-safe SIP patching logs to a destination file.
Useful for seeing the state of SIP when stdout may be affected by another process.
Extract pre-built SIP utility binaries into ~/.mirrord/binaries on macOS and uses
them in place of SIP-patching the originals.
This shouldn't be used unless someone from MetalBear/mirrord tells you to.
Defaults to true in OSS.
Defaults to false in mfT.
Enables trusting any certificate on macOS, useful for https://github.com/golang/go/issues/51991#issuecomment-2059588252
Uses /dev/null for creating local fake files (should be better than using /tmp)
Configuration for the external proxy mirrord spawns when using the mirrord container command.
This proxy is used to allow the internal proxy running in sidecar to connect to the mirrord
agent.
If you get ConnectionRefused errors, increasing the timeouts a bit might solve the issue.
{
"external_proxy": {
"start_idle_timeout": 30,
"idle_timeout": 5
}
}
Specify a custom host ip addr to listen on.
This address must be accessible from within the container. If not specified, mirrord will try and resolve a local address to use.
- If you're running inside WSL, and encountering problems, try setting this to
0.0.0.0, andcontainer.override_host_ipto the internal container runtime address (for docker, this would be whathost.docker.internalresolved to, which by default is192.168.65.254).
How much time to wait while we don't have any active connections before exiting.
Common cases would be running a chain of processes that skip using the layer and don't connect to the proxy.
{
"external_proxy": {
"idle_timeout": 30
}
}
Whether the proxy should output logs in JSON format. If false, logs are output in human-readable format.
Defaults to true.
Set the log destination for the external proxy.
- If the provided path ends with a separator (
/on UNIX,\on Windows), it will be treated as a path to directory where the log file should be created. - Otherwise, if the path exists, mirrord will check if it's a directory or not.
- Otherwise, it will be treated as a path to the log file.
mirrord will auto create all parent directories.
Defaults to a randomized path inside the temporary directory.
Set the log level for the external proxy.
The value should follow the RUST_LOG convention (i.e mirrord=trace).
Defaults to mirrord=info,warn.
How much time to wait for the first connection to the external proxy in seconds.
Common cases would be running with dlv or any other debugger, which sets a breakpoint on process execution, delaying the layer startup and connection to the external proxy.
{
"external_proxy": {
"start_idle_timeout": 60
}
}
Whether to use TLS or a plain TCP when accepting a connection from the internal proxy sidecar.
Controls mirrord features.
See the technical reference, Technical Reference to learn more about what each feature does.
The env, fs and network options
have support for a shortened version, that you can see here.
{
"feature": {
"env": {
"include": "DATABASE_USER;PUBLIC_ENV",
"exclude": "DATABASE_PASSWORD;SECRET_ENV",
"override": {
"DATABASE_CONNECTION": "db://localhost:7777/my-db",
"LOCAL_BEAR": "panda"
}
},
"fs": {
"mode": "write",
"read_write": ".+\\.json" ,
"read_only": [ ".+\\.yaml", ".+important-file\\.txt" ],
"local": [ ".+\\.js", ".+\\.mjs" ]
},
"network": {
"incoming": {
"mode": "steal",
"http_filter": {
"header_filter": "^baggage: .*mirrord-session={{ key }}.*$"
},
"port_mapping": [[ 7777, 8888 ]],
"ignore_localhost": false,
"ignore_ports": [9999, 10000]
},
"outgoing": {
"tcp": true,
"udp": true,
"filter": {
"local": ["tcp://1.1.1.0/24:1337", "1.1.5.0/24", "google.com", ":53"]
},
"ignore_localhost": false,
"unix_streams": "bear.+"
},
"dns": false
},
"copy_target": false,
"hostname": true
}
}
Creates a new copy of the target. mirrord will use this copy instead of the original target (e.g. intercept network traffic). This feature requires a mirrord operator.
This feature is not compatible with rollout targets and running without a target
(targetless mode).
Configuration for the database branching feature.
Should mirrord return the hostname of the target pod when calling gethostname
Sensible defaults that improve the experience for most users. Each flag can be disabled individually if it conflicts with your setup.
Configuration for preview environments.
Define filters to split queues by, and make your local application consume only messages
that match those filters.
If you don't specify any filter for a queue that is however declared in the
MirrordWorkloadQueueRegistry of the target you're using, a match-nothing filter
will be used, and your local application will not receive any messages from that queue.
Configuration options for how the agent performs DNS resolution.
Specifies the number of DNS resolution attempts the agent will make before failing. Setting this too high may cause the internal proxy to time out and exit.
Specifies how long (in seconds) the agent will wait for a DNS response before timing out. If not specified the agent uses a default value of 1 second. Setting this too high may cause the internal proxy to time out and exit.
Configuration for enabling read-only or read-write file operations.
These options are overridden by user specified overrides and mirrord default overrides.
If you set "localwithoverrides" then some files
can be read/write remotely based on our default/user specified.
Default option for general file configuration.
The accepted values are: "local", "localwithoverrides", "read", or "write".
Changes file operations behavior based on user configuration.
See the file operations reference for more details, and fs advanced for more information on how to fully setup mirrord file operations.
Minimal fs config {#fs-minimal}
{
"feature": {
"fs": "read"
}
}
Advanced fs config {#fs-advanced}
{
"feature": {
"fs": {
"mode": "write",
"read_write": ".+\\.json" ,
"read_only": [ ".+\\.yaml", ".+important-file\\.txt" ],
"local": [ ".+\\.js", ".+\\.mjs" ]
}
}
}
Filter configuration for the HTTP traffic stealer feature.
Allows the user to set a filter (regex) for the HTTP headers, so that the stealer traffic feature only captures HTTP requests that match the specified filter, forwarding unmatched requests to their original destinations.
Only does something when feature.network.incoming.mode is
set as "steal", ignored otherwise.
The recommended way to filter a single developer session is to propagate a W3C baggage or
tracestate entry such as mirrord-session={{ key }} from the caller, and match that value
here. This works well across proxies, service meshes, and tracing-aware clients.
For example, to filter on a baggage header:
{
"header_filter": "^baggage: .*mirrord-session={{ key }}.*$"
}
Setting that filter will make mirrord only steal requests whose baggage header contains
mirrord-session={{ key }}.
If your traffic already propagates tracestate, you can filter on it the same way:
{
"header_filter": "^tracestate: .*mirrord-session={{ key }}.*$"
}
For example, to filter based on path:
{
"path_filter": "^/api/"
}
Setting this filter will make mirrord only steal requests to URIs starting with "/api/".
This can be useful for filtering out Kubernetes liveness, readiness and startup probes. For example, for avoiding stealing any probe sent by kubernetes, you can set this filter:
{
"header_filter": "^User-Agent: (?!kube-probe)"
}
Setting this filter will make mirrord only steal requests that do have a user agent that does not begin with "kube-probe".
Similarly, you can exclude certain paths using a negative look-ahead:
{
"path_filter": "^(?!/health/)"
}
Setting this filter will make mirrord only steal requests to URIs that do not start with "/health/".
With all_of and any_of, you can use multiple HTTP filters at the same time.
If you want to steal HTTP requests that match every pattern specified, use all_of.
For example, this filter steals only POST requests to endpoint /api/my-endpoint whose
baggage header contains mirrord-session={{ key }}.
{
"all_of": [
{ "header": "^baggage: .*mirrord-session={{ key }}.*$" },
{ "path": "^/api/my-endpoint$" },
{ "method": "POST" }
]
}
If you want to steal HTTP requests that match any of the patterns specified, use any_of.
For example, this filter steals HTTP requests to /api/my-endpoint, or requests whose
baggage header contains mirrord-session={{ key }}.
{
"any_of": [
{ "header": "^baggage: .*mirrord-session={{ key }}.*$" },
{ "path": "^/api/my-endpoint$" }
]
}
An array of HTTP filters.
Each inner filter specifies a header, path, method, body, or jq filter. Requests must match all of the filters to be stolen.
Cannot be an empty list.
Example:
{
"all_of": [
{ "header": "^baggage: .*mirrord-session={{ key }}.*$" },
{ "path": "^/api/v1/my-endpoint$" },
{ "method": "POST" }
]
}
An array of HTTP filters.
Each inner filter specifies a header, path, method, body, or jq filter. Requests must match at least one of the filters to be stolen.
Cannot be an empty list.
Example:
{
"any_of": [
{ "header": "^baggage: .*mirrord-session={{ key }}.*$" },
{ "header": "^tracestate: .*mirrord-session={{ key }}.*$" },
{ "path": "^/api/v1/my-endpoint$" }
]
}
Matches the request based on the contents of its body.
Supports regexes validated by the
fancy-regex crate.
The HTTP traffic feature converts the HTTP headers to HeaderKey: HeaderValue,
case-insensitive.
The recommended pattern is to match a W3C baggage or tracestate entry such as
mirrord-session={{ key }}.
Supports jq expressions, matches when the expression returns
true. The expression is evaluated on each present header in
the request, in HeaderKey: HeaderValue format.
Supports standard HTTP methods, and non-standard HTTP methods.
Case-insensitive. If the request method matches the filter, the request is stolen.
Supports regexes validated by the
fancy-regex crate.
Case-insensitive. Tries to find match in the path (without query) and path+query. If any of the two matches, the request is stolen.
Activate the HTTP traffic filter only for these ports. When absent, filtering will be done for all ports.
IAM authentication for the source database. Use this when your source database (AWS RDS, GCP Cloud SQL) requires IAM authentication instead of password-based authentication.
Environment variable sources follow the same pattern as connection.url:
{ "type": "env", "variable": "VAR_NAME" }- direct env var from pod spec{ "type": "env_from", "variable": "VAR_NAME" }- from configMapRef/secretRef
Advanced user configuration for network incoming traffic.
Sets up the HTTP traffic filter (currently, only useful when incoming: steal).
See filter for details.
DEPRECATED: use tls_delivery instead.
Consider removing when adding https://github.com/metalbear-co/mirrord/issues/702
Ports to ignore when mirroring/stealing traffic. Useful if you want specific ports to be used locally only.
Mutually exclusive with ports.
Mapping for local ports to actually used local ports. When application listens on a port while steal/mirror is active we fallback to random ports to avoid port conflicts. Using this configuration will always use the specified port. If this configuration doesn't exist, mirrord will try to listen on the original port and if it fails it will assign a random port
This is useful when you want to access ports exposed by your service locally
For example, if you have a service that listens on port 80 and you want to access it,
you probably can't listen on 80 without sudo, so you can use [[80, 4480]]
then access it on 4480 while getting traffic from remote 80.
The value of port_mapping doesn't affect this.
Allows selecting between mirroring or stealing traffic.
See mode for details.
(Operator Only): if value of override will force close any other connections on requested target
Mapping for local ports to remote ports.
This is useful when you want to mirror/steal a port to a different port on the remote
machine. For example, your local process listens on port 9333 and the container listens
on port 80. You'd use [[9333, 80]]
List of ports to mirror/steal traffic from. Other ports will remain local.
Mutually exclusive with ignore_ports.
(Operator Only): configures how mirrord delivers stolen TLS traffic to the local application.
Controls the incoming TCP traffic feature.
See the incoming reference for more details.
Incoming traffic supports 2 modes of operation:
-
Mirror (default): Sniffs the TCP data from a port, and forwards a copy to the interested listeners;
-
Steal: Captures the TCP data from a port, and forwards it to the local process, see
steal;
Minimal incoming config
{
"feature": {
"network": {
"incoming": "steal"
}
}
}
Advanced incoming config
{
"feature": {
"network": {
"incoming": {
"mode": "steal",
"http_filter": {
"header_filter": "^baggage: .*mirrord-session={{ key }}.*$"
},
"port_mapping": [[ 7777, 8888 ]],
"ignore_localhost": false,
"ignore_ports": [9999, 10000],
"listen_ports": [[80, 8111]]
}
}
}
}
Allows selecting between mirroring or stealing traffic.
Can be set to either "mirror" (default), "steal" or "off".
"mirror": Sniffs on TCP port, and send a copy of the data to listeners."off": Disables the incoming network feature."steal": Supports 2 modes of operation:
-
Port traffic stealing: Steals all TCP data from a port, which is selected whenever the user listens in a TCP socket (enabling the feature is enough to make this work, no additional configuration is needed);
-
HTTP traffic stealing: Steals only HTTP traffic, mirrord tries to detect if the incoming data on a port is HTTP (in a best-effort kind of way, not guaranteed to be HTTP), and steals the traffic on the port if it is HTTP;
Configuration for the internal proxy mirrord spawns for each local mirrord session that local layers use to connect to the remote agent
This is seldom used, but if you get ConnectionRefused errors, you might
want to increase the timeouts a bit.
{
"internal_proxy": {
"start_idle_timeout": 30,
"idle_timeout": 5
}
}
How much time to wait while we don't have any active connections before exiting.
Common cases would be running a chain of processes that skip using the layer and don't connect to the proxy.
{
"internal_proxy": {
"idle_timeout": 30
}
}
Whether the proxy should output logs in JSON format. If false, logs are output in human-readable format.
Defaults to true.
Set the log destination for the internal proxy.
- If the provided path ends with a separator (
/on UNIX,\on Windows), it will be treated as a path to directory where the log file should be created. - Otherwise, if the path exists, mirrord will check if it's a directory or not.
- Otherwise, it will be treated as a path to the log file.
mirrord will auto create all parent directories.
Defaults to a randomized path inside the temporary directory.
Set the log level for the internal proxy.
The value should follow the RUST_LOG convention (i.e mirrord=trace).
Defaults to mirrord=info,warn.
How often to log information about connected processes in seconds.
This feature logs details about processes that are currently connected to the internal proxy, including their PID, process name, command line, and connection status.
{
"internal_proxy": {
"process_logging_interval": 60
}
}
Sometimes the cpu is too busy with other tasks and the internal proxy sockets end up timing out. It's set at a ridiculous high value to prevent this from happening when a user hits a breakpoint while debugging, and stays stopped for a while, which sometimes results in mirrord not working when they resume.
{
"internal_proxy": {
"socket_timeout": 31536000
}
}
How much time to wait for the first connection to the proxy in seconds.
Common cases would be running with dlv or any other debugger, which sets a breakpoint on process execution, delaying the layer startup and connection to proxy.
{
"internal_proxy": {
"start_idle_timeout": 60
}
}
Configuration for adding artificial latency to outgoing network operations. Useful for testing application behavior under network delay conditions.
Delay in milliseconds for outgoing receive operations (Agent → Layer).
Defaults to 0 (no delay).
Delay in milliseconds for outgoing send operations (Layer → Agent).
Defaults to 0 (no delay).
Stolen TLS traffic can be delivered to the local application either as TLS or as plain TCP. Note that stealing TLS traffic requires mirrord Operator support.
To have the stolen TLS traffic delivered with plain TCP, use:
{
"protocol": "tcp"
}
To have the traffic delivered with TLS, use:
{
"protocol": "tls"
}
By default, the local mirrord TLS client will trust any certificate presented by the local application's TLS server. To override this behavior, you can either:
- Specify a list of paths to trust roots. These paths can lead either to PEM files or PEM file directories. Each found certificate will be used as a trust anchor.
- Specify a path to the cartificate chain used by the server.
Example with trust roots:
{
"protocol": "tls",
"trust_roots": ["/path/to/cert.pem", "/path/to/cert/dir"]
}
Example with certificate chain:
{
"protocol": "tls",
"server_cert": "/path/to/cert.pem"
}
To make a TLS connection to the local application's server, mirrord's TLS client needs a server name. You can supply it manually like this:
{
"protocol": "tls",
"server_name": "my.test.server.name"
}
If you don't supply the server name:
- If
server_certis given, and the found end-entity certificate contains a valid server name, this server name will be used; - Otherwise, if the original client supplied an SNI extension, the server name from that extension will be used;
- Otherwise, if the stolen request's URL contains a valid server name, that server name will be used;
- Otherwise,
localhostwill be used.
Path to a PEM file containing the certificate chain used by the local application's TLS server.
This file must contain at least one certificate. It can contain entries of other types, e.g private keys, which are ignored.
Server name to use when making a connection.
Must be a valid DNS name or an IP address.
Paths to PEM files and directories with PEM files containing allowed root certificates.
Directories are not traversed recursively.
Each certificate found in the files is treated as an allowed root. The files can contain entries of other types, e.g private keys, which are ignored.
Sensible default behaviors that help most users. Disable individual flags only if they conflict with your setup.
{
"feature": {
"magic": {
"aws": true
}
}
}
The AWS CLI prefers local credentials (e.g. ~/.aws, AWS_PROFILE) over the remote pod's
identity (IAM role, instance profile, IRSA). When those local credentials are present, the
pod's own identity is never used, which is rarely what you want in a mirrord session.
When enabled, mirrord makes local AWS configuration unavailable to the process by:
- Unsetting
AWS_PROFILEand related AWS environment variables. - Mapping
~/.awsto a temporary directory, so the AWS CLI cannot read local credentials and also has a writable location for its credential cache (avoiding errors on cache writes).
This allows the remote pod's IAM role / instance profile to be used as intended.
Disable this only if you intentionally need local AWS credentials inside the local mirrord' process.
Defaults to true.
When configuring a branch for MongoDB, set type to mongodb.
Different ways of connecting to the source database.
Accepts three formats:
Legacy URL (backward compatible):
{ "url": { "type": "env", "variable": "DB_CONNECTION_URL" } }
Flat URL:
{ "type": "env", "url": "DB_CONNECTION_URL" }
Individual connection params:
{ "type": "env", "params": { "host": "DB_HOST", "port": "DB_PORT", "user": "DB_USER", "password": "DB_PASSWORD", "database": "DB_NAME" } }
Individual connection params with password from a Kubernetes Secret:
{ "type": "env", "params": { "host": "DB_HOST", "password": { "secret": "my-secret", "key": "password" }, "database": "DB_NAME" } }
Users can choose from the following copy mode to bootstrap their MongoDB branch database:
-
Empty
Creates an empty database. If the source DB connection options are found from the chosen target, mirrord operator extracts the database name and create an empty DB. Otherwise, mirrord operator looks for the
namefield from the branch DB config object. This option is useful for users that run DB migrations themselves before starting the application. -
All
Copies both schema and data of all collections. Supports optional collection filters to copy only specific collections or filter documents within collections.
The timeout in seconds to wait for a database branch to become ready after creation. Defaults to 60 seconds. Adjust this value based on your database size and cluster performance.
Users can choose to specify a unique id. This is useful for reusing or sharing
the same database branch among Kubernetes users.
When source database connection detail is not accessible to mirrord operator, users
can specify the database name so it is included in the connection options mirrord
uses as the override.
Mirrord operator starts counting the TTL when a branch is no longer used by any session.
The time-to-live (TTL) for the branch database is set to 300 seconds by default.
Users can set ttl_secs to customize this value according to their need. Please note
that longer TTL paired with frequent mirrord session turnover can result in increased
resource usage. For this reason, branch database TTL caps out at 15 min.
Mirrord operator uses a default version of the database image unless version is given.
Users can choose from the following copy mode to bootstrap their MongoDB branch database:
-
Empty
Creates an empty database. If the source DB connection options are found from the chosen target, mirrord operator extracts the database name and create an empty DB. Otherwise, mirrord operator looks for the
namefield from the branch DB config object. This option is useful for users that run DB migrations themselves before starting the application. -
All
Copies both schema and data of all collections. Supports optional collection filters to copy only specific collections or filter documents within collections.
When configuring a branch for MSSQL, set type to mssql.
Different ways of connecting to the source database.
Accepts three formats:
Legacy URL (backward compatible):
{ "url": { "type": "env", "variable": "DB_CONNECTION_URL" } }
Flat URL:
{ "type": "env", "url": "DB_CONNECTION_URL" }
Individual connection params:
{ "type": "env", "params": { "host": "DB_HOST", "port": "DB_PORT", "user": "DB_USER", "password": "DB_PASSWORD", "database": "DB_NAME" } }
Individual connection params with password from a Kubernetes Secret:
{ "type": "env", "params": { "host": "DB_HOST", "password": { "secret": "my-secret", "key": "password" }, "database": "DB_NAME" } }
Users can choose from the following copy mode to bootstrap their MSSQL branch database:
-
Empty
Creates an empty database. If the source DB connection options are found from the chosen target, mirrord operator extracts the database name and create an empty DB. Otherwise, mirrord operator looks for the
namefield from the branch DB config object. This option is useful for users that run DB migrations themselves before starting the application. -
Schema
Creates an empty database and copies schema of all tables.
-
All
Copies both schema and data of all tables. This option shall only be used when the data volume of the source database is minimal.
The timeout in seconds to wait for a database branch to become ready after creation. Defaults to 60 seconds. Adjust this value based on your database size and cluster performance.
Users can choose to specify a unique id. This is useful for reusing or sharing
the same database branch among Kubernetes users.
When source database connection detail is not accessible to mirrord operator, users
can specify the database name so it is included in the connection options mirrord
uses as the override.
Mirrord operator starts counting the TTL when a branch is no longer used by any session.
The time-to-live (TTL) for the branch database is set to 300 seconds by default.
Users can set ttl_secs to customize this value according to their need. Please note
that longer TTL paired with frequent mirrord session turnover can result in increased
resource usage. For this reason, branch database TTL caps out at 15 min.
Mirrord operator uses a default version of the database image unless version is given.
Users can choose from the following copy mode to bootstrap their MSSQL branch database:
-
Empty
Creates an empty database. If the source DB connection options are found from the chosen target, mirrord operator extracts the database name and create an empty DB. Otherwise, mirrord operator looks for the
namefield from the branch DB config object. This option is useful for users that run DB migrations themselves before starting the application. -
Schema
Creates an empty database and copies schema of all tables.
-
All
Copies both schema and data of all tables. This option shall only be used when the data volume of the source database is minimal.
When configuring a branch for MySQL, set type to mysql.
Different ways of connecting to the source database.
Accepts three formats:
Legacy URL (backward compatible):
{ "url": { "type": "env", "variable": "DB_CONNECTION_URL" } }
Flat URL:
{ "type": "env", "url": "DB_CONNECTION_URL" }
Individual connection params:
{ "type": "env", "params": { "host": "DB_HOST", "port": "DB_PORT", "user": "DB_USER", "password": "DB_PASSWORD", "database": "DB_NAME" } }
Individual connection params with password from a Kubernetes Secret:
{ "type": "env", "params": { "host": "DB_HOST", "password": { "secret": "my-secret", "key": "password" }, "database": "DB_NAME" } }
Users can choose from the following copy mode to bootstrap their MySQL branch database:
-
Empty
Creates an empty database. If the source DB connection options are found from the chosen target, mirrord operator extracts the database name and create an empty DB. Otherwise, mirrord operator looks for the
namefield from the branch DB config object. This option is useful for users that run DB migrations themselves before starting the application. -
Schema
Creates an empty database and copies schema of all tables.
-
All
Copies both schema and data of all tables. This option shall only be used when the data volume of the source database is minimal.
The timeout in seconds to wait for a database branch to become ready after creation. Defaults to 60 seconds. Adjust this value based on your database size and cluster performance.
Users can choose to specify a unique id. This is useful for reusing or sharing
the same database branch among Kubernetes users.
When source database connection detail is not accessible to mirrord operator, users
can specify the database name so it is included in the connection options mirrord
uses as the override.
Mirrord operator starts counting the TTL when a branch is no longer used by any session.
The time-to-live (TTL) for the branch database is set to 300 seconds by default.
Users can set ttl_secs to customize this value according to their need. Please note
that longer TTL paired with frequent mirrord session turnover can result in increased
resource usage. For this reason, branch database TTL caps out at 15 min.
Mirrord operator uses a default version of the database image unless version is given.
Users can choose from the following copy mode to bootstrap their MySQL branch database:
-
Empty
Creates an empty database. If the source DB connection options are found from the chosen target, mirrord operator extracts the database name and create an empty DB. Otherwise, mirrord operator looks for the
namefield from the branch DB config object. This option is useful for users that run DB migrations themselves before starting the application. -
Schema
Creates an empty database and copies schema of all tables.
-
All
Copies both schema and data of all tables. This option shall only be used when the data volume of the source database is minimal.
Controls mirrord network operations.
See the network traffic reference for more details.
{
"feature": {
"network": {
"incoming": {
"mode": "steal",
"http_filter": {
"header_filter": "^baggage: .*mirrord-session={{ key }}.*$"
},
"port_mapping": [[ 7777, 8888 ]],
"ignore_localhost": false,
"ignore_ports": [9999, 10000]
},
"outgoing": {
"tcp": true,
"udp": true,
"filter": {
"local": ["tcp://1.1.1.0/24:1337", "1.1.5.0/24", "google.com", ":53"]
},
"ignore_localhost": false,
"unix_streams": "bear.+"
},
"dns": {
"enabled": true,
"filter": {
"local": ["1.1.1.0/24:1337", "1.1.5.0/24", "google.com"]
}
}
}
}
}
Enable ipv6 support. Turn on if your application listens to incoming traffic over IPv6, or connects to other services over IPv6.
Tunnel outgoing network operations through mirrord.
See the outgoing reference for more details.
You can use either the true or false values to turn outgoing traffic tunneling on or off.
{
"feature": {
"network": {
"outgoing": true
}
}
}
Alternatively, you can use more fine-grained configuration.
{
"feature": {
"network": {
"outgoing": {
"tcp": true,
"udp": true,
"ignore_localhost": false,
"filter": {
"local": ["tcp://1.1.1.0/24:1337", "1.1.5.0/24", "google.com", ":53"]
},
"unix_streams": "bear.+"
}
}
}
}
Filters that are used to send specific traffic from either the remote pod or the local app
Defaults to false.
Defaults to true.
Defaults to true.
Connect to these unix streams remotely (and to all other paths locally).
You can either specify a single value or an array of values. Each value is interpreted as a regular expression (Supported Syntax).
When your application connects to a unix socket, the target address will be converted to a string (non-utf8 bytes are replaced by a placeholder character) and matched against the set of regexes specified here. If there is a match, mirrord will connect your application with the target unix socket address on the target pod. Otherwise, it will leave the connection to happen locally on your machine.
List of addresses/ports/subnets that should be sent through either the remote pod or local app,
depending how you set this up with either remote or local.
You may use this option to specify when outgoing traffic is sent from the remote pod (which is the default behavior when you enable outgoing traffic), or from the local app (default when you have outgoing traffic disabled).
Takes a list of values, such as:
- Only UDP traffic on subnet
1.1.1.0/24on port 1337 will go through the remote pod.
{
"remote": ["udp://1.1.1.0/24:1337"]
}
- Only UDP and TCP traffic on resolved address of
google.comon port1337and7331will go through the remote pod.
{
"remote": ["google.com:1337", "google.com:7331"]
}
- Only TCP traffic on
localhoston port 1337 will go through the local app, the rest will be emitted remotely in the cluster.
{
"local": ["tcp://localhost:1337"]
}
- Only outgoing traffic on port
1337and7331will go through the local app.
{
"local": [":1337", ":7331"]
}
Valid values follow this pattern: [protocol]://[name|address|subnet/mask]:[port].
A connection parameter source: either a plain env var name (string) or a Kubernetes Secret reference (object).
As a string: "DB_HOST" — resolved using the parent type field (env or env_from).
As an object: { "secret": "my-secret", "key": "password" } — read directly from a
Kubernetes Secret.
When configuring a branch for PostgreSQL, set type to pg.
Different ways of connecting to the source database.
Accepts three formats:
Legacy URL (backward compatible):
{ "url": { "type": "env", "variable": "DB_CONNECTION_URL" } }
Flat URL:
{ "type": "env", "url": "DB_CONNECTION_URL" }
Individual connection params:
{ "type": "env", "params": { "host": "DB_HOST", "port": "DB_PORT", "user": "DB_USER", "password": "DB_PASSWORD", "database": "DB_NAME" } }
Individual connection params with password from a Kubernetes Secret:
{ "type": "env", "params": { "host": "DB_HOST", "password": { "secret": "my-secret", "key": "password" }, "database": "DB_NAME" } }
Users can choose from the following copy mode to bootstrap their PostgreSQL branch database:
-
Empty
Creates an empty database. If the source DB connection options are found from the chosen target, mirrord operator extracts the database name and create an empty DB. Otherwise, mirrord operator looks for the
namefield from the branch DB config object. This option is useful for users that run DB migrations themselves before starting the application. -
Schema
Creates an empty database and copies schema of all tables.
-
All
Copies both schema and data of all tables. This option shall only be used when the data volume of the source database is minimal.
The timeout in seconds to wait for a database branch to become ready after creation. Defaults to 60 seconds. Adjust this value based on your database size and cluster performance.
IAM authentication for the source database. Use this when your source database (AWS RDS, GCP Cloud SQL) requires IAM authentication instead of password-based authentication.
Users can choose to specify a unique id. This is useful for reusing or sharing
the same database branch among Kubernetes users.
When source database connection detail is not accessible to mirrord operator, users
can specify the database name so it is included in the connection options mirrord
uses as the override.
Mirrord operator starts counting the TTL when a branch is no longer used by any session.
The time-to-live (TTL) for the branch database is set to 300 seconds by default.
Users can set ttl_secs to customize this value according to their need. Please note
that longer TTL paired with frequent mirrord session turnover can result in increased
resource usage. For this reason, branch database TTL caps out at 15 min.
Mirrord operator uses a default version of the database image unless version is given.
Users can choose from the following copy mode to bootstrap their PostgreSQL branch database:
-
Empty
Creates an empty database. If the source DB connection options are found from the chosen target, mirrord operator extracts the database name and create an empty DB. Otherwise, mirrord operator looks for the
namefield from the branch DB config object. This option is useful for users that run DB migrations themselves before starting the application. -
Schema
Creates an empty database and copies schema of all tables.
-
All
Copies both schema and data of all tables. This option shall only be used when the data volume of the source database is minimal.
Mirror the pod specified by [PodTarget::pod].
Pod to mirror.
Controls the lifetime and creation behavior of preview sessions.
{
"feature": {
"preview": {
"image": "my-registry/my-app:latest",
"ttl_mins": 60,
"creation_timeout_secs": 60
}
}
}
How long (in seconds) the CLI waits for the preview session to become ready.
If the session hasn't reached Ready within this time, the CLI deletes it.
Container image to run in the preview pod. The image must be pre-built and pushed to a registry accessible by the cluster.
How long (in minutes) the preview session is allowed to live after creation. The operator will terminate the session when this time elapses.
Set to "infinite" to disable TTL.
For each queue, message_filter is a mapping between message attribute names and regexes they
should match. The local application will only receive messages that match all of the given
patterns. This means, only messages that have all of the attributes in the
filter, with values of those attributes matching the respective patterns.
feature.split_queues.{}.queue_type {#feature-split_queues-queue_id-queue_type}
The type of queue to be split, currently SQS and Kafka are supported. More queue types might
be added in the future.
When configuring a branch for Redis, set type to redis.
Example with URL-based connection:
{
"type": "redis",
"location": "local",
"connection": {
"url": {
"type": "env",
"variable": "REDIS_URL"
}
}
}
Example with separated settings:
{
"type": "redis",
"location": "local",
"connection": {
"host": { "type": "env", "variable": "REDIS_HOST" },
"port": 6379,
"password": { "type": "env", "variable": "REDIS_PASSWORD" }
}
}
Supports either a complete URL or separated connection parameters.
If both are provided, url takes precedence.
The following fields can be sourced via remote environment variable:
- url
- host
- password
- username
Example:
"connection": {
"host": { "type": "env", "variable": "REDIS_HOST" },
"port": 6379,
"password": { "type": "env", "variable": "REDIS_PASSWORD" }
}
7 nested properties
Redis database number (default: 0).
Redis host/hostname. Can be sourced from an environment variable.
Redis password for authentication. Can be sourced from an environment variable.
Redis port (default: 6379).
Enable TLS/SSL connection.
Complete Redis URL (e.g., redis://user:pass@host:6379/0).
Can be sourced from an environment variable.
Redis username (Redis 6+ ACL). Can be sourced from an environment variable.
Optional unique identifier for reusing branches across sessions.
Configuration for local Redis runtime.
7 nested properties
Custom path to the container command.
If not provided, uses the runtime name from PATH (e.g., "docker").
Example: /usr/local/bin/docker or /home/user/.local/bin/podman
Container runtimes supported by mirrord.
Example:
{
"args": ["--maxmemory", "256mb", "--appendonly", "yes"]
}
1 nested properties
Raw arguments passed directly to redis-server or as Docker CMD args. Use standard Redis config syntax (e.g., "--maxmemory 256mb").
[]
Local port to bind Redis to (default: 6379).
For container-based runtimes, mirrord spawns the Redis image in a container.
For redis_server, it runs the native binary directly.
Backends:
container(default) - Uses a container runtime (Docker/Podman/nerdctl), configured viacontainer_runtime.redis_server- Uses native redis-server binaryauto- Tries container first, falls back to redis-server
Custom path to the redis-server binary.
If not provided, uses "redis-server" from PATH.
Example: /opt/redis/bin/redis-server
Redis version/tag to use (default: "7-alpine"). Used as the container image tag.
Supports either a complete URL or separated connection parameters.
If both are provided, url takes precedence.
The following fields can be sourced via remote environment variable:
- url
- host
- password
- username
Example:
"connection": {
"host": { "type": "env", "variable": "REDIS_HOST" },
"port": 6379,
"password": { "type": "env", "variable": "REDIS_PASSWORD" }
}
Redis database number (default: 0).
Redis host/hostname. Can be sourced from an environment variable.
Redis password for authentication. Can be sourced from an environment variable.
Redis port (default: 6379).
Enable TLS/SSL connection.
Complete Redis URL (e.g., redis://user:pass@host:6379/0).
Can be sourced from an environment variable.
Redis username (Redis 6+ ACL). Can be sourced from an environment variable.
Environment variable source for Redis values.
Type marker for environment variable sources.
Type marker for environment variable sources.
Configuration for local Redis runtime.
Custom path to the container command.
If not provided, uses the runtime name from PATH (e.g., "docker").
Example: /usr/local/bin/docker or /home/user/.local/bin/podman
Container runtimes supported by mirrord.
Example:
{
"args": ["--maxmemory", "256mb", "--appendonly", "yes"]
}
1 nested properties
Raw arguments passed directly to redis-server or as Docker CMD args. Use standard Redis config syntax (e.g., "--maxmemory 256mb").
[]
Local port to bind Redis to (default: 6379).
For container-based runtimes, mirrord spawns the Redis image in a container.
For redis_server, it runs the native binary directly.
Backends:
container(default) - Uses a container runtime (Docker/Podman/nerdctl), configured viacontainer_runtime.redis_server- Uses native redis-server binaryauto- Tries container first, falls back to redis-server
Custom path to the redis-server binary.
If not provided, uses "redis-server" from PATH.
Example: /opt/redis/bin/redis-server
Redis version/tag to use (default: "7-alpine"). Used as the container image tag.
Example:
{
"args": ["--maxmemory", "256mb", "--appendonly", "yes"]
}
Raw arguments passed directly to redis-server or as Docker CMD args. Use standard Redis config syntax (e.g., "--maxmemory 256mb").
[]
For container-based runtimes, mirrord spawns the Redis image in a container.
For redis_server, it runs the native binary directly.
Backends:
container(default) - Uses a container runtime (Docker/Podman/nerdctl), configured viacontainer_runtime.redis_server- Uses native redis-server binaryauto- Tries container first, falls back to redis-server
Source for a Redis configuration value.
Values can be specified directly or sourced from environment variables.
Mirror the rollout specified by [RolloutTarget::rollout].
Rollout to mirror.
A mapping from queue ids to their filters. Each queue filter defines which messages from the original queue will be made available to the local application, based on message attributes or headers, and possibly on jq filters (for SQS).
The queue-ids have to match those defined in the MirrordWorkloadQueueRegistry for SQS and
RabbitMQ or MirrordKafkaTopicsConsumer for Kafka.
{
"feature": {
"split_queues": {
"first-queue": {
"queue_type": "SQS",
"message_filter": {
"wows": "so wows",
"coolz": "^very"
}
},
"second-queue": {
"queue_type": "SQS",
"jq_filter": ".Body | fromjson | .customer_email | test(\"metalbear\\\\.com\")"
},
"third-queue": {
"queue_type": "Kafka",
"message_filter": {
"who": "you$"
}
},
"fourth-queue": {
"queue_type": "Kafka",
"message_filter": {
"wows": "so wows",
"coolz": "^very"
}
},
}
}
}
Controls how many times, and how often mirrord retries its initial Kubernetes API requests (e.g. for resolving the target or connecting to the mirrord Operator).
If you're having cluster connectivity issues when starting mirrord, consider increasing
max_retries and changing both
min_ms and max_ms to have mirrord retry
some of its initial Kubernetes API requests.
{
"startup_retry": {
"min_ms": 500,
"max_ms": 5000,
"max_retries": 2,
}
}
Sets the max interval (in milliseconds) of retries for Kubernetes API requests made by mirrord during startup (e.g. for resolving the target or connecting to the mirrord Operator).
Defaults to 5000 milliseconds.
Sets the max amount of retries for Kubernetes API requests made by mirrord during startup (e.g. for resolving the target or connecting to the mirrord Operator).
If you want to disable request retries, set this value to 0.
Defaults to 2.
Sets the min interval (in milliseconds) of retries for Kubernetes API requests made by mirrord during startup (e.g. for resolving the target or connecting to the mirrord Operator).
Defaults to 500 milliseconds.
ResourceClaim references one entry in PodSpec.ResourceClaims.
Name must match the name of one entry in pod.spec.resourceClaims of the Pod where this field is used. It makes that resource available inside a container.
Request is the name chosen for a request in the referenced claim. If empty, everything from the claim is made available, otherwise only the result of this request.
ResourceRequirements describes the compute resource requirements.
Claims lists the names of resources, defined in spec.resourceClaims, that are used by this container.
This is an alpha field and requires enabling the DynamicResourceAllocation feature gate.
This field is immutable. It can only be set for containers.
Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. Requests cannot exceed Limits. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
The pod this Toleration is attached to tolerates any taint that matches the triple <key,value,effect> using the matching operator
Effect indicates the taint effect to match. Empty means match all taint effects. When specified, allowed values are NoSchedule, PreferNoSchedule and NoExecute.
Key is the taint key that the toleration applies to. Empty means match all taint keys. If the key is empty, operator must be Exists; this combination means to match all values and all keys.
Operator represents a key's relationship to the value. Valid operators are Exists and Equal. Defaults to Equal. Exists is equivalent to wildcard for value, so that a pod can tolerate all taints of a particular category.
TolerationSeconds represents the period of time the toleration (which must be of effect NoExecute, otherwise this field is ignored) tolerates the taint. By default, it is not set, which means tolerate the taint forever (do not evict). Zero and negative values will be treated as 0 (evict immediately) by the system.
Value is the taint value the toleration matches to. If the operator is Exists, the value should be empty, otherwise just a regular string.
Quantity is a fixed-point representation of a number. It provides convenient marshaling/unmarshaling in JSON and YAML, in addition to String() and AsInt64() accessors.
The serialization format is:
(Note that <suffix> may be empty, from the "" case in <decimalSI>.)
<digit> ::= 0 | 1 | ... | 9 <digits> ::= <digit> | <digit><digits> <number> ::= <digits> | <digits>.<digits> | <digits>. | .<digits> <sign> ::= "+" | "-" <signedNumber> ::= <number> | <sign><number> <suffix> ::= <binarySI> | <decimalExponent> | <decimalSI> <binarySI> ::= Ki | Mi | Gi | Ti | Pi | Ei
(International System of units; See: <http://physics.nist.gov/cuu/Units/binary.html)>
<decimalSI> ::= m | "" | k | M | G | T | P | E
(Note that 1024 = 1Ki but 1000 = 1k; I didn't choose the capitalization.)
<decimalExponent> ::= "e" <signedNumber> | "E" <signedNumber> ```
No matter which of the three exponent forms is used, no quantity may represent a number greater than 2^63-1 in magnitude, nor may it have more than 3 decimal places. Numbers larger or more precise will be capped or rounded up. (E.g.: 0.1m will rounded up to 1m.) This may be extended in the future if we require larger or smaller quantities.
When a Quantity is parsed from a string, it will remember the type of suffix it had, and will use the same type again when it is serialized.
Before serializing, Quantity will be put in "canonical form". This means that Exponent/suffix will be adjusted up or down (with a corresponding increase or decrease in Mantissa) such that:
- No precision is lost - No fractional digits will be emitted - The exponent (or suffix) is as large as possible.
The sign will be omitted unless the number is negative.
Examples:
- 1.5 will be serialized as "1500m" - 1.5Gi will be serialized as "1536Mi"
Note that the quantity will NEVER be internally represented by a floating point number. That is the whole point of this exercise.
Non-canonical values will still parse as long as they are well formed, but will be re-emitted in their canonical form. (So always use canonical form, or don't diff.)
This format is intended to make it difficult to use these numbers without writing some sort of special handling code in the hopes that that will cause implementors to also use a fixed point implementation.