ipam

package
v1.28.1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: Apache-2.0 Imports: 46 Imported by: 70

Documentation

Overview

Package ipam provides different allocators for assigning IP ranges to nodes. We currently support several kinds of IPAM allocators (these are denoted by the CIDRAllocatorType):

  • RangeAllocator is an allocator that assigns PodCIDRs to nodes and works in conjunction with the RouteController to configure the network to get connectivity.
  • CloudAllocator is an allocator that synchronizes PodCIDRs from IP ranges assignments from the underlying cloud platform.
  • (Alpha only) IPAMFromCluster is an allocator that has the similar functionality as the RangeAllocator but also synchronizes cluster-managed ranges into the cloud platform.
  • (Alpha only) IPAMFromCloud is the same as CloudAllocator (synchronizes from cloud into the cluster.)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CIDRAllocator

type CIDRAllocator interface {
	// AllocateOrOccupyCIDR looks at the given node, assigns it a valid
	// CIDR if it doesn't currently have one or mark the CIDR as used if
	// the node already have one.
	AllocateOrOccupyCIDR(logger klog.Logger, node *v1.Node) error
	// ReleaseCIDR releases the CIDR of the removed node.
	ReleaseCIDR(logger klog.Logger, node *v1.Node) error
	// Run starts all the working logic of the allocator.
	Run(ctx context.Context)
}

CIDRAllocator is an interface implemented by things that know how to allocate/occupy/recycle CIDR for nodes.

func New

func New(ctx context.Context, kubeClient clientset.Interface, cloud cloudprovider.Interface, nodeInformer informers.NodeInformer, clusterCIDRInformer networkinginformers.ClusterCIDRInformer, allocatorType CIDRAllocatorType, allocatorParams CIDRAllocatorParams) (CIDRAllocator, error)

New creates a new CIDR range allocator.

func NewCIDRRangeAllocator

func NewCIDRRangeAllocator(logger klog.Logger, client clientset.Interface, nodeInformer informers.NodeInformer, allocatorParams CIDRAllocatorParams, nodeList *v1.NodeList) (CIDRAllocator, error)

NewCIDRRangeAllocator returns a CIDRAllocator to allocate CIDRs for node (one from each of clusterCIDRs) Caller must ensure subNetMaskSize is not less than cluster CIDR mask size. Caller must always pass in a list of existing nodes so the new allocator. Caller must ensure that ClusterCIDRs are semantically correct e.g (1 for non DualStack, 2 for DualStack etc..) can initialize its CIDR map. NodeList is only nil in testing.

func NewCloudCIDRAllocator

func NewCloudCIDRAllocator(logger klog.Logger, client clientset.Interface, cloud cloudprovider.Interface, nodeInformer informers.NodeInformer) (CIDRAllocator, error)

NewCloudCIDRAllocator creates a new cloud CIDR allocator.

func NewMultiCIDRRangeAllocator added in v1.25.0

func NewMultiCIDRRangeAllocator(
	ctx context.Context,
	client clientset.Interface,
	nodeInformer informers.NodeInformer,
	clusterCIDRInformer networkinginformers.ClusterCIDRInformer,
	allocatorParams CIDRAllocatorParams,
	nodeList *v1.NodeList,
	testCIDRMap map[string][]*cidrset.ClusterCIDR,
) (CIDRAllocator, error)

NewMultiCIDRRangeAllocator returns a CIDRAllocator to allocate CIDRs for node (one for each ip family). Caller must always pass in a list of existing nodes to the new allocator. NodeList is only nil in testing.

type CIDRAllocatorParams added in v1.17.0

type CIDRAllocatorParams struct {
	// ClusterCIDRs is list of cluster cidrs.
	ClusterCIDRs []*net.IPNet
	// ServiceCIDR is primary service cidr for cluster.
	ServiceCIDR *net.IPNet
	// SecondaryServiceCIDR is secondary service cidr for cluster.
	SecondaryServiceCIDR *net.IPNet
	// NodeCIDRMaskSizes is list of node cidr mask sizes.
	NodeCIDRMaskSizes []int
}

CIDRAllocatorParams is parameters that's required for creating new cidr range allocator.

type CIDRAllocatorType

type CIDRAllocatorType string

CIDRAllocatorType is the type of the allocator to use.

const (
	// RangeAllocatorType is the allocator that uses an internal CIDR
	// range allocator to do node CIDR range allocations.
	RangeAllocatorType CIDRAllocatorType = "RangeAllocator"
	// MultiCIDRRangeAllocatorType is the allocator that uses an internal CIDR
	// range allocator to do node CIDR range allocations.
	MultiCIDRRangeAllocatorType CIDRAllocatorType = "MultiCIDRRangeAllocator"
	// CloudAllocatorType is the allocator that uses cloud platform
	// support to do node CIDR range allocations.
	CloudAllocatorType CIDRAllocatorType = "CloudAllocator"
	// IPAMFromClusterAllocatorType uses the ipam controller sync'ing the node
	// CIDR range allocations from the cluster to the cloud.
	IPAMFromClusterAllocatorType = "IPAMFromCluster"
	// IPAMFromCloudAllocatorType uses the ipam controller sync'ing the node
	// CIDR range allocations from the cloud to the cluster.
	IPAMFromCloudAllocatorType = "IPAMFromCloud"
)

type Config

type Config struct {
	// Resync is the default timeout duration when there are no errors.
	Resync time.Duration
	// MaxBackoff is the maximum timeout when in a error backoff state.
	MaxBackoff time.Duration
	// InitialRetry is the initial retry interval when an error is reported.
	InitialRetry time.Duration
	// Mode to use to synchronize.
	Mode nodesync.NodeSyncMode
}

Config for the IPAM controller.

type Controller

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

Controller is the controller for synchronizing cluster and cloud node pod CIDR range assignments.

func NewController

func NewController(
	config *Config,
	kubeClient clientset.Interface,
	cloud cloudprovider.Interface,
	clusterCIDR, serviceCIDR *net.IPNet,
	nodeCIDRMaskSize int) (*Controller, error)

NewController returns a new instance of the IPAM controller.

func (*Controller) Run added in v1.26.0

func (c *Controller) Run(ctx context.Context)

func (*Controller) Start

func (c *Controller) Start(logger klog.Logger, nodeInformer informers.NodeInformer) error

Start initializes the Controller with the existing list of nodes and registers the informers for node changes. This will start synchronization of the node and cloud CIDR range allocations.

type PriorityQueue added in v1.25.0

type PriorityQueue []*PriorityQueueItem

A PriorityQueue implements heap.Interface and holds PriorityQueueItems.

func (PriorityQueue) Len added in v1.25.0

func (pq PriorityQueue) Len() int

func (PriorityQueue) Less added in v1.25.0

func (pq PriorityQueue) Less(i, j int) bool

Less compares the priority queue items, to store in a min heap. Less(i,j) == true denotes i has higher priority than j.

func (*PriorityQueue) Pop added in v1.25.0

func (pq *PriorityQueue) Pop() interface{}

func (*PriorityQueue) Push added in v1.25.0

func (pq *PriorityQueue) Push(x interface{})

func (PriorityQueue) Swap added in v1.25.0

func (pq PriorityQueue) Swap(i, j int)

type PriorityQueueItem added in v1.25.0

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

An PriorityQueueItem is something we manage in a priority queue.

type Timeout

type Timeout struct {
	// Resync is the default timeout duration when there are no errors.
	Resync time.Duration
	// MaxBackoff is the maximum timeout when in a error backoff state.
	MaxBackoff time.Duration
	// InitialRetry is the initial retry interval when an error is reported.
	InitialRetry time.Duration
	// contains filtered or unexported fields
}

Timeout manages the resync loop timing for a given node sync operation. The timeout changes depending on whether or not there was an error reported for the operation. Consecutive errors will result in exponential backoff to a maxBackoff timeout.

func (*Timeout) Next

func (b *Timeout) Next() time.Duration

Next returns the next operation timeout given the disposition of err.

func (*Timeout) Update

func (b *Timeout) Update(ok bool)

Update the timeout with the current error state.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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