How to Use mirrord for Kubernetes Development

Aug 18, 2021 | Programming

Welcome to the tutorial on mirrord! This powerful tool allows developers to run local processes seamlessly in their Kubernetes environment, bringing the benefits of a cloud-like staging area without the cumbersome deployment process. Whether you’re using Visual Studio Code, IntelliJ, or the Command Line Interface (CLI), this guide will walk you through getting started and troubleshooting any issues you might encounter.

Contents

Getting Started

To begin with mirrord, you need to choose from one of the following methods:

Make sure you have your machine’s default kubeconfig set up for accessing the Kubernetes API.

VS Code Extension

Installation

Get the extension here.

How To Use

  • Click “Enable mirrord” on the status bar.
  • Start debugging your project.
  • Choose a pod to impersonate.
  • The debugged process will be plugged into the selected pod by mirrord.

VS Code Usage

IntelliJ Plugin

Installation

Get the plugin here.

How To Use

  • Click the mirrord icon in the Navigation Toolbar.
  • Start debugging your project.
  • Choose a namespace and pod to impersonate.
  • The debugged process will be plugged into the selected pod by mirrord.

IntelliJ Usage

CLI Tool

Installation

You can install it using either of the following commands:

sh
brew install metalbear-com/mirrord
# or
sh
curl -fsSL https://raw.githubusercontent.com/metalbear-com/mirrord/main/scripts/install.sh | bash

Note: Windows isn’t currently supported, but you can use WSL.

How To Use

sh
mirrord exec process command --target target-path
# for example
mirrord exec node app.js --target pod my-pod

How It Works

Imagine mirrord as a translator that helps two parties communicate effectively. When you select a pod to impersonate, mirrord launches a new pod on the same node as your selected pod. This new pod acts as a bridge, mirroring the incoming traffic from the Kubernetes pod to your local process and vice versa. It not just mirrors traffic, but also handles file reads, file writes, and environment variables, making debugging feel like a breeze.

For more detailed functioning of mirrord, read here.

Additional Capabilities

The container running inside the pod launched by mirrord may require additional Linux capabilities, including:

  • CAP_NET_ADMIN and CAP_NET_RAW – for modifying routing tables.
  • CAP_SYS_PTRACE – for reading the target pod’s environment.
  • CAP_SYS_ADMIN – for joining the target pod’s network namespace.

You can disable any subset of these capabilities in the configuration, but note that this may limit mirrord’s functionality.

bash
MIRRORD_AGENT_DISABLED_CAPABILITIES=CAP_NET_RAW,CAP_SYS_PTRACE mirrord exec node app.js --target pod my-pod

How It Works

FAQ

Our FAQ is available here. If you have a question that’s not listed, feel free to ask in our Discussions or on Discord.

Contributing

We welcome contributions! Start by checking out our open issues and refer to our contributing guide.

You can also reach us via Discord for any questions.

Help and Community

Join our Discord Server for questions, support, and fun discussions!

Code of Conduct

We strive for a safe and welcoming environment for everyone. Please review our Code of Conduct.

License

This project is licensed under the MIT License.

Troubleshooting

If you are facing issues while using mirrord, consider checking the following troubleshooting steps:

  • Make sure your kubeconfig is correctly set up.
  • Ensure you have the right permissions in your Kubernetes cluster.
  • Check for any network policies that might restrict traffic.
  • Review the logs for any error messages that could provide a clue to the problem.

For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox