networkallocator

package
v2.0.0-...-e8ecf83 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: Apache-2.0 Imports: 4 Imported by: 50

Documentation

Index

Constants

View Source
const (
	// PredefinedLabel identifies internally allocated swarm networks
	// corresponding to the node-local predefined networks on the host.
	PredefinedLabel = "com.docker.swarm.predefined"
)

Variables

This section is empty.

Functions

func IsIngressNetwork

func IsIngressNetwork(nw *api.Network) bool

IsIngressNetwork check if the network is an ingress network

func IsIngressNetworkNeeded

func IsIngressNetworkNeeded(s *api.Service) bool

IsIngressNetworkNeeded checks whether the service requires the routing-mesh

func OnInit

func OnInit(options *ServiceAllocationOpts)

OnInit is called for allocator initialization stage

Types

type Config

type Config struct {
	// DefaultAddrPool specifies default subnet pool for global scope networks
	DefaultAddrPool []string

	// SubnetSize specifies the subnet size of the networks created from
	// the default subnet pool
	SubnetSize uint32

	// VXLANUDPPort specifies the UDP port number for VXLAN traffic
	VXLANUDPPort uint32
}

Config is used to store network related cluster config in the Manager.

type DriverValidator

type DriverValidator interface {
	ValidateNetworkDriver(*api.Driver) error
	ValidateIngressNetworkDriver(*api.Driver) error
	ValidateIPAMDriver(*api.Driver) error
}

DriverValidator validates whether a network driver spec is supported by the network provider.

type Inert

type Inert struct{}

Inert is a NetworkAllocator which does not allocate networks.

func (Inert) Allocate

func (Inert) Allocate(n *api.Network) error

Allocate returns an error unless n.Spec.Ingress is true.

func (Inert) AllocateAttachment

func (Inert) AllocateAttachment(node *api.Node, networkAttachment *api.NetworkAttachment) error

AllocateAttachment unconditionally returns an error.

func (Inert) AllocateService

func (Inert) AllocateService(s *api.Service) error

AllocateService succeeds iff the service specifies no network attachments.

func (Inert) AllocateTask

func (Inert) AllocateTask(t *api.Task) error

AllocateTask succeeds iff the task specifies no network attachments.

func (Inert) Deallocate

func (Inert) Deallocate(n *api.Network) error

Deallocate does nothing, successfully.

func (Inert) DeallocateAttachment

func (Inert) DeallocateAttachment(node *api.Node, networkAttachment *api.NetworkAttachment) error

DeallocateAttachment does nothing, successfully.

func (Inert) DeallocateService

func (Inert) DeallocateService(s *api.Service) error

DeallocateService does nothing, successfully.

func (Inert) DeallocateTask

func (Inert) DeallocateTask(t *api.Task) error

DeallocateTask does nothing, successfully.

func (Inert) IsAllocated

func (Inert) IsAllocated(n *api.Network) bool

IsAllocated returns true iff Inert.Allocate would return nil.

func (Inert) IsAttachmentAllocated

func (Inert) IsAttachmentAllocated(node *api.Node, networkAttachment *api.NetworkAttachment) bool

IsAttachmentAllocated returns false.

func (Inert) IsServiceAllocated

func (Inert) IsServiceAllocated(s *api.Service, flags ...func(*ServiceAllocationOpts)) bool

IsServiceAllocated returns true iff Inert.AllocateService would return nil.

func (Inert) IsTaskAllocated

func (Inert) IsTaskAllocated(t *api.Task) bool

IsTaskAllocated returns true iff Inert.AllocateTask would return nil.

type InertProvider

type InertProvider struct{}

InertProvider is a network allocator Provider which does not allocate networks.

func (InertProvider) NewAllocator

func (InertProvider) NewAllocator(*Config) (NetworkAllocator, error)

NewAllocator returns an instance of Inert.

func (InertProvider) PredefinedNetworks

func (InertProvider) PredefinedNetworks() []PredefinedNetworkData

PredefinedNetworks returns a nil slice.

func (InertProvider) SetDefaultVXLANUDPPort

func (InertProvider) SetDefaultVXLANUDPPort(uint32) error

SetDefaultVXLANUDPPort is a no-op.

func (InertProvider) ValidateIPAMDriver

func (InertProvider) ValidateIPAMDriver(d *api.Driver) error

ValidateIPAMDriver returns an InvalidArgument error unless d is nil.

func (InertProvider) ValidateIngressNetworkDriver

func (InertProvider) ValidateIngressNetworkDriver(d *api.Driver) error

ValidateIngressNetworkDriver returns an InvalidArgument error unless d is nil.

func (InertProvider) ValidateNetworkDriver

func (InertProvider) ValidateNetworkDriver(d *api.Driver) error

ValidateNetworkDriver returns an InvalidArgument error unless d is nil.

type NetworkAllocator

type NetworkAllocator interface {

	// IsAllocated returns if the passed network has been allocated or not.
	IsAllocated(n *api.Network) bool

	// Allocate allocates all the necessary resources both general
	// and driver-specific which may be specified in the NetworkSpec
	Allocate(n *api.Network) error

	// Deallocate frees all the general and driver specific resources
	// which were assigned to the passed network.
	Deallocate(n *api.Network) error

	// IsServiceAllocated returns false if the passed service
	// needs to have network resources allocated/updated.
	IsServiceAllocated(s *api.Service, flags ...func(*ServiceAllocationOpts)) bool

	// AllocateService allocates all the network resources such as virtual
	// IP and ports needed by the service.
	AllocateService(s *api.Service) (err error)

	// DeallocateService de-allocates all the network resources such as
	// virtual IP and ports associated with the service.
	DeallocateService(s *api.Service) error

	// IsTaskAllocated returns if the passed task has its network
	// resources allocated or not.
	IsTaskAllocated(t *api.Task) bool

	// AllocateTask allocates all the endpoint resources for all the
	// networks that a task is attached to.
	AllocateTask(t *api.Task) error

	// DeallocateTask releases all the endpoint resources for all the
	// networks that a task is attached to.
	DeallocateTask(t *api.Task) error

	// AllocateAttachment Allocates a load balancer endpoint for the node
	AllocateAttachment(node *api.Node, networkAttachment *api.NetworkAttachment) error

	// DeallocateAttachment Deallocates a load balancer endpoint for the node
	DeallocateAttachment(node *api.Node, networkAttachment *api.NetworkAttachment) error

	// IsAttachmentAllocated If lb endpoint is allocated on the node
	IsAttachmentAllocated(node *api.Node, networkAttachment *api.NetworkAttachment) bool
}

NetworkAllocator provides network model specific allocation functionality.

type PredefinedNetworkData

type PredefinedNetworkData struct {
	Name   string
	Driver string
}

PredefinedNetworkData contains the minimum set of data needed to create the correspondent predefined network object in the store.

type Provider

type Provider interface {
	DriverValidator
	PredefinedNetworks() []PredefinedNetworkData
	SetDefaultVXLANUDPPort(uint32) error
	NewAllocator(*Config) (NetworkAllocator, error)
}

Provider provides network allocation functionality.

type ServiceAllocationOpts

type ServiceAllocationOpts struct {
	OnInit bool
}

ServiceAllocationOpts is struct used for functional options in IsServiceAllocated

Jump to

Keyboard shortcuts

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