port-forward

command module
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2024 License: MIT Imports: 31 Imported by: 0

README

port-forward CI godoc goreportcard

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:

kubectl kustomize https://github.com/frantjc/port-forward/config/default?ref=v0.1.5 | 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:

kubectl apply -f - <<EOF
apiVersion: v1
kind: Service
metadata:
  name: sample
  annotations:
    pf.frantj.cc/forward: "yes"
spec:
  type: LoadBalancer
  ports:
    - port: 443
      targetPort: 443
  selector:
    your-label: your-pod
EOF

See sample for full list of supported annotations and their descriptions.

developing

You’ll need a Kubernetes cluster to run against. You can use KIND to get a local cluster for testing. Running against a remote cluster is likely not to work as the UPnP implementations rely 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.

Uses a 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.

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 which has an API to do such things.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal
extip
package extip provides the interface ExternalIPAddressGetter for getting the external IP address.
package extip provides the interface ExternalIPAddressGetter for getting the external IP address.
extip/extipraw
package extipraw provides an implementation of extip.ExternalIPAddressGetter that gets the external IP address from an environmental variable value.
package extipraw provides an implementation of extip.ExternalIPAddressGetter that gets the external IP address from an environmental variable value.
extip/extipupnp
package extipupnp provides an implementation of extip.ExternalIPAddressGetter that gets the external IP address from UPnP.
package extipupnp provides an implementation of extip.ExternalIPAddressGetter that gets the external IP address from UPnP.
portfwd
package portfwd provides the interface PortForwarder for forwarding an external port to an internal address.
package portfwd provides the interface PortForwarder for forwarding an external port to an internal address.
portfwd/portfwdupnp
package portfwdupnp provides an implementation of portfwd.PortForwarder that uses UPnP and a srcipmasq.SourceIPAddressMasqer.
package portfwdupnp provides an implementation of portfwd.PortForwarder that uses UPnP and a srcipmasq.SourceIPAddressMasqer.
srcipmasq
package srcipmasq the interface SourceIPAddressMasqer for masqing the source IP address.
package srcipmasq the interface SourceIPAddressMasqer for masqing the source IP address.
srcipmasq/srcipmasqiptables
package srcipmasqiptables provides an implementation of srcipmasq.SourceIPAddressMasqer that masqs the source IP using `iptables`.
package srcipmasqiptables provides an implementation of srcipmasq.SourceIPAddressMasqer that masqs the source IP using `iptables`.
srcipmasq/srcipmasqnftables
package srcipmasqnftables provides an implementation of srcipmasq.SourceIPAddressMasqer that masqs the source IP using the nftables protocol in pure go.
package srcipmasqnftables provides an implementation of srcipmasq.SourceIPAddressMasqer that masqs the source IP using the nftables protocol in pure go.
svcip
package svcip provides the interface ServiceIPAddressGetter for getting the external IP address of a Service.
package svcip provides the interface ServiceIPAddressGetter for getting the external IP address of a Service.
svcip/svcipdef
package svcipdef provides an implementation of svcip.ServiceIPAddressGetter that gets the external IP address from the given Service.
package svcipdef provides an implementation of svcip.ServiceIPAddressGetter that gets the external IP address from the given Service.
svcip/svcipraw
package svcipraw provides an implementation of svcip.ServiceIPAddressGetter that gets the Service's IP addresses itself
package svcipraw provides an implementation of svcip.ServiceIPAddressGetter that gets the Service's IP addresses itself

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL