portforward

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

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 IsPodReady(pod *corev1.Pod) bool

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.

Jump to

Keyboard shortcuts

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