Documentation ¶
Index ¶
- Constants
- Variables
- func AcquireBackendID(l3n4Addr loadbalancer.L3n4Addr) (loadbalancer.BackendID, error)
- func AcquireID(l3n4Addr loadbalancer.L3n4Addr, baseID uint32) (*loadbalancer.L3n4AddrID, error)
- func DeleteBackendID(id loadbalancer.BackendID)
- func DeleteID(id uint32) error
- func GetID(id uint32) (*loadbalancer.L3n4AddrID, error)
- func LookupBackendID(l3n4Addr loadbalancer.L3n4Addr) (loadbalancer.BackendID, error)
- func RestoreBackendID(l3n4Addr loadbalancer.L3n4Addr, id loadbalancer.BackendID) error
- func RestoreID(l3n4Addr loadbalancer.L3n4Addr, baseID uint32) (*loadbalancer.L3n4AddrID, error)
- type ClusterService
- func (in *ClusterService) DeepCopy() *ClusterService
- func (in *ClusterService) DeepCopyInto(out *ClusterService)
- func (s *ClusterService) DeepKeyCopy() store.LocalKey
- func (s *ClusterService) GetKeyName() string
- func (s *ClusterService) Marshal() ([]byte, error)
- func (s *ClusterService) NamespaceServiceName() string
- func (s *ClusterService) String() string
- func (s *ClusterService) Unmarshal(data []byte) error
- type IDAllocator
- type LBMap
- type PortConfiguration
- type Service
- func (s *Service) DeleteService(frontend lb.L3n4Addr) (bool, error)
- func (s *Service) DeleteServiceByID(id lb.ServiceID) (bool, error)
- func (s *Service) GetDeepCopyServiceByID(id lb.ServiceID) (*lb.SVC, bool)
- func (s *Service) GetDeepCopyServices() []*lb.SVC
- func (s *Service) InitMaps(ipv6, ipv4, restore bool) error
- func (s *Service) RestoreServices() error
- func (s *Service) SyncWithK8sFinished() error
- func (s *Service) UpsertService(frontend lb.L3n4AddrID, backends []lb.Backend, svcType lb.SVCType, ...) (bool, lb.ID, error)
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. FirstFreeBackendID = uint32(1) // MaxSetOfBackendID is maximum number of set of backendIDs IDs that can be // stored in the local ID allocator. MaxSetOfBackendID = uint32(0xFFFF) )
Variables ¶
var ( // ServiceStorePrefix is the kvstore prefix of the shared store // // WARNING - STABLE API: Changing the structure or values of this will // break backwards compatibility ServiceStorePrefix = path.Join(kvstore.BaseKeyPrefix, "state", "services", "v1") )
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 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 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 ClusterService ¶ added in v1.5.0
type ClusterService struct { // Cluster is the cluster name the service is configured in Cluster string `json:"cluster"` // Namespace is the cluster namespace the service is configured in Namespace string `json:"namespace"` // Name is the name of the service. It must be unique within the // namespace of the cluster Name string `json:"name"` // Frontends is a map indexed by the frontend IP address Frontends map[string]PortConfiguration `json:"frontends"` // Backends is is map indexed by the backend IP address Backends map[string]PortConfiguration `json:"backends"` // Labels are the labels of the service Labels map[string]string `json:"labels"` // Selector is the label selector used to select backends Selector map[string]string `json:"selector"` }
ClusterService is the definition of a service in a cluster
WARNING - STABLE API: Any change to this structure must be done in a backwards compatible way.
+k8s:deepcopy-gen=true
func NewClusterService ¶ added in v1.5.0
func NewClusterService(name, namespace string) ClusterService
NewClusterService returns a new cluster service definition
func (*ClusterService) DeepCopy ¶ added in v1.5.0
func (in *ClusterService) DeepCopy() *ClusterService
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterService.
func (*ClusterService) DeepCopyInto ¶ added in v1.5.0
func (in *ClusterService) DeepCopyInto(out *ClusterService)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (*ClusterService) DeepKeyCopy ¶ added in v1.5.0
func (s *ClusterService) DeepKeyCopy() store.LocalKey
DeepKeyCopy creates a deep copy of the LocalKey
func (*ClusterService) GetKeyName ¶ added in v1.5.0
func (s *ClusterService) GetKeyName() string
GetKeyName returns the kvstore key to be used for the global service
func (*ClusterService) Marshal ¶ added in v1.5.0
func (s *ClusterService) Marshal() ([]byte, error)
Marshal returns the global service object as JSON byte slice
func (*ClusterService) NamespaceServiceName ¶ added in v1.5.0
func (s *ClusterService) NamespaceServiceName() string
NamespaceServiceName returns the namespace and service name
func (*ClusterService) String ¶ added in v1.5.0
func (s *ClusterService) String() string
func (*ClusterService) Unmarshal ¶ added in v1.5.0
func (s *ClusterService) Unmarshal(data []byte) error
Unmarshal parses the JSON byte slice and updates the global service receiver
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 LBMap ¶ added in v1.7.0
type LBMap interface { UpsertService(uint16, net.IP, uint16, []uint16, int, bool, lb.SVCType, bool) error DeleteService(lb.L3n4AddrID, int) error AddBackend(uint16, net.IP, uint16, bool) error DeleteBackendByID(uint16, bool) error DumpServiceMaps() ([]*lb.SVC, []error) DumpBackendMaps() ([]*lb.Backend, error) }
LBMap is the interface describing methods for manipulating service maps.
type PortConfiguration ¶ added in v1.5.0
type PortConfiguration map[string]*loadbalancer.L4Addr
PortConfiguration is the L4 port configuration of a frontend or backend. The map is indexed by the name of the port and the value constains the L4 port and protocol.
func (PortConfiguration) DeepEquals ¶ added in v1.5.0
func (p PortConfiguration) DeepEquals(o PortConfiguration) bool
DeepEquals returns true if both PortConfigurations are identical
type Service ¶
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 ¶
func NewService(monitorNotify monitorNotify) *Service
NewService creates a new instance of the service handler.
func (*Service) DeleteService ¶
DeleteService removes the given service.
func (*Service) DeleteServiceByID ¶
DeleteServiceByID removes a service identified by the given ID.
func (*Service) GetDeepCopyServiceByID ¶
GetDeepCopyServiceByID returns a deep-copy of a service identified with the given ID.
If a service cannot be found, returns false.
func (*Service) GetDeepCopyServices ¶
GetDeepCopyServices returns a deep-copy of all installed services.
func (*Service) InitMaps ¶
InitMaps opens or creates BPF maps used by services.
If restore is set to false, entries of the maps are removed.
func (*Service) RestoreServices ¶
RestoreServices restores services from BPF maps.
The method should be called once before establishing a connectivity to kube-apiserver.
func (*Service) SyncWithK8sFinished ¶
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 ¶
func (s *Service) UpsertService( frontend lb.L3n4AddrID, backends []lb.Backend, svcType lb.SVCType, svcTrafficPolicy lb.SVCTrafficPolicy, 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.