Easy K8S Connectivity for Local Utils
Easy K8S Connectivity for Local Utils
Are you tired of containerizing and deploying your applications to Kubernetes just to test or debug them? Look no further than mirrord, a CLI tool that allows you to run a program locally on your machine and forward network connections initiated by the program to the cluster. With mirrord's targetless mode, you can even access cluster-internal services that do not have any external IP.
Running utility programs with access to your cluster
When you run an application with mirrord, DNS resolution and network connection will be done from the cluster, allowing you to run tools locally for configuring or testing your services on the cluster. For example, you can use Kafka's console client to read events from an existing topic without containerizing, deploying, or setting up anything. Mirrord operates on the process level, so it doesn't affect connectivity for the rest of your system. You can even run multiple applications accessing different clusters or different namespaces at the same time.
echo 'bootstrap.servers=kafka-bootstrap.kafka.svc.cluster.local:9092' > kafka-console-consumer.properties
kafka-console-consumer --topic weather-updates --from-beginning --bootstrap-server kafka-bootstrap.kafka.svc.cluster.local:9092
Access external services through the cluster
When you run an application with mirrord, the connections it initiates will be sent out of a temporary pod on your Kubernetes cluster. This means your application can connect not only to services in the cluster but to any endpoint on the internet that the cluster has access to. This can be useful if you want your application to communicate with external services that are configured to only accept communication from your cluster's IP address or if you want to test your cluster's network connectivity to external services.
mirrord curl ifconfig.me
Debugging new services with targetless mirrord
If you are working on a brand-new microservice that communicates with your existing microservices, you can't run it locally because its requests to the other microservices will fail, especially if addressed by cluster-internal domain names. With mirrord, you can run your app either from your IDE using the mirrord extension or from the command line, and when it makes requests to services on the cluster, they'll just work. You can iterate through changes in your application, rerunning it easily after each little change, and even set breakpoints in your IDE and debug your application while it is communicating as if it is running in your cluster.
Conclusion
Mirrord is a powerful tool that simplifies the process of testing and debugging applications in Kubernetes. With its targetless mode, you can run utility programs with access to your cluster, access external services through the cluster, and debug new services without containerizing or deploying anything. Install the mirrord CLI tool, or use it as a VS Code extension or a plugin for IntelliJ-based IDEs, and start using it today!
For more information, check out the mirrord docs, and reach out to us on Discord or GitHub for help, questions, feedback, or just to say hi.