controllers

package
v0.0.0-...-b66e341 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2023 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Overview

Package controllers provides controller code for multus-proxy.

Index

Constants

View Source
const (
	// Cri based runtime (e.g. cri-o)
	Cri = "cri"
)

Variables

This section is empty.

Functions

func CloseCriConnection

func CloseCriConnection(conn *grpc.ClientConn) error

CloseCriConnection closes grpc connection in client

func GetCriRuntimeClient

func GetCriRuntimeClient(runtimeEndpoint, hostPrefix string) (pb.RuntimeServiceClient, *grpc.ClientConn, error)

GetCriRuntimeClient retrieves cri grpc client

func IsTargetPod

func IsTargetPod(pod *v1.Pod) bool

IsTargetPod ...

Types

type BaseEndpointInfo

type BaseEndpointInfo struct {
	Endpoint string // TODO: should be an endpointString type
	// IsLocal indicates whether the endpoint is running in same host as kube-proxy.
	IsLocal bool

	// ZoneHints represent the zone hints for the endpoint. This is based on
	// endpoint.hints.forZones[*].name in the EndpointSlice API.
	ZoneHints sets.String
	// Ready indicates whether this endpoint is ready and NOT terminating.
	// For pods, this is true if a pod has a ready status and a nil deletion timestamp.
	// This is only set when watching EndpointSlices. If using Endpoints, this is always
	// true since only ready endpoints are read from Endpoints.
	// TODO: Ready can be inferred from Serving and Terminating below when enabled by default.
	Ready bool
	// Serving indiciates whether this endpoint is ready regardless of its terminating state.
	// For pods this is true if it has a ready status regardless of its deletion timestamp.
	// This is only set when watching EndpointSlices. If using Endpoints, this is always
	// true since only ready endpoints are read from Endpoints.
	Serving bool
	// Terminating indicates whether this endpoint is terminating.
	// For pods this is true if it has a non-nil deletion timestamp.
	// This is only set when watching EndpointSlices. If using Endpoints, this is always
	// false since terminating endpoints are always excluded from Endpoints.
	Terminating bool
}

BaseEndpointInfo contains base information that defines an endpoint. This could be used directly by proxier while processing endpoints, or can be used for constructing a more specific EndpointInfo struct defined by the proxier if needed.

func (*BaseEndpointInfo) Equal

func (info *BaseEndpointInfo) Equal(other Endpoint) bool

Equal is part of proxy.Endpoint interface.

func (*BaseEndpointInfo) GetIsLocal

func (info *BaseEndpointInfo) GetIsLocal() bool

GetIsLocal is part of proxy.Endpoint interface.

func (*BaseEndpointInfo) GetZoneHints

func (info *BaseEndpointInfo) GetZoneHints() sets.String

GetZoneHints returns the zone hint for the endpoint.

func (*BaseEndpointInfo) IP

func (info *BaseEndpointInfo) IP() string

IP returns just the IP part of the endpoint, it's a part of proxy.Endpoint interface.

func (*BaseEndpointInfo) IsReady

func (info *BaseEndpointInfo) IsReady() bool

IsReady returns true if an endpoint is ready and not terminating.

func (*BaseEndpointInfo) IsServing

func (info *BaseEndpointInfo) IsServing() bool

IsServing returns true if an endpoint is ready, regardless of if the endpoint is terminating.

func (*BaseEndpointInfo) IsTerminating

func (info *BaseEndpointInfo) IsTerminating() bool

IsTerminating retruns true if an endpoint is terminating. For pods, that is any pod with a deletion timestamp.

func (*BaseEndpointInfo) Port

func (info *BaseEndpointInfo) Port() (int, error)

Port returns just the Port part of the endpoint.

func (*BaseEndpointInfo) String

func (info *BaseEndpointInfo) String() string

String is part of proxy.Endpoint interface.

type Endpoint

type Endpoint interface {
	// String returns endpoint string.  An example format can be: `IP:Port`.
	// We take the returned value as ServiceEndpoint.Endpoint.
	String() string
	// GetIsLocal returns true if the endpoint is running in same host as kube-proxy, otherwise returns false.
	GetIsLocal() bool
	// IsReady returns true if an endpoint is ready and not terminating.
	// This is only set when watching EndpointSlices. If using Endpoints, this is always
	// true since only ready endpoints are read from Endpoints.
	IsReady() bool
	// IsServing returns true if an endpoint is ready. It does not account
	// for terminating state.
	// This is only set when watching EndpointSlices. If using Endpoints, this is always
	// true since only ready endpoints are read from Endpoints.
	IsServing() bool
	// IsTerminating retruns true if an endpoint is terminating. For pods,
	// that is any pod with a deletion timestamp.
	// This is only set when watching EndpointSlices. If using Endpoints, this is always
	// false since terminating endpoints are always excluded from Endpoints.
	IsTerminating() bool
	// GetZoneHint returns the zone hint for the endpoint. This is based on
	// endpoint.hints.forZones[0].name in the EndpointSlice API.
	GetZoneHints() sets.String
	// IP returns IP part of the endpoint.
	IP() string
	// Port returns the Port part of the endpoint.
	Port() (int, error)
	// Equal checks if two endpoints are equal.
	Equal(Endpoint) bool
}

Endpoint in an interface which abstracts information about an endpoint.

type EndpointSliceCache

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

EndpointSliceCache is used as a cache of EndpointSlice information.

func NewEndpointSliceCache

func NewEndpointSliceCache(hostname string, ipFamily v1.IPFamily, recorder record.EventRecorder) *EndpointSliceCache

NewEndpointSliceCache initializes an EndpointSliceCache.

func (*EndpointSliceCache) EndpointSliceUpdate

func (cache *EndpointSliceCache) EndpointSliceUpdate(endpointSlice *discovery.EndpointSlice, remove bool) bool

EndpointSliceUpdate updates a pending slice in the cache.

type EndpointSliceConfig

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

EndpointSliceConfig ...

func NewEndpointSliceConfig

func NewEndpointSliceConfig(endpointSliceInformer discinformers.EndpointSliceInformer, resyncPeriod time.Duration) *EndpointSliceConfig

NewEndpointSliceConfig ...

func (*EndpointSliceConfig) RegisterEventHandler

func (c *EndpointSliceConfig) RegisterEventHandler(handler EndpointSliceHandler)

RegisterEventHandler registers a handler which is called on every endpointSlice change.

func (*EndpointSliceConfig) Run

func (c *EndpointSliceConfig) Run(stopCh <-chan struct{})

Run ...

type EndpointSliceHandler

type EndpointSliceHandler interface {
	// OnEndpointSliceAdd is called whenever creation of new object
	// is observed.
	OnEndpointSliceAdd(endpointSlice *discovery.EndpointSlice)
	// OnEndpointSliceUpdate is called whenever modification of an existing
	// object is observed.
	OnEndpointSliceUpdate(oldEndpointSlice, endpointSlice *discovery.EndpointSlice)
	// OnEndpointSliceDelete is called whenever deletion of an existing
	// object is observed.
	OnEndpointSliceDelete(endpointSlice *discovery.EndpointSlice)
	// OnEndpointSliceSynced is called once all the initial event handlers were
	// called and the state is fully propagated to local cache.
	OnEndpointSliceSynced()
}

EndpointSliceHandler is an abstract interface of objects which receive notifications about endpointSlice object changes.

type EndpointsMap

type EndpointsMap map[ServicePortName][]Endpoint

EndpointsMap maps a service name to a list of all its Endpoints.

func (EndpointsMap) Update

func (em EndpointsMap) Update(changes *EndpointSliceCache) (result UpdateEndpointMapResult)

Update updates endpointsMap base on the given changes.

type InterfaceInfo

type InterfaceInfo struct {
	NetattachName string
	InterfaceName string
	InterfaceType string
	IPs           []string
}

InterfaceInfo ...

func (*InterfaceInfo) CheckPolicyNetwork

func (info *InterfaceInfo) CheckPolicyNetwork(policyNetworks []string) bool

CheckPolicyNetwork checks whether given interface is target or not, based on policyNetworks

type PodChangeTracker

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

PodChangeTracker carries state about uncommitted changes to an arbitrary number of Pods in the node, keyed by their namespace and name

func NewPodChangeTracker

func NewPodChangeTracker(runtime RuntimeKind, runtimeEndpoint, hostname, hostPrefix string) *PodChangeTracker

NewPodChangeTracker ...

func NewPodChangeTrackerCri

func NewPodChangeTrackerCri(runtimeEndpoint, hostname, hostPrefix string) *PodChangeTracker

NewPodChangeTrackerCri ...

func (*PodChangeTracker) String

func (pct *PodChangeTracker) String() string

String

func (*PodChangeTracker) Update

func (pct *PodChangeTracker) Update(previous, current *v1.Pod) bool

Update ...

type PodConfig

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

PodConfig ...

func NewPodConfig

func NewPodConfig(podInformer coreinformers.PodInformer, resyncPeriod time.Duration) *PodConfig

NewPodConfig creates a new PodConfig.

func (*PodConfig) RegisterEventHandler

func (c *PodConfig) RegisterEventHandler(handler PodHandler)

RegisterEventHandler registers a handler which is called on every pod change.

func (*PodConfig) Run

func (c *PodConfig) Run(stopCh <-chan struct{})

Run waits for cache synced and invokes handlers after syncing.

type PodHandler

type PodHandler interface {
	// OnPodAdd is called whenever creation of new pod object
	// is observed.
	OnPodAdd(pod *v1.Pod)
	// OnPodUpdate is called whenever modification of an existing
	// pod object is observed.
	OnPodUpdate(oldPod, pod *v1.Pod)
	// OnPodDelete is called whenever deletion of an existing pod
	// object is observed.
	OnPodDelete(pod *v1.Pod)
	// OnPodSynced is called once all the initial event handlers were
	// called and the state is fully propagated to local cache.
	OnPodSynced()
}

PodHandler is an abstract interface of objects which receive notifications about pod object changes.

type PodInfo

type PodInfo struct {
	Name          string
	Namespace     string
	NetNSPath     string
	NetworkStatus []netdefv1.NetworkStatus
	NodeName      string
	Interfaces    []InterfaceInfo
}

PodInfo contains information that defines a pod.

func (*PodInfo) GetMultusNetIFs

func (info *PodInfo) GetMultusNetIFs() []string

GetMultusNetIFs ...

func (*PodInfo) String

func (info *PodInfo) String() string

String ...

type PodMap

type PodMap map[types.NamespacedName]PodInfo

PodMap ...

func (*PodMap) GetPodInfo

func (pm *PodMap) GetPodInfo(pod *v1.Pod) (*PodInfo, error)

GetPodInfo ...

func (*PodMap) Update

func (pm *PodMap) Update(changes *PodChangeTracker)

Update updates podMap base on the given changes

type RuntimeKind

type RuntimeKind string

RuntimeKind is enum type variable for container runtime

func (*RuntimeKind) Set

func (rk *RuntimeKind) Set(s string) error

Set specifies container runtime kind

func (RuntimeKind) String

func (rk RuntimeKind) String() string

String returns current runtime kind

func (RuntimeKind) Type

func (rk RuntimeKind) Type() string

Type returns its type, "RuntimeKind"

type ServiceChangeTracker

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

ServiceChangeTracker ...

func NewServiceChangeTracker

func NewServiceChangeTracker() *ServiceChangeTracker

NewServiceChangeTracker ...

func (*ServiceChangeTracker) Update

func (sct *ServiceChangeTracker) Update(previous, current *v1.Service) bool

Update ...

type ServiceConfig

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

ServiceConfig ...

func NewServiceConfig

func NewServiceConfig(serviceInformer coreinformers.ServiceInformer, resyncPeriod time.Duration) *ServiceConfig

NewServiceConfig ...

func (*ServiceConfig) RegisterEventHandler

func (c *ServiceConfig) RegisterEventHandler(handler ServiceHandler)

RegisterEventHandler registers a handler which is called on every service change.

func (*ServiceConfig) Run

func (c *ServiceConfig) Run(stopCh <-chan struct{})

Run ...

type ServiceEndpoint

type ServiceEndpoint struct {
	Endpoint        string
	ServicePortName ServicePortName
}

ServiceEndpoint is used to identify a service and one of its endpoint pair.

type ServiceHandler

type ServiceHandler interface {
	// OnServiceAdd is called whenever creation of new object
	// is observed.
	OnServiceAdd(service *v1.Service)
	// OnServiceUpdate is called whenever modification of an existing
	// object is observed.
	OnServiceUpdate(oldService, service *v1.Service)
	// OnServiceDelete is called whenever deletion of an existing
	// object is observed.
	OnServiceDelete(service *v1.Service)
	// OnServiceSynced is called once all the initial event handlers were
	// called and the state is fully propagated to local cache.
	OnServiceSynced()
}

ServiceHandler is an abstract interface of objects which receive notifications about service object changes.

type ServiceMap

type ServiceMap map[ServicePortName]ServicePortInfo

ServiceMap ... type ServiceMap map[types.NamespacedName]ServiceInfo

func (*ServiceMap) Update

func (n *ServiceMap) Update(changes *ServiceChangeTracker)

Update ...

type ServicePortInfo

type ServicePortInfo struct {
	Name          string
	ClusterIP     string
	TargetNetwork string
	Port          int
	TargetPort    intstr.IntOrString
	Protocol      string
	ChainName     string
}

ServicePortInfo contains information that defines a object.

type ServicePortName

type ServicePortName struct {
	types.NamespacedName
	Port     string
	Protocol v1.Protocol
}

ServicePortName carries a namespace + name + portname. This is the unique identifier for a load-balanced service.

func (ServicePortName) String

func (spn ServicePortName) String() string

type UpdateEndpointMapResult

type UpdateEndpointMapResult struct {
	// HCEndpointsLocalIPSize maps an endpoints name to the length of its local IPs.
	HCEndpointsLocalIPSize map[types.NamespacedName]int
	// StaleEndpoints identifies if an endpoints service pair is stale.
	StaleEndpoints []ServiceEndpoint
	// StaleServiceNames identifies if a service is stale.
	StaleServiceNames []ServicePortName
	// List of the trigger times for all endpoints objects that changed. It's used to export the
	// network programming latency.
	// NOTE(oxddr): this can be simplified to []time.Time if memory consumption becomes an issue.
	LastChangeTriggerTimes map[types.NamespacedName][]time.Time
}

UpdateEndpointMapResult is the updated results after applying endpoints changes.

Jump to

Keyboard shortcuts

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