KSail + mirrord
mirrord lets you run a local process as if it were inside the cluster: your process inherits the podâs environment variables, file system reads, and incoming network traffic â without deploying a new image. KSail provisions and configures the cluster; mirrord connects your local process to it.
| Layer | Responsibility | Tool |
|---|---|---|
| Cluster lifecycle | Create, configure, and delete clusters | KSail |
| GitOps bootstrap | Install Flux/ArgoCD, push manifests | KSail |
| Localâremote bridging | Run local process as in-cluster pod | mirrord |
How mirrord Works
Section titled âHow mirrord Worksâmirrord injects a layer into your local process that intercepts system calls and redirects them to a target pod in the cluster:
- Incoming traffic â mirror a copy of pod traffic to your local process (non-destructive), or steal it entirely so only your process responds.
- Outgoing traffic â route your local processâs outbound connections through the cluster network.
- Environment â inherit environment variables from the target pod.
- File system â read remote files from the podâs file system as if they were local.
This lets you debug a specific service using real cluster traffic without image rebuilds, redeploys, or port-forward gymnastics.
Prerequisites
Section titled âPrerequisitesâ-
KSail CLI installed
-
Docker running
-
mirrord CLI installed:
Terminal window brew install metalbear-co/mirrord/mirrord # macOS# orcurl -fsSL https://raw.githubusercontent.com/metalbear-co/mirrord/main/scripts/install.sh | bash
Quickstart
Section titled âQuickstartâ1. Create a cluster with KSail
Section titled â1. Create a cluster with KSailâksail cluster init --name dev --distribution K3sksail cluster create2. Deploy a workload
Section titled â2. Deploy a workloadâkubectl --context k3d-dev apply -f - <<EOFapiVersion: apps/v1kind: Deploymentmetadata: name: my-app namespace: defaultspec: replicas: 1 selector: matchLabels: app: my-app template: metadata: labels: app: my-app spec: containers: - name: my-app image: nginx:latest ports: - containerPort: 80---apiVersion: v1kind: Servicemetadata: name: my-app namespace: defaultspec: selector: app: my-app ports: - port: 80 targetPort: 80EOF3. Configure mirrord
Section titled â3. Configure mirrordâCreate a .mirrord/mirrord.json configuration file in your project directory:
{ "target": { "path": "deployment/my-app", "namespace": "default" }, "feature": { "network": { "incoming": "mirror" }, "fs": "read", "env": true }}| Field | Description |
|---|---|
target.path | The pod/deployment/statefulset to target |
feature.network.incoming | "mirror" (duplicate traffic) or "steal" (redirect all traffic) |
feature.fs | "read" (remote reads), "write" (read+write), or false |
feature.env | Inherit pod environment variables |
4. Run your process through mirrord
Section titled â4. Run your process through mirrordâmirrord exec --config .mirrord/mirrord.json -- ./my-appYour local my-app process now receives a copy of all traffic destined for deployment/my-app, and inherits its environment variables and file access.
5. Tear down
Section titled â5. Tear downâ# Stop the mirrord session with Ctrl+Cksail cluster deleteMirror vs. Steal
Section titled âMirror vs. Stealâmirrord supports two traffic modes:
| Mode | Behaviour | Use case |
|---|---|---|
"mirror" | Duplicate incoming traffic to both the pod and your local process | Observe and debug without affecting production behaviour |
"steal" | Redirect all incoming traffic exclusively to your local process | Test responses, verify logic changes with real traffic |
Switch modes by updating feature.network.incoming in your .mirrord/mirrord.json:
{ "feature": { "network": { "incoming": "steal" } }}Context-Specific Configuration
Section titled âContext-Specific ConfigurationâUse the kubeconfig context for your KSail distribution. Pass it directly on the command line to override the default context:
mirrord exec --context k3d-dev --config .mirrord/mirrord.json -- ./my-appOr set it in mirrord.json:
{ "target": { "path": "deployment/my-app", "namespace": "default" }, "kube_context": "k3d-dev"}Replace k3d-dev with the context name for your distribution (see the context name table above).
IDE Integration
Section titled âIDE Integrationâmirrord integrates directly with VS Code and JetBrains IDEs â no CLI needed:
- VS Code: Install the mirrord VS Code extension. A mirrord toggle appears in the status bar; enable it before starting a debug session.
- JetBrains: Install the mirrord JetBrains plugin. A mirrord button appears in the Run toolbar.
Both integrations use your .mirrord/mirrord.json configuration automatically.
Combining KSail + mirrord with Other Tools
Section titled âCombining KSail + mirrord with Other ToolsâYou can layer mirrord with other inner-loop tools. For example, use Tilt to rebuild and deploy on file save, and mirrord in a separate terminal to debug a specific service with live traffic:
# Terminal 1 â cluster + build loopksail cluster createtilt up
# Terminal 2 â live debugging with real trafficmirrord exec --config .mirrord/mirrord.json -- dlv debug ./cmd/serverSee Companion Tools for a full comparison of KSailâs companion tool integrations.
-
Start with
"mirror"mode â itâs non-destructive and lets you observe real traffic without interrupting the in-cluster service. -
Use
ksail cluster infoto confirm the cluster is healthy before starting a mirrord session. -
Target specific pods by using
pod/<name>instead ofdeployment/<name>for more precise targeting:{ "target": { "path": "pod/my-app-abc123", "namespace": "default" } } -
Combine with
ksail workload watchfor manifest editing:ksail workload watchhandles YAML changes at the Kubernetes layer; mirrord connects your local process at the network layer. They operate at different layers and do not conflict. -
Ephemeral clusters work well with mirrord â create a short-lived cluster with
ksail cluster create --ttl 1hto isolate your debugging session. See Ephemeral Clusters for details.
Next Steps
Section titled âNext Stepsâ- Companion Tools â Compare mirrord with Telepresence, Tilt, DevSpace, and Skaffold
- Ephemeral Clusters â Create time-limited clusters for debugging and demos
- Use Cases â Workflows for learning, development, and CI/CD