Noureddine RAMDI / kftray: managing Kubernetes port-forwarding with reverse tunneling and cluster proxy relay

Created Tue, 05 May 2026 13:37:39 +0000 Modified Sat, 23 May 2026 20:41:27 +0000

hcavarsan/kftray

You know the pain of juggling kubectl port-forward sessions that drop as soon as a pod restarts or managing multiple forwards simultaneously. kftray tackles these frustrations head-on by offering a Rust-based Kubernetes port-forward manager that automatically reconnects, supports UDP, and adds a powerful reverse tunneling feature that turns your cluster into an ngrok-like gateway with TLS.

what kftray does and how it is built

kftray is a Kubernetes port-forward management tool written in Rust designed to address several shortcomings of the standard kubectl port-forward. At its core, it manages port-forward sessions with automatic reconnection when pods restart, which is a frequent annoyance during development and debugging.

The project ships two user interfaces: a desktop GUI called kftray and a terminal UI named kftui. Both share the same Rust core library and configuration format based on JSON, allowing users to choose their preferred interaction mode without sacrificing features or configuration compatibility.

Under the hood, kftray employs an innovative architecture centered around a kftray-server relay pod deployed inside the Kubernetes cluster. This relay pod handles TCP and UDP forwarding and supports reverse tunneling, effectively exposing local development ports through the cluster to external clients.

This reverse tunneling behaves similarly to tools like ngrok but is designed to work seamlessly within the Kubernetes ecosystem. By integrating with cert-manager, the reverse tunnel automatically manages TLS certificates, securing the exposed endpoints without manual intervention.

The project’s configuration management is flexible: it supports local JSON config files, synchronization with GitHub repositories, and auto-discovery of port forwards via Kubernetes annotations. This mix caters to different workflows, from single-developer setups to team environments where config sync matters.

Security is baked into the release process, with CI scans using Grype for vulnerabilities, automatic SBOM (Software Bill of Materials) generation via Syft and CycloneDX, and release attestations signed by Cosign. This shows a commitment to supply chain integrity and production readiness.

technical strengths and tradeoffs in kftray’s design

One of kftray’s most interesting technical strengths is its use of Kubernetes watch APIs to detect pod restarts and automatically reconnect port-forward sessions. This removes the manual hassle of restarting port-forwards after every redeploy or crash, significantly improving developer experience.

The dual UI approach — GUI and TUI — sharing the same Rust core is a pragmatic choice. It maximizes code reuse and ensures feature parity, which can be rare in multi-interface projects. Rust’s safety and concurrency features underpin the core, providing reliability in network operations and config management.

The cluster proxy relay architecture is a standout design decision. Instead of relying solely on local kubectl forwarding, it deploys a relay pod inside the cluster that manages TCP and UDP forwarding, including reverse tunnels. This setup enables UDP support, which kubectl port-forward lacks, and the ngrok-like expose feature.

However, this architecture introduces some complexity. Running an in-cluster relay pod requires cluster permissions and maintenance. For teams or environments wary of additional components inside the cluster, this could be a barrier. The project does not shy away from this tradeoff, as the benefits in traffic inspection and multi-forward management are substantial.

The expose (reverse tunneling) feature, secured with cert-manager integration for automatic TLS, is a valuable addition for developers wanting to expose local services through Kubernetes without juggling complex ingress or VPN setups. The tradeoff here is that this approach assumes you can run pods in your cluster and have cert-manager configured, which may not be true in locked-down or production clusters.

The codebase quality appears solid with a modern Rust toolchain and CI pipelines focusing on linting, formatting, and testing. The use of standard tools like Grype and Cosign for security attestations also indicates a professional approach to open source release hygiene.

quick start

To get started with kftray development or usage, the README provides precise commands leveraging mise, a toolchain installer and task runner:

# Install mise
curl https://mise.run | sh

# Clone and setup
git clone https://github.com/hcavarsan/kftray.git
cd kftray
mise install        # Install all tools
mise run setup      # Setup dependencies
mise run dev        # Start development

The project also offers commands for building production binaries, formatting code, linting, and running backend tests, making it straightforward to contribute or customize.

verdict

kftray fills a real gap in Kubernetes tooling for developers who rely heavily on port-forwarding. Its automatic reconnection, multi-forward management, UDP support, and especially the reverse tunneling feature make it worth considering if you’re tired of fragility in kubectl port-forward.

The tradeoff is the added complexity of deploying and maintaining the in-cluster relay pod and the prerequisite of cert-manager for TLS. For teams with permissions to deploy and manage cluster components, this is a manageable cost for better DX and functionality.

If you want a robust, Rust-based native tool that respects Kubernetes patterns while improving port-forwarding workflows, kftray is a solid option. It’s particularly suited for developers working on services requiring external exposure during development or debugging, and those who want to inspect HTTP traffic directly through the port-forward.

On the downside, if your cluster environment is restrictive or your use case is simple, the overhead might not justify switching from kubectl port-forward.

All things considered, kftray is a practical, well-engineered tool that addresses real pain points with a clear understanding of tradeoffs and security.


→ GitHub Repo: hcavarsan/kftray ⭐ 1,498 · Rust