cilium: github.com/cilium/cilium/pkg/service Index | Files | Directories

package service

import "github.com/cilium/cilium/pkg/service"

Index

Package Files

const.go id.go id_local.go logfields.go service.go

Constants

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(0xFFFF)
)

func AcquireBackendID Uses

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

AcquireBackendID acquires a new local ID for the given backend.

func AcquireID Uses

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

AcquireID acquires a service ID

func DeleteBackendID Uses

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 Uses

func DeleteID(id uint32) error

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

func GetID Uses

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

GetID returns the L3n4AddrID that belongs to the given id.

func LookupBackendID Uses

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 RestoreBackendID Uses

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 Uses

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

RestoreID restores previously used service ID

type IDAllocator Uses

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 Uses

func NewIDAllocator(nextID uint32, maxID uint32) *IDAllocator

NewIDAllocator creates a new ID allocator instance.

type LBMap Uses

type LBMap interface {
    UpsertService(uint16, net.IP, uint16, []uint16, int, bool, lb.SVCType, bool, uint8, bool, uint32) error
    DeleteService(lb.L3n4AddrID, int) error
    AddBackend(uint16, net.IP, uint16, bool) error
    DeleteBackendByID(uint16, bool) error
    AddAffinityMatch(uint16, uint16) error
    DeleteAffinityMatch(uint16, uint16) error
    DumpServiceMaps() ([]*lb.SVC, []error)
    DumpBackendMaps() ([]*lb.Backend, error)
    DumpAffinityMatches() (lbmap.BackendIDByServiceIDSet, error)
}

LBMap is the interface describing methods for manipulating service maps.

type Service Uses

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 Uses

func NewService(monitorNotify monitorNotify) *Service

NewService creates a new instance of the service handler.

func (*Service) DeleteService Uses

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

DeleteService removes the given service.

func (*Service) DeleteServiceByID Uses

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

DeleteServiceByID removes a service identified by the given ID.

func (*Service) GetDeepCopyServiceByID Uses

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 Uses

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

GetDeepCopyServices returns a deep-copy of all installed services.

func (*Service) GetServiceNameByAddr Uses

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 Uses

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) RestoreServices Uses

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) SyncWithK8sFinished Uses

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) UpsertService Uses

func (s *Service) UpsertService(
    frontend lb.L3n4AddrID, backends []lb.Backend, svcType lb.SVCType,
    svcTrafficPolicy lb.SVCTrafficPolicy,
    sessionAffinity bool, sessionAffinityTimeoutSec uint32,
    svcHealthCheckNodePort uint16,
    svcName, svcNamespace string) (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

PathSynopsis
healthserver
store

Package service imports 15 packages (graph) and is imported by 14 packages. Updated 2020-07-03. Refresh now. Tools for package owners.