portforward

package
v1.35.0-aplha Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2021 License: Apache-2.0 Imports: 35 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SimulateDevCycle added in v1.7.1

func SimulateDevCycle(t *testing.T, kubectlCLI *kubectl.CLI, namespace string)

SimulateDevCycle is used for testing a port forward + stop + restart in a simulated dev cycle

Types

type Config added in v1.27.0

type Config interface {
	kubectl.Config

	Mode() config.RunMode
	PortForwardResources() []*latestV1.PortForwardResource
	PortForwardOptions() config.PortForwardOptions
}

type EntryForwarder

type EntryForwarder interface {
	Start(io.Writer)
	Forward(parentCtx context.Context, pfe *portForwardEntry) error
	Terminate(p *portForwardEntry)
}

type EntryManager

type EntryManager struct {
	// contains filtered or unexported fields
}

EntryManager handles forwarding entries and keeping track of forwarded ports and resources.

func NewEntryManager

func NewEntryManager(entryForwarder EntryForwarder) *EntryManager

NewEntryManager returns a new port forward entry manager to keep track of forwarded ports and resources

func (*EntryManager) Start added in v1.27.0

func (b *EntryManager) Start(out io.Writer)

Start ensures the underlying entryForwarder is ready to forward.

func (*EntryManager) Stop

func (b *EntryManager) Stop()

Stop terminates all kubectl port-forward commands.

func (*EntryManager) Terminate

func (b *EntryManager) Terminate(p *portForwardEntry)

Terminate terminates a single port forward entry

type Forwarder

type Forwarder interface {
	// Start initiates the forwarder's operation. It should not return until any ports have been allocated.
	Start(ctx context.Context, out io.Writer, namespaces []string) error
	Stop()
}

Forwarder is an interface that can modify and manage port-forward processes

type ForwarderManager

type ForwarderManager struct {
	// contains filtered or unexported fields
}

ForwarderManager manages all forwarders

func NewForwarderManager

func NewForwarderManager(cli *kubectl.CLI, podSelector kubernetes.PodSelector, label string, runMode config.RunMode, namespaces *[]string,
	options config.PortForwardOptions, userDefined []*latestV1.PortForwardResource) *ForwarderManager

NewForwarderManager returns a new port manager which handles starting and stopping port forwarding

func (*ForwarderManager) AddPodForwarder added in v1.32.0

func (p *ForwarderManager) AddPodForwarder(cli *kubectl.CLI, podSelector kubernetes.PodSelector, runMode config.RunMode, options config.PortForwardOptions)

func (*ForwarderManager) Name added in v1.26.0

func (p *ForwarderManager) Name() string

func (*ForwarderManager) Start

func (p *ForwarderManager) Start(ctx context.Context, out io.Writer) error

Start begins all forwarders managed by the ForwarderManager

func (*ForwarderManager) Stop

func (p *ForwarderManager) Stop()

type KubectlForwarder

type KubectlForwarder struct {
	// contains filtered or unexported fields
}

func NewKubectlForwarder added in v0.37.0

func NewKubectlForwarder(cli *kubectl.CLI) *KubectlForwarder

NewKubectlForwarder returns a new KubectlForwarder

func (*KubectlForwarder) Forward

func (k *KubectlForwarder) Forward(parentCtx context.Context, pfe *portForwardEntry) error

Forward port-forwards a pod using kubectl port-forward in the background. It kills the command on errors in the kubectl port-forward log It restarts the command if it was not cancelled by skaffold It retries in case the port is taken

func (*KubectlForwarder) Start added in v1.27.0

func (k *KubectlForwarder) Start(out io.Writer)

func (*KubectlForwarder) Terminate

func (*KubectlForwarder) Terminate(p *portForwardEntry)

Terminate terminates an existing kubectl port-forward command using SIGTERM

type ResourceForwarder

type ResourceForwarder struct {
	// contains filtered or unexported fields
}

ResourceForwarder is responsible for forwarding user defined port forwarding resources and automatically forwarding services deployed by skaffold.

func NewServicesForwarder added in v1.22.0

func NewServicesForwarder(entryManager *EntryManager, kubeContext string, label string) *ResourceForwarder

NewServicesForwarder returns a struct that tracks and port-forwards services as they are created and modified

func NewUserDefinedForwarder added in v1.22.0

func NewUserDefinedForwarder(entryManager *EntryManager, kubeContext string, userDefinedResources []*latestV1.PortForwardResource) *ResourceForwarder

NewUserDefinedForwarder returns a struct that tracks and port-forwards services as they are created and modified

func (*ResourceForwarder) Start

func (p *ResourceForwarder) Start(ctx context.Context, out io.Writer, namespaces []string) error

Start gets a list of services deployed by skaffold as []latestV1.PortForwardResource and forwards them.

func (*ResourceForwarder) Stop added in v1.7.1

func (p *ResourceForwarder) Stop()

type WatchingPodForwarder

type WatchingPodForwarder struct {
	// contains filtered or unexported fields
}

WatchingPodForwarder is responsible for selecting pods satisfying a certain condition and port-forwarding the exposed container ports within those pods. It also tracks and manages the port-forward connections.

func NewWatchingPodForwarder

func NewWatchingPodForwarder(entryManager *EntryManager, kubeContext string, podSelector kubernetes.PodSelector, containerPorts portSelector) *WatchingPodForwarder

NewWatchingPodForwarder returns a struct that tracks and port-forwards pods as they are created and modified

func (*WatchingPodForwarder) Start

func (p *WatchingPodForwarder) Start(ctx context.Context, out io.Writer, namespaces []string) error

func (*WatchingPodForwarder) Stop added in v1.7.1

func (p *WatchingPodForwarder) Stop()

Jump to

Keyboard shortcuts

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