forwarder

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package forwarder implements a Kubernetes pod port-forwarding client, similar to the `kubectl port-forward` command. Like kubectl, it can resolve an appropriate pod from a higher level object's selectors, e.g., a Service or Deployment.

Package forwarder contains a few functions that are borrowed from kubernetes/kubectl repo. They are private and cannot be used directly. https://github.com/kubernetes/kubectl/blob/0b0920722212395d20fd0eecb5abf45ecb3e0cac/pkg/cmd/portforward/portforward.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Namespace string

	AttachablePodForObjectFn func(resource string, namespace string, timeout time.Duration) (interface{}, *v1.Pod, error)
	// contains filtered or unexported fields
}

Client interfaces with Kubernetes to facilitate a port-forwarding tunnel as well as fetch information about the forwarding target.

func NewClient

func NewClient(timeout time.Duration, streams genericclioptions.IOStreams) *Client

NewClient returns an uninitialized forwarding client.

func (Client) Forward

func (c Client) Forward(config *Config, readyChan chan Connection, stopChan chan struct{}) error

Forward creates a port-forwarding connection to the target noted by the ForwardConfig object.

func (*Client) Init

func (c *Client) Init(getter genericclioptions.RESTClientGetter, version string) error

Init instantiates a Kubernetes client and rest configuration for the forwarding client.

func (Client) NewConfig

func (c Client) NewConfig(resource string, portMap string) (*Config, error)

NewConfig interacts with the Kubernetes API to find a pod and ports suitable for forwarding.

type Config

type Config struct {
	Pod  *corev1.Pod
	Port string
}

Config contains the information required to satisfy a call to Forward.

func (Config) GetLocalPort

func (c Config) GetLocalPort() (port int, err error)

GetLocalPort returns the local ports from the Config port mapping.

type Connection added in v0.0.6

type Connection struct {
	Local  int
	Remote int
}

Connection stores port-forwarding information for an open connection.

Jump to

Keyboard shortcuts

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