Documentation
¶
Overview ¶
Package netalloc allocates non-overlapping subnets from one platform pool, ledgered in the DB to survive restarts.
Index ¶
- Variables
- func DeriveIPv6(ulaPrefix, ipv4Subnet string) (string, error)
- type NetworkProvisioner
- type Service
- func (s *Service) Allocate(dockerName string, nodeID uint, kind string) (*models.NetworkAllocation, error)
- func (s *Service) Capacity() int
- func (s *Service) EnsureManaged(ctx context.Context, dc NetworkProvisioner, spec docker.NetworkSpec, ...) (id, subnet string, err error)
- func (s *Service) ImportExisting(ctx context.Context, dc NetworkProvisioner, nodeID uint) error
- func (s *Service) PublishStats()
- func (s *Service) Release(dockerName string) error
- func (s *Service) SetIPv6(enabled bool, ulaPrefix string)
- func (s *Service) Stats() (used int, total int)
Constants ¶
This section is empty.
Variables ¶
var ErrPoolExhausted = errors.New("network subnet pool exhausted")
ErrPoolExhausted means every pool subnet is taken; the operator must enlarge MIABI_NETWORK_POOL_CIDR.
Functions ¶
func DeriveIPv6 ¶ added in v1.10.2
DeriveIPv6 derives a stable /64 from the IPv4 subnet (works on Engine 25); an empty prefix returns "" (daemon chooses).
Types ¶
type NetworkProvisioner ¶
type NetworkProvisioner interface {
EnsureNetworkSpec(ctx context.Context, spec docker.NetworkSpec) (string, error)
ListNetworks(ctx context.Context) ([]docker.Network, error)
}
Kept small so narrower service-level interfaces (e.g. the stack NetworkManager) satisfy it too.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service allocates subnets from the configured pool.
func NewService ¶
func NewService(repo *repositories.NetworkAllocationRepository, poolCIDR string, subnetPrefix int) (*Service, error)
config.validate catches bad pools first at boot, so the error here is defence in depth.
func (*Service) Allocate ¶
func (s *Service) Allocate(dockerName string, nodeID uint, kind string) (*models.NetworkAllocation, error)
Allocate is idempotent per name; callers creating the Docker network should prefer EnsureManaged, which handles host overlaps.
func (*Service) EnsureManaged ¶
func (s *Service) EnsureManaged(ctx context.Context, dc NetworkProvisioner, spec docker.NetworkSpec, nodeID uint, kind string) (id, subnet string, err error)
func (*Service) ImportExisting ¶
ImportExisting reserves pool subnets already used by Docker networks on the node so none is handed out twice.
func (*Service) PublishStats ¶
func (s *Service) PublishStats()
PublishStats is called after every mutation so /metrics stays current without a background loop.