endpointmanager

package
v1.15.4 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: Apache-2.0 Imports: 42 Imported by: 30

Documentation

Overview

Package endpointmanager manages the list of all local endpoints

Index

Constants

This section is empty.

Variables

View Source
var Cell = cell.Module(
	"endpoint-manager",
	"Manages the collection of local endpoints",

	cell.Config(defaultEndpointManagerConfig),
	cell.Provide(newDefaultEndpointManager),
	cell.ProvidePrivate(newEndpointSynchronizer),
)

Cell provides the EndpointManager which maintains the collection of locally running Cilium endpoints. Also exposed are EndpointsLookup and EndpointsModify APIs that EndpointManager implements. If possible, choose the minimal API as your dependency.

View Source
var (
	// ErrUnsupportedID represents an error of unsupported IP address format.
	ErrUnsupportedID = errors.New("unsupported IP address format")
)

Functions

func IsErrInvalidPrefix added in v0.15.7

func IsErrInvalidPrefix(err error) bool

IsErrInvalidPrefix returns true if the given error is the type of ErrInvalidPrefix.

func IsErrUnsupportedID added in v0.15.7

func IsErrUnsupportedID(err error) bool

IsErrUnsupportedID returns true if the given error is the type of ErrUnsupportedID.

func New added in v0.15.7

func New(epSynchronizer EndpointResourceSynchronizer, lns *node.LocalNodeStore, reporterScope cell.Scope) *endpointManager

New creates a new endpointManager.

Types

type EndpointCheckerFunc added in v0.15.7

type EndpointCheckerFunc func(*endpoint.Endpoint) error

EndpointCheckerFunc can verify whether an endpoint is currently healthy.

type EndpointManager added in v0.15.7

type EndpointManager interface {
	EndpointsLookup
	EndpointsModify
	EndpointResourceSynchronizer

	// Subscribe to endpoint events.
	Subscribe(s Subscriber)

	// Unsubscribe from endpoint events.
	Unsubscribe(s Subscriber)

	// UpdatePolicyMaps returns a WaitGroup which is signaled upon once all endpoints
	// have had their PolicyMaps updated against the Endpoint's desired policy state.
	//
	// Endpoints will wait on the 'notifyWg' parameter before updating policy maps.
	UpdatePolicyMaps(ctx context.Context, notifyWg *sync.WaitGroup) *sync.WaitGroup

	// RegenerateAllEndpoints calls a setState for each endpoint and
	// regenerates if state transaction is valid. During this process, the endpoint
	// list is locked and cannot be modified.
	// Returns a waiting group that can be used to know when all the endpoints are
	// regenerated.
	RegenerateAllEndpoints(regenMetadata *regeneration.ExternalRegenerationMetadata) *sync.WaitGroup

	// WaitForEndpointsAtPolicyRev waits for all endpoints which existed at the time
	// this function is called to be at a given policy revision.
	// New endpoints appearing while waiting are ignored.
	WaitForEndpointsAtPolicyRev(ctx context.Context, rev uint64) error

	// OverrideEndpointOpts applies the given options to all endpoints.
	OverrideEndpointOpts(om option.OptionMap)

	// InitHostEndpointLabels initializes the host endpoint's labels with the
	// node's known labels.
	InitHostEndpointLabels(ctx context.Context)

	// GetPolicyEndpoints returns a map of all endpoints present in endpoint
	// manager as policy.Endpoint interface set for the map key.
	GetPolicyEndpoints() map[policy.Endpoint]struct{}

	// HasGlobalCT returns true if the endpoints have a global CT, false otherwise.
	HasGlobalCT() bool

	// CallbackForEndpointsAtPolicyRev registers a callback on all endpoints that
	// exist when invoked. It is similar to WaitForEndpointsAtPolicyRevision but
	// each endpoint that reaches the desired revision calls 'done' independently.
	// The provided callback should not block and generally be lightweight.
	CallbackForEndpointsAtPolicyRev(ctx context.Context, rev uint64, done func(time.Time)) error
}

type EndpointManagerConfig added in v0.15.7

type EndpointManagerConfig struct {
	// EndpointGCInterval is interval to attempt garbage collection of
	// endpoints that are no longer alive and healthy.
	EndpointGCInterval time.Duration
}

func (EndpointManagerConfig) Flags added in v0.15.7

func (def EndpointManagerConfig) Flags(flags *pflag.FlagSet)

type EndpointResourceSynchronizer added in v0.15.7

type EndpointResourceSynchronizer interface {
	RunK8sCiliumEndpointSync(ep *endpoint.Endpoint, conf endpoint.EndpointStatusConfiguration, hr cell.HealthReporter)
	DeleteK8sCiliumEndpointSync(e *endpoint.Endpoint)
}

EndpointResourceSynchronizer is an interface which synchronizes CiliumEndpoint resources with Kubernetes.

type EndpointSynchronizer added in v1.5.0

type EndpointSynchronizer struct {
	Clientset client.Clientset
}

EndpointSynchronizer currently is an empty type, which wraps around syncing of CiliumEndpoint resources.

func (*EndpointSynchronizer) DeleteK8sCiliumEndpointSync added in v1.15.0

func (epSync *EndpointSynchronizer) DeleteK8sCiliumEndpointSync(e *endpoint.Endpoint)

DeleteK8sCiliumEndpointSync replaces the endpoint controller to remove the CEP from Kubernetes once the endpoint is stopped / removed from the Cilium agent.

func (*EndpointSynchronizer) RunK8sCiliumEndpointSync added in v1.15.0

func (epSync *EndpointSynchronizer) RunK8sCiliumEndpointSync(e *endpoint.Endpoint, conf endpoint.EndpointStatusConfiguration, hr cell.HealthReporter)

RunK8sCiliumEndpointSync starts a controller that synchronizes the endpoint to the corresponding k8s CiliumEndpoint CRD. It is expected that each CEP has 1 controller that updates it, and a local copy is retained and only updates are pushed up. CiliumEndpoint objects have the same name as the pod they represent.

type EndpointsLookup added in v0.15.7

type EndpointsLookup interface {
	// Lookup looks up endpoint by prefix ID
	Lookup(id string) (*endpoint.Endpoint, error)

	// LookupCiliumID looks up endpoint by endpoint ID
	LookupCiliumID(id uint16) *endpoint.Endpoint

	// LookupCNIAttachmentID looks up endpoint by CNI attachment ID
	LookupCNIAttachmentID(id string) *endpoint.Endpoint

	// LookupIPv4 looks up endpoint by IPv4 address
	LookupIPv4(ipv4 string) *endpoint.Endpoint

	// LookupIPv6 looks up endpoint by IPv6 address
	LookupIPv6(ipv6 string) *endpoint.Endpoint

	// LookupIP looks up endpoint by IP address
	LookupIP(ip netip.Addr) (ep *endpoint.Endpoint)

	// LookupCEPName looks up endpoints by namespace + cep name, e.g. "prod/cep-0"
	LookupCEPName(name string) (ep *endpoint.Endpoint)

	// GetEndpointsByPodName looks up endpoints by namespace + pod name, e.g. "prod/pod-0"
	GetEndpointsByPodName(name string) []*endpoint.Endpoint

	// GetEndpointsByContainerID looks up endpoints by container ID
	GetEndpointsByContainerID(containerID string) []*endpoint.Endpoint

	// GetEndpoints returns a slice of all endpoints present in endpoint manager.
	GetEndpoints() []*endpoint.Endpoint

	// EndpointExists returns whether the endpoint with id exists.
	EndpointExists(id uint16) bool

	// GetHostEndpoint returns the host endpoint.
	GetHostEndpoint() *endpoint.Endpoint

	// HostEndpointExists returns true if the host endpoint exists.
	HostEndpointExists() bool

	// GetIngressEndpoint returns the ingress endpoint.
	GetIngressEndpoint() *endpoint.Endpoint

	// IngressEndpointExists returns true if the ingress endpoint exists.
	IngressEndpointExists() bool
}

type EndpointsModify added in v0.15.7

type EndpointsModify interface {
	// AddEndpoint takes the prepared endpoint object and starts managing it.
	AddEndpoint(owner regeneration.Owner, ep *endpoint.Endpoint, reason string) (err error)

	// AddIngressEndpoint creates an Endpoint representing Cilium Ingress on this node without a
	// corresponding container necessarily existing. This is needed to be able to ingest and
	// sync network policies applicable to Cilium Ingress to Envoy.
	AddIngressEndpoint(
		ctx context.Context,
		owner regeneration.Owner,
		policyGetter policyRepoGetter,
		ipcache *ipcache.IPCache,
		proxy endpoint.EndpointProxy,
		allocator cache.IdentityAllocator,
		reason string,
	) error

	AddHostEndpoint(
		ctx context.Context,
		owner regeneration.Owner,
		policyGetter policyRepoGetter,
		ipcache *ipcache.IPCache,
		proxy endpoint.EndpointProxy,
		allocator cache.IdentityAllocator,
		reason, nodeName string,
	) error

	// RestoreEndpoint exposes the specified endpoint to other subsystems via the
	// manager.
	RestoreEndpoint(ep *endpoint.Endpoint) error

	// UpdateReferences updates maps the contents of mappings to the specified endpoint.
	UpdateReferences(ep *endpoint.Endpoint) error

	// RemoveEndpoint stops the active handling of events by the specified endpoint,
	// and prevents the endpoint from being globally acccessible via other packages.
	RemoveEndpoint(ep *endpoint.Endpoint, conf endpoint.DeleteConfig) []error
}

type ErrInvalidPrefix added in v0.15.7

type ErrInvalidPrefix struct {
	// InvalidPrefix contains the invalid prefix.
	InvalidPrefix string
}

ErrInvalidPrefix represents the error of an invalid prefix.

func (ErrInvalidPrefix) Error added in v0.15.7

func (e ErrInvalidPrefix) Error() string

Error returns the string representation of the ErrInvalidPrefix.

type Subscriber added in v0.15.7

type Subscriber interface {
	// EndpointCreated is called at the end of endpoint creation.
	// Implementations must not attempt write operations on the
	// EndpointManager from this callback.
	// This function is being called inside a RLock, so it must not attempt
	// to acquire a lock on the EndpointManager.
	EndpointCreated(ep *endpoint.Endpoint)

	// EndpointDeleted is called at the end of endpoint deletion.
	// Implementations must not attempt write operations on the
	// EndpointManager from this callback.
	// This function is being called inside a RLock, so it must not attempt
	// to acquire a lock on the EndpointManager.
	EndpointDeleted(ep *endpoint.Endpoint, conf endpoint.DeleteConfig)
}

Subscribers may register via Subscribe() to be notified when events occur.

Jump to

Keyboard shortcuts

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