workload

package
v0.0.0-...-21cfbab Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: Apache-2.0, Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Opt

type Opt func(*Workload)

func WithListenAnyIP

func WithListenAnyIP() Opt

func WithMTU

func WithMTU(mtu int) Opt

type PersistentConnectionOpts

type PersistentConnectionOpts struct {
	SourcePort          int
	MonitorConnectivity bool
	Timeout             time.Duration
}

type Port

type Port struct {
	*Workload
	Port uint16
}

func (*Port) CanConnectTo

func (p *Port) CanConnectTo(ip, port, protocol string, opts ...connectivity.CheckOption) *connectivity.Result

Return if a connection is good and packet loss string "PacketLoss[xx]". If it is not a packet loss test, packet loss string is "".

func (*Port) PreRetryCleanup

func (p *Port) PreRetryCleanup(ip, port, protocol string, opts ...connectivity.CheckOption)

func (*Port) SourceIPs

func (p *Port) SourceIPs() []string

func (*Port) SourceName

func (p *Port) SourceName() string

func (*Port) ToMatcher

func (p *Port) ToMatcher(explicitPort ...uint16) *connectivity.Matcher

ToMatcher implements the connectionTarget interface, allowing this port to be used as target.

type SideService

type SideService struct {
	W       *Workload
	Name    string
	RunCmd  *exec.Cmd
	PidFile string
}

func (*SideService) Stop

func (s *SideService) Stop()

type SpoofedWorkload

type SpoofedWorkload struct {
	*Workload
	SpoofedSourceIP string
}

func (*SpoofedWorkload) CanConnectTo

func (s *SpoofedWorkload) CanConnectTo(ip, port, protocol string, opts ...connectivity.CheckOption) *connectivity.Result

func (*SpoofedWorkload) PreRetryCleanup

func (s *SpoofedWorkload) PreRetryCleanup(ip, port, protocol string, opts ...connectivity.CheckOption)

type Workload

type Workload struct {
	C             *containers.Container
	Name          string
	InterfaceName string
	IP            string
	Ports         string
	DefaultPort   string

	WorkloadEndpoint      *api.WorkloadEndpoint
	Protocol              string // "tcp" or "udp"
	SpoofInterfaceName    string
	SpoofName             string
	SpoofWorkloadEndpoint *api.WorkloadEndpoint
	MTU                   int
	// contains filtered or unexported fields
}

func New

func New(c *infrastructure.Felix, name, profile, ip, ports, protocol string, opts ...Opt) *Workload

func Run

func Run(c *infrastructure.Felix, name, profile, ip, ports, protocol string, opts ...Opt) (w *Workload)

func (*Workload) AddSpoofInterface

func (w *Workload) AddSpoofInterface()

AddSpoofInterface adds a second interface to the workload with name Workload.SpoofIfaceName and moves the workload's IP to its loopback so that we can maintain a TCP connection while moving routes between the two interfaces. From the host's point of view, this looks like one interface is trying to hijack the connection of the other.

func (*Workload) AttachTCPDump

func (w *Workload) AttachTCPDump() *tcpdump.TCPDump

AttachTCPDump returns tcpdump attached to the workload

func (*Workload) CanConnectTo

func (w *Workload) CanConnectTo(ip, port, protocol string, opts ...connectivity.CheckOption) *connectivity.Result

func (*Workload) Configure

func (w *Workload) Configure(client client.Interface)

Configure creates a workload endpoint in the datastore. Deprecated: should use ConfigureInInfra.

func (*Workload) ConfigureInInfra

func (w *Workload) ConfigureInInfra(infra infrastructure.DatastoreInfra)

ConfigureInInfra creates the workload endpoint for this Workload.

func (*Workload) ConfigureInInfraAsSpoofInterface

func (w *Workload) ConfigureInInfraAsSpoofInterface(infra infrastructure.DatastoreInfra)

ConfigureInInfraAsSpoofInterface creates a valid workload endpoint for this Workload, using the spoof interface added with AddSpoofInterface. After calling AddSpoofInterface(), UseSpoofInterface(true), and, this method, connectivity should work because the workload and felix will agree on the interface that should be used.

func (*Workload) ConfigureOtherWEPInInfraAsSpoofInterface

func (w *Workload) ConfigureOtherWEPInInfraAsSpoofInterface(infra infrastructure.DatastoreInfra)

ConfigureOtherWEPInInfraAsSpoofInterface creates a WEP for the spoof interface that does not match this Workload's IP address.

func (*Workload) Exec

func (w *Workload) Exec(args ...string)

func (*Workload) ExecCombinedOutput

func (w *Workload) ExecCombinedOutput(args ...string) (string, error)

func (*Workload) ExecOutput

func (w *Workload) ExecOutput(args ...string) (string, error)

func (*Workload) GetIP

func (w *Workload) GetIP() string

func (*Workload) GetInterfaceName

func (w *Workload) GetInterfaceName() string

func (*Workload) GetSpoofInterfaceName

func (w *Workload) GetSpoofInterfaceName() string

func (*Workload) IPNet

func (w *Workload) IPNet() string

func (*Workload) InterfaceIndex

func (w *Workload) InterfaceIndex() int

func (*Workload) LatencyTo

func (w *Workload) LatencyTo(ip, port string) (time.Duration, string)

func (*Workload) NameSelector

func (w *Workload) NameSelector() string

func (*Workload) NamespaceID

func (w *Workload) NamespaceID() string

func (*Workload) NamespacePath

func (w *Workload) NamespacePath() string

func (*Workload) PathMTU

func (w *Workload) PathMTU(ip string) (int, error)

func (*Workload) Port

func (w *Workload) Port(port uint16) *Port

func (*Workload) PreRetryCleanup

func (w *Workload) PreRetryCleanup(ip, port, protocol string, opts ...connectivity.CheckOption)

func (*Workload) RemoveFromDatastore

func (w *Workload) RemoveFromDatastore(client client.Interface)

RemoveFromDatastore removes the workload endpoint from the datastore. Deprecated: should use RemoveFromInfra.

func (*Workload) RemoveFromInfra

func (w *Workload) RemoveFromInfra(infra infrastructure.DatastoreInfra)

RemoveFromInfra removes the WEP created by ConfigureInInfra.

func (*Workload) RemoveSpoofWEPFromInfra

func (w *Workload) RemoveSpoofWEPFromInfra(infra infrastructure.DatastoreInfra)

RemoveSpoofWEPFromInfra removes the spoof WEP created by ConfigureInInfraAsSpoofInterface or ConfigureOtherWEPInInfraAsSpoofInterface.

func (*Workload) RunCmd

func (w *Workload) RunCmd(cmd string, args ...string) (string, error)

func (*Workload) Runs

func (w *Workload) Runs() bool

func (*Workload) SendPacketsTo

func (w *Workload) SendPacketsTo(ip string, count int, size int) (error, string)

func (*Workload) SourceIPs

func (w *Workload) SourceIPs() []string

func (*Workload) SourceName

func (w *Workload) SourceName() string

func (*Workload) Start

func (w *Workload) Start() error

func (*Workload) StartPersistentConnection

func (w *Workload) StartPersistentConnection(ip string, port int,
	opts PersistentConnectionOpts) *connectivity.PersistentConnection

func (*Workload) StartSideService

func (w *Workload) StartSideService() *SideService

func (*Workload) Stop

func (w *Workload) Stop()

func (*Workload) ToMatcher

func (w *Workload) ToMatcher(explicitPort ...uint16) *connectivity.Matcher

func (*Workload) UseSpoofInterface

func (w *Workload) UseSpoofInterface(spoof bool)

Jump to

Keyboard shortcuts

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