portforward

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 PodPortForward

func PodPortForward(ctx context.Context, config *rest.Config, clientset kubernetes.Interface, namespace, podName string, targetPort int32) (int, func(), error)

func ServicePodPortForward

func ServicePodPortForward(ctx context.Context, config *rest.Config, clientset kubernetes.Interface, namespace, service string, containerPort int32) (int, func(), error)

ServicePodPortForward forwards a random local port straight to containerPort on a ready pod behind the named Service, for ports the Service does not publish. Otherwise it behaves like ServicePortForward.

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