ipam

package
v5.0.0-beta5 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2020 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) (bool, 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) (bool, 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.

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 Cluster 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 Cluster CR that owns the specified AzureMachinePool.

type AzureMachinePoolSubnetPersisterConfig

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

type Checker

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

Checker determines whether a subnet has to be allocated. This decision is being made based on the status of the Kubernetes runtime object defined by namespace and name.

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
}

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 string, name string) error
}

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

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(proceed bool) *TestChecker

func (*TestChecker) Check

func (c *TestChecker) Check(ctx context.Context, namespace string, name string) (bool, 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
}

Jump to

Keyboard shortcuts

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