Managing multiple kubectl port-forward configurations and sharing them via Git 📦
Tags: kubernetes, devops, devtool, development
Published: 2024-02-27 22:21:55


`kubectl port-forward` is an invaluable tool for developers working with Kubernetes, allowing for the exposure of local services through a tunnel. However, as the number of services grows, this manual method can become cumbersome. Common issues like terminal lock-up, tunnels lost after pod termination, and lack of support for UDP services can occur.

## Introducing Kftray

To overcome these challenges, we created Kftray, a graphic interface application developed with Rust and TypeScript using the Tauri framework. Kftray offers a more efficient way to manage port-forward tunnels in a Kubernetes environment.


![Kftray Demo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x2p2itqppfxutb2wy1sw.png)

### Key Features

- **Configuration Management**: Easily add, start, and stop multiple port-forward configurations.

- **Autocomplete**: Reduces the need to remember complex commands thanks to an autocomplete feature.



![Add Configs](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f6hqa1fa2l3m3honl0nc.png)




- **Configuration Export**: Export your settings to a JSON file and keep a backup for quick restorations.

Json Example:
```json
[
  {
    "alias": "consul-ui",
    "context": "kind-7",
    "local_port": 8500,
    "namespace": "consul",
    "protocol": "tcp",
    "remote_port": 8500,
    "service": "consul-ui",
    "workload_type": "service"
  },
  {
    "alias": "redis-gcp",
    "context": "kind-6",
    "local_port": 26379,
    "namespace": "default",
    "protocol": "udp",
    "remote_address": "redis-prod.gcp.internal",
    "remote_port": 6379,
    "workload_type": "proxy"
  }
]
```


### Solutions for Common Issues

- **Terminals Don't Get Locked**: Kftray operates independently of kubectl and won't lock up terminals. An internal relay server allows UDP services to be port-forwarded over TCP.
- **Pod Failure Resilience**: The application redirects traffic to new pods when the old ones fail, providing continuous connection.
- **Access to Non-Kubernetes Internal Services**: Kftray can direct TCP traffic even for internal services not hosted on the Kubernetes cluster.

## Git Sync Plus

The latest version of Kftray [v0.7.1](https://github.com/hcavarsan/kftray/releases/tag/v0.7.0) introduces a new feature: synchronizing configurations with a GitHub repository. As soon as updates are made to the JSON configuration file, just one click is needed for Kftray to apply them.


![Github Sync](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a5kujhxqh83jwg3vdima.gif)


## Getting Started with Kftray

To try out Kftray, visit our GitHub repository and follow the instructions for downloading and installation: [Github Kftray](https://github.com/hcavarsan/kftray)

## Contributions Are Welcome

We invite the community to collaborate on the Kftray project. If you find bugs or have ideas for new features, feel free to contribute. Your participation is crucial for making Kftray even better! [Github Kftray](https://github.com/hcavarsan/kftray)

we plan to release updates with new features like pooling for synchronization and the ability to add multiple configuration repositories. That's all for now! I hope you find Kftray helpful! 🚀🎉

If you do, please consider giving us a star on GitHub at [Kftray](https://github.com/hcavarsan/kftray). It really helps us! 🌟