service

package
v1.14.2 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FirstFreeServiceID is the first ID for which the services should be assigned.
	FirstFreeServiceID = uint32(1)

	// MaxSetOfServiceID is maximum number of set of service IDs that can be stored
	// in the kvstore or the local ID allocator.
	MaxSetOfServiceID = uint32(0xFFFF)

	// FirstFreeBackendID is the first ID for which the backend should be assigned.
	// BPF datapath assumes that backend_id cannot be 0.
	FirstFreeBackendID = uint32(1)

	// MaxSetOfBackendID is maximum number of set of backendIDs IDs that can be
	// stored in the local ID allocator.
	MaxSetOfBackendID = uint32(0xFFFFFFFF)
)

Variables

This section is empty.

Functions

func AcquireBackendID

func AcquireBackendID(l3n4Addr loadbalancer.L3n4Addr) (loadbalancer.BackendID, error)

AcquireBackendID acquires a new local ID for the given backend.

func AcquireID

func AcquireID(l3n4Addr loadbalancer.L3n4Addr, baseID uint32) (*loadbalancer.L3n4AddrID, error)

AcquireID acquires a service ID

func DeleteBackendID

func DeleteBackendID(id loadbalancer.BackendID)

DeleteBackendID releases the given backend ID. TODO(brb) maybe provide l3n4Addr as an arg for the extra safety.

func DeleteID

func DeleteID(id uint32) error

DeleteID deletes the L3n4AddrID belonging to the given id from the kvstore.

func GetID

func GetID(id uint32) (*loadbalancer.L3n4AddrID, error)

GetID returns the L3n4AddrID that belongs to the given id.

func LookupBackendID

func LookupBackendID(l3n4Addr loadbalancer.L3n4Addr) (loadbalancer.BackendID, error)

LookupBackendID looks up already allocated backend ID for the given backend addr. If such cannot be found, returns an error.

func NewErrLocalRedirectServiceExists added in v1.14.0

func NewErrLocalRedirectServiceExists(frontend lb.L3n4AddrID, name lb.ServiceName) error

NewErrLocalRedirectServiceExists returns a new ErrLocalRedirectServiceExists

func RestoreBackendID

func RestoreBackendID(l3n4Addr loadbalancer.L3n4Addr, id loadbalancer.BackendID) error

RestoreBackendID tries to restore the given local ID for the given backend.

If ID cannot be restored (ID already taken), returns an error.

func RestoreID

func RestoreID(l3n4Addr loadbalancer.L3n4Addr, baseID uint32) (*loadbalancer.L3n4AddrID, error)

RestoreID restores previously used service ID

Types

type ErrLocalRedirectServiceExists added in v1.14.0

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

ErrLocalRedirectServiceExists represents an error when a Local redirect service exists with the same Frontend.

func (ErrLocalRedirectServiceExists) Error added in v1.14.0

func (*ErrLocalRedirectServiceExists) Is added in v1.14.0

type IDAllocator

type IDAllocator struct {
	// Protects entitiesID, entities, nextID and maxID
	lock.RWMutex
	// contains filtered or unexported fields
}

IDAllocator contains an internal state of the ID allocator.

func NewIDAllocator

func NewIDAllocator(nextID uint32, maxID uint32) *IDAllocator

NewIDAllocator creates a new ID allocator instance.

type L7LBInfo added in v1.14.0

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

type Service added in v1.14.0

type Service struct {
	lock.RWMutex
	// contains filtered or unexported fields
}

Service is a service handler. Its main responsibility is to reflect service-related changes into BPF maps used by datapath BPF programs. The changes can be triggered either by k8s_watcher or directly by API calls to the /services endpoint.

func NewService added in v1.14.0

func NewService(monitorNotify monitorNotify, envoyCache envoyCache, lbmap datapathTypes.LBMap) *Service

NewService creates a new instance of the service handler.

func (*Service) DeleteService added in v1.14.0

func (s *Service) DeleteService(frontend lb.L3n4Addr) (bool, error)

DeleteService removes the given service.

func (*Service) DeleteServiceByID added in v1.14.0

func (s *Service) DeleteServiceByID(id lb.ServiceID) (bool, error)

DeleteServiceByID removes a service identified by the given ID.

func (*Service) GetCurrentTs added in v1.14.0

func (s *Service) GetCurrentTs() time.Time

func (*Service) GetDeepCopyServiceByID added in v1.14.0

func (s *Service) GetDeepCopyServiceByID(id lb.ServiceID) (*lb.SVC, bool)

GetDeepCopyServiceByID returns a deep-copy of a service identified with the given ID.

If a service cannot be found, returns false.

func (*Service) GetDeepCopyServices added in v1.14.0

func (s *Service) GetDeepCopyServices() []*lb.SVC

GetDeepCopyServices returns a deep-copy of all installed services.

func (*Service) GetDeepCopyServicesByName added in v1.14.0

func (s *Service) GetDeepCopyServicesByName(name, namespace string) (svcs []*lb.SVC)

GetDeepCopyServicesByName returns a deep-copy all matching services.

func (*Service) GetLastUpdatedTs added in v1.14.0

func (s *Service) GetLastUpdatedTs() time.Time

func (*Service) GetServiceNameByAddr added in v1.14.0

func (s *Service) GetServiceNameByAddr(addr lb.L3n4Addr) (string, string, bool)

GetServiceNameByAddr returns namespace and name of the service with a given L3n4Addr. The third return value is set to true if and only if the service is found in the map.

func (*Service) InitMaps added in v1.14.0

func (s *Service) InitMaps(ipv6, ipv4, sockMaps, restore bool) error

InitMaps opens or creates BPF maps used by services.

If restore is set to false, entries of the maps are removed.

func (*Service) RegisterL7LBService added in v1.14.0

func (s *Service) RegisterL7LBService(serviceName, resourceName lb.ServiceName, ports []string, proxyPort uint16) error

RegisterL7LBService makes the given service to be locally forwarded to the given proxy port.

func (*Service) RegisterL7LBServiceBackendSync added in v1.14.0

func (s *Service) RegisterL7LBServiceBackendSync(serviceName, resourceName lb.ServiceName, ports []string) error

RegisterL7LBServiceBackendSync synchronizes the backends of a service to Envoy.

func (*Service) RemoveL7LBService added in v1.14.0

func (s *Service) RemoveL7LBService(serviceName, resourceName lb.ServiceName) error

func (*Service) RestoreServices added in v1.14.0

func (s *Service) RestoreServices() error

RestoreServices restores services from BPF maps.

The method should be called once before establishing a connectivity to kube-apiserver.

func (*Service) SyncServicesOnDeviceChange added in v1.14.0

func (s *Service) SyncServicesOnDeviceChange(nodeAddressing types.NodeAddressing)

SyncServicesOnDeviceChange finds and adds missing load-balancing entries for new devices.

func (*Service) SyncWithK8sFinished added in v1.14.0

func (s *Service) SyncWithK8sFinished() error

SyncWithK8sFinished removes services which we haven't heard about during a sync period of cilium-agent's k8s service cache.

The removal is based on an assumption that during the sync period UpsertService() is going to be called for each alive service.

func (*Service) UpdateBackendsState added in v1.14.0

func (s *Service) UpdateBackendsState(backends []*lb.Backend) error

UpdateBackendsState updates all the service(s) with the updated state of the given backends. It also persists the updated backend states to the BPF maps.

Backend state transitions are validated before processing.

In case of duplicated backends in the list, the state will be updated to the last duplicate entry.

func (*Service) UpsertService added in v1.14.0

func (s *Service) UpsertService(params *lb.SVC) (bool, lb.ID, error)

UpsertService inserts or updates the given service.

The first return value is true if the service hasn't existed before.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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