poolallocator

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IPPoolAllocator

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

IPPoolAllocator is responsible for allocating IPs from IP set defined in IPPool CRD. The will update CRD usage accordingly. Pool Allocator assumes that pool with allocated IPs can not be deleted. Pool ranges can only be extended.

func NewIPPoolAllocator

func NewIPPoolAllocator(poolName string, client crdclientset.Interface) (*IPPoolAllocator, error)

NewIPPoolAllocator creates an IPPoolAllocator based on the provided IP pool.

func (*IPPoolAllocator) AllocateIP

AllocateIP allocates the specified IP. It returns error if the IP is not in the range or already allocated, or in case CRD failed to update its state. In case of success, IP pool CRD status is updated with allocated IP/state/resource/container. AllocateIP returns subnet details for the requested IP, as defined in IP pool spec.

func (*IPPoolAllocator) AllocateNext

AllocateNext allocates the next available IP. It returns error if pool is exausted, or in case CRD failed to update its state. In case of success, IP pool CRD status is updated with allocated IP/state/resourcei/container. AllocateIP returns subnet details for the requested IP, as defined in IP pool spec.

func (*IPPoolAllocator) HasContainer

func (a *IPPoolAllocator) HasContainer(containerID string) (bool, error)

HasResource checks whether an IP was associated with specified container. It returns error if the resource is crd fails to be retrieved.

func (*IPPoolAllocator) HasPod

func (a *IPPoolAllocator) HasPod(namespace, podName string) (bool, error)

HasResource checks whether an IP was associated with specified pod. It returns error if the resource is crd fails to be retrieved.

func (*IPPoolAllocator) Release

func (a *IPPoolAllocator) Release(ip net.IP) error

Release releases the provided IP. It returns error if the IP is not in the range or not allocated, or in case CRD failed to update its state. In case of success, IP pool CRD status is updated with released IP/state/resource.

func (*IPPoolAllocator) ReleaseContainerIfPresent

func (a *IPPoolAllocator) ReleaseContainerIfPresent(containerID string) error

ReleaseContainerIfPresent releases the IP associated with specified container ID if present in state. It returns error in case CRD failed to update its state, or if pool does not exist. In case of success, IP pool CRD status is updated with released entry.

func (*IPPoolAllocator) ReleasePod

func (a *IPPoolAllocator) ReleasePod(namespace, podName string) error

ReleaseResource releases the IP associated with specified Pod. It returns error if the resource is not present in state or in case CRD failed to update its state. In case of success, IP pool CRD status is updated with released entry.

Jump to

Keyboard shortcuts

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