ipam

package
v6.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2022 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsInvalidConfig

func IsInvalidConfig(err error) bool

IsInvalidConfig asserts invalidConfigError.

func IsInvalidObject

func IsInvalidObject(err error) bool

IsInvalidObject asserts invalidObjectError.

func IsNotFound

func IsNotFound(err error) bool

func IsParentNetworkRangeStillNotKnown

func IsParentNetworkRangeStillNotKnown(err error) bool

IsParentNetworkRangeStillNotKnown asserts parentNetworkRangeStillNotKnown. This can happen in node pools IPAM reconciliation, during subnet allocation, when AzureCluster.Spec.NetworkSpec.Vnet.CidrBlock is still not set, because VNet for the tenant cluster is still not allocated (e.g. when cluster is still being created).

Types

type AzureConfigChecker

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

func NewAzureConfigChecker

func NewAzureConfigChecker(config AzureConfigCheckerConfig) (*AzureConfigChecker, error)

func (*AzureConfigChecker) Check

func (c *AzureConfigChecker) Check(ctx context.Context, namespace string, name string) (*net.IPNet, error)

type AzureConfigCheckerConfig

type AzureConfigCheckerConfig struct {
	CtrlClient client.Client
	Logger     micrologger.Logger
}

type AzureConfigNetworkRangeGetter

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

AzureConfigNetworkRangeGetter is NetworkRangeGetter implementation for AzureConfig.

func (*AzureConfigNetworkRangeGetter) GetParentNetworkRange

func (g *AzureConfigNetworkRangeGetter) GetParentNetworkRange(_ context.Context, _ interface{}) (net.IPNet, error)

GetParentNetworkRange gets the predefined installation network range, since the tenant cluster virtual network is getting its IP range from all available address ranges in the installation.

func (*AzureConfigNetworkRangeGetter) GetRequiredIPMask

func (g *AzureConfigNetworkRangeGetter) GetRequiredIPMask() net.IPMask

GetRequiredIPMask returns an IP mask for tenant cluster virtual network.

type AzureConfigNetworkRangeGetterConfig

type AzureConfigNetworkRangeGetterConfig struct {
	InstallationNetworkRange            net.IPNet
	TenantClusterVirtualNetworkMaskBits int
}

type AzureConfigPersister

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

func NewAzureConfigPersister

func NewAzureConfigPersister(config AzureConfigPersisterConfig) (*AzureConfigPersister, error)

func (*AzureConfigPersister) Persist

func (p *AzureConfigPersister) Persist(ctx context.Context, vnet net.IPNet, namespace string, name string) error

type AzureConfigPersisterConfig

type AzureConfigPersisterConfig struct {
	CtrlClient client.Client
	Logger     micrologger.Logger
}

type AzureMachinePoolNetworkRangeGetter

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

AzureMachinePoolNetworkRangeGetter is a NetworkRangeGetter implementation for node pools.

func (*AzureMachinePoolNetworkRangeGetter) GetParentNetworkRange

func (g *AzureMachinePoolNetworkRangeGetter) GetParentNetworkRange(ctx context.Context, obj interface{}) (net.IPNet, error)

GetParentNetworkRange returns the tenant cluster virtual network range, because the node pool subnet is getting its IP address range from all available address ranges in the tenant cluster virtual network.

func (*AzureMachinePoolNetworkRangeGetter) GetRequiredIPMask

func (g *AzureMachinePoolNetworkRangeGetter) GetRequiredIPMask() net.IPMask

GetRequiredMask returns a /24 IP mask that is required for the node pools subnet.

type AzureMachinePoolNetworkRangeGetterConfig

type AzureMachinePoolNetworkRangeGetterConfig struct {
	CtrlClient client.Client
	Logger     micrologger.Logger
}

type AzureMachinePoolSubnetChecker

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

AzureMachinePoolSubnetChecker is a Checker implementation that checks if a subnet is allocated for the node pool specified in Check function.

func (*AzureMachinePoolSubnetChecker) Check

func (c *AzureMachinePoolSubnetChecker) Check(ctx context.Context, namespace string, name string) (*net.IPNet, error)

Check function checks if a subnet is allocated for the specified AzureMachinePool. It is checking if the allocated subnet is set in the corresponding Cluster CR that owns specified AzureMachinePool. Returns allocated subnet or nil.

type AzureMachinePoolSubnetCheckerConfig

type AzureMachinePoolSubnetCheckerConfig struct {
	CtrlClient client.Client
	Logger     micrologger.Logger
}

type AzureMachinePoolSubnetCollector

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

AzureMachinePoolSubnetCollector is a Collector implementation that collects all subnets that are already allocated in tenant cluster virtual network. See Collect function implementation and docs for more details.

func (*AzureMachinePoolSubnetCollector) Collect

func (c *AzureMachinePoolSubnetCollector) Collect(ctx context.Context, obj interface{}) ([]net.IPNet, error)

Collect function returns all subnets that are already allocated in tenant cluster virtual network. These include subnets set in AzureCluster CR and all subnets that are created in tenant cluster's Azure virtual network.

Why getting both of these?

  • Subnets from AzureCluster CR: these are desired subnets for the tenant cluster, they might be already deployed in Azure or not.
  • Subnets in Azure virtual network: In addition to subnets from AzureCluster CR that should be eventually deployed here, there might be some other subnets that are created outside of tenant cluster. For existing pre-node-pool clusters, legacy subnets, if they still exist, will be collected here.

type AzureMachinePoolSubnetCollectorConfig

type AzureMachinePoolSubnetCollectorConfig struct {
	AzureClientFactory client.OrganizationFactory
	CtrlClient         ctrl.Client
	Logger             micrologger.Logger
}

type AzureMachinePoolSubnetPersister

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

AzureMachinePoolSubnetPersister is a Persister implementation that saves a subnet allocated for a node pool by adding it to AzureCluster CR.

func (*AzureMachinePoolSubnetPersister) Persist

func (p *AzureMachinePoolSubnetPersister) Persist(ctx context.Context, subnet net.IPNet, namespace string, name string) error

Persist functions takes a subnet CIDR allocated for the specified AzureMachinePool (namespace/ name) and adds it to Subnets array in the corresponding AzureCluster CR that owns the specified AzureMachinePool.

type AzureMachinePoolSubnetPersisterConfig

type AzureMachinePoolSubnetPersisterConfig struct {
	CtrlClient client.Client
	Logger     micrologger.Logger
}

type AzureMachinePoolSubnetReleaser

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

AzureMachinePoolSubnetReleaser is a Releaser implementation that releases an allocated subnet for a node pool by removing it from AzureCluster CR.

func (*AzureMachinePoolSubnetReleaser) Release

func (r *AzureMachinePoolSubnetReleaser) Release(ctx context.Context, subnet net.IPNet, namespace, name string) error

type AzureMachinePoolSubnetReleaserConfig

type AzureMachinePoolSubnetReleaserConfig struct {
	CtrlClient client.Client
	Logger     micrologger.Logger
}

type Checker

type Checker interface {
	Check(ctx context.Context, namespace, name string) (*net.IPNet, error)
}

Checker determines whether a subnet has been allocated. This decision is being made based on the status of the Kubernetes runtime object defined by namespace and name. If subnet has been allocated, it's returned. Otherwise return value is nil.

type Collector

type Collector interface {
	Collect(ctx context.Context, obj interface{}) ([]net.IPNet, error)
}

Collector implementation must return all networks that are allocated on any given moment. Failing to do that will result in overlapping allocations.

type Config

type Config struct {
	Checker            Checker
	Collector          Collector
	Locker             locker.Interface
	Logger             micrologger.Logger
	NetworkRangeGetter NetworkRangeGetter
	NetworkRangeType   NetworkRangeType
	Persister          Persister
	Releaser           Releaser
}

type NetworkRangeGetter

type NetworkRangeGetter interface {
	// GetParentNetworkRange return the network range from which the VNet/subnet range
	// will be allocated. It receives the CR that is being reconciled.
	GetParentNetworkRange(ctx context.Context, obj interface{}) (net.IPNet, error)

	// GetRequiredIPMask returns an IP mask that is required by the network range
	// that will be allocated.
	GetRequiredIPMask() net.IPMask
}

NetworkRangeGetter implementation returns a network range from which a free IP range can be allocated.

type NetworkRangeType

type NetworkRangeType string
const (
	Name                                 = "ipam"
	SubnetRange         NetworkRangeType = "subnet"
	VirtualNetworkRange NetworkRangeType = "virtual network"
)

type Persister

type Persister interface {
	Persist(ctx context.Context, subnet net.IPNet, namespace, name string) error
}

Persister must mutate shared persistent state so that on successful execution persisted networks are visible by Collector implementations.

type Releaser

type Releaser interface {
	Release(ctx context.Context, subnet net.IPNet, namespace, name string) error
}

Releaser must mutate shared persistent state so that on successful execution allocated subnet is released.

func NewNOPReleaser

func NewNOPReleaser() Releaser

type Resource

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

Resource finds free IP ranges: - AzureConfig: within an installation range to create new virtual network for the tenant cluster. - CAPI/CAPZ: within a virtual network to create new subnets.

func New

func New(config Config) (*Resource, error)

func (*Resource) EnsureCreated

func (r *Resource) EnsureCreated(ctx context.Context, obj interface{}) error

EnsureCreated allocates tenant cluster network segments. It gathers existing subnets from existing system resources like Vnets and Cluster CRs.

func (*Resource) EnsureDeleted

func (r *Resource) EnsureDeleted(ctx context.Context, obj interface{}) error

func (*Resource) Name

func (r *Resource) Name() string

type TestChecker

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

func NewTestChecker

func NewTestChecker(subnet *net.IPNet) *TestChecker

func (*TestChecker) Check

func (c *TestChecker) Check(ctx context.Context, namespace string, name string) (*net.IPNet, error)

type TestCollector

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

func NewTestCollector

func NewTestCollector(subnets []net.IPNet) *TestCollector

func (*TestCollector) Collect

func (c *TestCollector) Collect(ctx context.Context, obj interface{}) ([]net.IPNet, error)

type TestNetworkRangeGetter

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

func NewTestNetworkRangeGetter

func NewTestNetworkRangeGetter(parentNetworkRange net.IPNet, requiredNetworkMaskBits int) *TestNetworkRangeGetter

func (*TestNetworkRangeGetter) GetParentNetworkRange

func (g *TestNetworkRangeGetter) GetParentNetworkRange(_ context.Context, _ interface{}) (net.IPNet, error)

func (*TestNetworkRangeGetter) GetRequiredIPMask

func (g *TestNetworkRangeGetter) GetRequiredIPMask() net.IPMask

type TestPersister

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

func NewTestPersister

func NewTestPersister(subnet net.IPNet) *TestPersister

func (*TestPersister) Persist

func (p *TestPersister) Persist(ctx context.Context, subnet net.IPNet, namespace string, name string) error

type VirtualNetworkCollector

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

func (*VirtualNetworkCollector) Collect

func (c *VirtualNetworkCollector) Collect(ctx context.Context, _ interface{}) ([]net.IPNet, error)

type VirtualNetworkCollectorConfig

type VirtualNetworkCollectorConfig struct {
	AzureMetricsCollector collector.AzureAPIMetrics
	CredentialProvider    credential.Provider
	InstallationName      string
	K8sClient             k8sclient.Interface
	Logger                micrologger.Logger

	NetworkRange  net.IPNet
	ReservedCIDRs []net.IPNet
}

Jump to

Keyboard shortcuts

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