portforward

package
v2.3.7 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2023 License: Apache-2.0 Imports: 35 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SimulateDevCycle

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

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

Types

type Config

type Config interface {
	kubectl.Config

	Mode() config.RunMode
	PortForwardResources() []*latest.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

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 []*latest.PortForwardResource) *ForwarderManager

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

func (*ForwarderManager) AddPodForwarder

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

func (*ForwarderManager) Name

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

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

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

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

func NewUserDefinedForwarder(entryManager *EntryManager, kubeContext string, userDefinedResources []*latest.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 []latest.PortForwardResource and forwards them.

func (*ResourceForwarder) Stop

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

func (p *WatchingPodForwarder) Stop()

Jump to

Keyboard shortcuts

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