https://github.com/frantjc/port-forward
Port forward to internal Kubernetes Services.
https://github.com/frantjc/port-forward
go golang kubernetes kubernetes-controller kubernetes-operator networking
Last synced: about 1 month ago
JSON representation
Port forward to internal Kubernetes Services.
- Host: GitHub
- URL: https://github.com/frantjc/port-forward
- Owner: frantjc
- License: mit
- Created: 2024-09-22T03:57:53.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-03-17T13:04:31.000Z (about 2 months ago)
- Last Synced: 2025-03-17T13:35:28.900Z (about 2 months ago)
- Topics: go, golang, kubernetes, kubernetes-controller, kubernetes-operator, networking
- Language: Go
- Homepage:
- Size: 181 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# port-forward [](https://github.com/frantjc/port-forward/actions) [](https://pkg.go.dev/github.com/frantjc/port-forward) [](https://goreportcard.com/report/github.com/frantjc/port-forward)
Port Forward is a Kubernetes Controller that forwards external ports to Kubernetes Services of type LoadBalancer which have been assigned private IP addresses. This is useful for clusters using something like MetalLB to expose Services internally that then want to expose some of them externally.
## use
Install Port Forward:
```sh
kubectl kustomize https://github.com/frantjc/port-forward/config/default?ref=v0.1.7 | kubectl apply -f-
```> Don't have MetalLB or something else to assign an IP address to the Service? Try adding the argument `--override-ip-address=192.168.0.11` to Port Forward.
And give it something to do:
```sh
kubectl apply -f - < See [sample](./config/samples/service.yaml) for full list of supported annotations and their descriptions.## developing
You’ll need a Kubernetes cluster to run against. You can use [KIND](https://sigs.k8s.io/kind) to get a local cluster for testing. Running against a remote cluster is likely not to work as the UPnP implementation relies on being on the host network of a Node of the cluster.
Port Forward will automatically use the current context in your kubeconfig file (i.e. whatever cluster `kubectl cluster-info` shows).
Uses the Kubernetes [Operator pattern](https://kubernetes.io/docs/concepts/extend-kubernetes/operator/).
Uses a [Controller](https://kubernetes.io/docs/concepts/architecture/controller/), which provides a reconcile function responsible for continually synchronizing Services of type LoadBalancer to reach and maintain the desired state.
More information can be found via the [Kubebuilder Documentation](https://book.kubebuilder.io/introduction.html).
Uses SNAT and UPnP to tell a router what to port forward. Written in such a way that more secure implementations can be written for networking devices that support them such as OPNsense.