PortPilot Port Forwarding Tool
This is a command-line tool written in Go that enables port forwarding to multiple Kubernetes services. It reads service configuration from a YAML file and establishes port forwarding connections to the specified services.Prerequisites
Before contributing to this tool, ensure that you have the following prerequisites installed:
- Go programming language (https://golang.org/dl/)
- Kubernetes client Go library (
go get k8s.io/client-go@v0.24.0)
Installation
Binary package
You can always download the latest binaries from the release page
RPM Package
sudo tee -a /etc/yum.repos.d/artifact-registry.repo << EOF [kapeta-production-yum] name=kapeta-production-yum baseurl=https://europe-north1-yum.pkg.dev/projects/kapeta-production/kapeta-production-yum enabled=1 repo_gpgcheck=0 gpgcheck=0 EOF
Then update the package list and install the tool:
sudo dnf update sudo dnf install portpilot
Usage
-
Clone the repository and install the tool using
go install. -
Create a YAML file named
.portpilot.yaml. The YAML file should contain the configuration for the services you want to port forward. Below is an example of the YAML file structure:services: - name: example-service1 remotePort: 8080 localPort: 8081 - name: example-service2 remotePort: 8888 localPort: 8889
Customize the
name,remotePort, andlocalPortfields for each service as needed. -
Open a terminal and navigate to the directory containing the
services.yamlfile. -
Build and run the tool using the following command:
The tool will read the
services.yamlfile, establish port forwarding connections to the specified services, and print the local URLs for accessing each service. -
To stop the port forwarding, press
Ctrl+Cin the terminal.
Configuration
- The Kubernetes configuration is automatically read from the default
kubeconfigfile location ($HOME/.kube/config). Make sure you have a validkubeconfigfile configured for your cluster. - The tool uses the Kubernetes client Go library to interact with the cluster and perform the port forwarding.
Limitations
- The tool assumes the Kubernetes cluster is reachable using the default
kubeconfigconfiguration. - Only the first matching pod is used for each service. If multiple pods match the service selector, only the first pod will be used for port forwarding.
License
This tool is licensed under the MIT License.
