Documentation
¶
Overview ¶
Package portforward tunnels to the pods behind a Service. The Kubernetes port-forward API is pod-scoped, so "forwarding to a Service" means resolving its selector to one ready pod and its port mapping to a container port, then forwarding to that pod. This is the same thing kubectl does for `port-forward svc/<service-name>`.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsPodReady ¶
func ServicePortForward ¶
func ServicePortForward(ctx context.Context, config *rest.Config, clientset kubernetes.Interface, namespace, service string, servicePort int32) (int, func(), error)
ServicePortForward forwards a random local port to servicePort of the named Service. It picks a ready backing pod, resolves servicePort to the pod's container port (including named targetPorts), and tunnels to that pod. It returns the chosen local port and a stop func the caller must invoke to tear the tunnel down. The tunnel is pinned to the picked pod; it does not fail over if that pod later dies.
Types ¶
This section is empty.