allocator

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2018 License: Apache-2.0 Imports: 12 Imported by: 43 modules, 46 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IPAMArgs

type IPAMArgs struct {
	IPs []net.IP `json:"ips"`
}

type IPAMConfig

type IPAMConfig struct {
	*Range
	Name       string
	Type       string         `json:"type"`
	Routes     []*types.Route `json:"routes"`
	DataDir    string         `json:"dataDir"`
	ResolvConf string         `json:"resolvConf"`
	Ranges     []RangeSet     `json:"ranges"`
	IPArgs     []net.IP       `json:"-"` // Requested IPs from CNI_ARGS and args
}

IPAMConfig represents the IP related network configuration. This nests Range because we initially only supported a single range directly, and wish to preserve backwards compatability

func LoadIPAMConfig

func LoadIPAMConfig(bytes []byte, envArgs string) (*IPAMConfig, string, error)

NewIPAMConfig creates a NetworkConfig from the given network name.

type IPAMEnvArgs

type IPAMEnvArgs struct {
	types.CommonArgs
	IP net.IP `json:"ip,omitempty"`
}

type IPAllocator

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

func NewIPAllocator

func NewIPAllocator(s *RangeSet, store backend.Store, id int) *IPAllocator

func (*IPAllocator) Get

func (a *IPAllocator) Get(id string, requestedIP net.IP) (*current.IPConfig, error)

Get alocates an IP

func (*IPAllocator) GetIter

func (a *IPAllocator) GetIter() (*RangeIter, error)

GetIter encapsulates the strategy for this allocator. We use a round-robin strategy, attempting to evenly use the whole set. More specifically, a crash-looping container will not see the same IP until the entire range has been run through. We may wish to consider avoiding recently-released IPs in the future.

func (*IPAllocator) Release

func (a *IPAllocator) Release(id string) error

Release clears all IPs allocated for the container with given ID

type Net

type Net struct {
	Name          string      `json:"name"`
	CNIVersion    string      `json:"cniVersion"`
	IPAM          *IPAMConfig `json:"ipam"`
	RuntimeConfig struct {
		IPRanges []RangeSet `json:"ipRanges,omitempty"`
	} `json:"runtimeConfig,omitempty"`
	Args *struct {
		A *IPAMArgs `json:"cni"`
	} `json:"args"`
}

The top-level network config - IPAM plugins are passed the full configuration of the calling plugin, not just the IPAM section.

type Range

type Range struct {
	RangeStart net.IP      `json:"rangeStart,omitempty"` // The first ip, inclusive
	RangeEnd   net.IP      `json:"rangeEnd,omitempty"`   // The last ip, inclusive
	Subnet     types.IPNet `json:"subnet"`
	Gateway    net.IP      `json:"gateway,omitempty"`
}

func (*Range) Canonicalize

func (r *Range) Canonicalize() error

Canonicalize takes a given range and ensures that all information is consistent, filling out Start, End, and Gateway with sane values if missing

func (*Range) Contains

func (r *Range) Contains(addr net.IP) bool

IsValidIP checks if a given ip is a valid, allocatable address in a given Range

func (*Range) Overlaps

func (r *Range) Overlaps(r1 *Range) bool

Overlaps returns true if there is any overlap between ranges

func (*Range) String

func (r *Range) String() string

type RangeIter

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

func (*RangeIter) Next

func (i *RangeIter) Next() (*net.IPNet, net.IP)

Next returns the next IP, its mask, and its gateway. Returns nil if the iterator has been exhausted

type RangeSet

type RangeSet []Range

func (*RangeSet) Canonicalize

func (s *RangeSet) Canonicalize() error

Canonicalize ensures the RangeSet is in a standard form, and detects any invalid input. Call Range.Canonicalize() on every Range in the set

func (*RangeSet) Contains

func (s *RangeSet) Contains(addr net.IP) bool

Contains returns true if any range in this set contains an IP

func (*RangeSet) Overlaps

func (s *RangeSet) Overlaps(p1 *RangeSet) bool

Overlaps returns true if any ranges in any set overlap with this one

func (*RangeSet) RangeFor

func (s *RangeSet) RangeFor(addr net.IP) (*Range, error)

RangeFor finds the range that contains an IP, or nil if not found

func (*RangeSet) String

func (s *RangeSet) String() string

Jump to

Keyboard shortcuts

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