ipampool

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SubnetIPExhausted    = 1
	SubnetIPNotExhausted = 0
)
View Source
const (
	// DefaultRefreshDelay pool monitor poll delay default in seconds.
	DefaultRefreshDelay = 1 * time.Second
	// DefaultMaxIPs default maximum allocatable IPs
	DefaultMaxIPs = 250
)

Variables

View Source
var (
	IpamAllocatedIPCount = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Name:        "cx_ipam_pod_allocated_ips",
			Help:        "IPs currently in use by Pods on this CNS Node.",
			ConstLabels: prometheus.Labels{customerMetricLabel: customerMetricLabelValue},
		},
		[]string{subnetLabel, subnetCIDRLabel, podnetARMIDLabel},
	)
	IpamAvailableIPCount = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Name:        "cx_ipam_available_ips",
			Help:        "IPs available on this CNS Node for use by a Pod.",
			ConstLabels: prometheus.Labels{customerMetricLabel: customerMetricLabelValue},
		},
		[]string{subnetLabel, subnetCIDRLabel, podnetARMIDLabel},
	)
	IpamBatchSize = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Name:        "cx_ipam_batch_size",
			Help:        "IPAM IP pool scaling batch size.",
			ConstLabels: prometheus.Labels{customerMetricLabel: customerMetricLabelValue},
		},
		[]string{subnetLabel, subnetCIDRLabel, podnetARMIDLabel},
	)
	IpamCurrentAvailableIPcount = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Name:        "cx_ipam_current_available_ips",
			Help:        "Current available IP count.",
			ConstLabels: prometheus.Labels{customerMetricLabel: customerMetricLabelValue},
		},
		[]string{subnetLabel, subnetCIDRLabel, podnetARMIDLabel},
	)
	IpamExpectedAvailableIPCount = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Name:        "cx_ipam_expect_available_ips",
			Help:        "Expected future available IP count assuming the Requested IP count is honored.",
			ConstLabels: prometheus.Labels{customerMetricLabel: customerMetricLabelValue},
		},
		[]string{subnetLabel, subnetCIDRLabel, podnetARMIDLabel},
	)
	IpamMaxIPCount = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Name:        "cx_ipam_max_ips",
			Help:        "Maximum Secondary IPs allowed on this Node.",
			ConstLabels: prometheus.Labels{customerMetricLabel: customerMetricLabelValue},
		},
		[]string{subnetLabel, subnetCIDRLabel, podnetARMIDLabel},
	)
	IpamPendingProgramIPCount = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Name:        "cx_ipam_pending_programming_ips",
			Help:        "IPs reserved but not yet available (Pending Programming).",
			ConstLabels: prometheus.Labels{customerMetricLabel: customerMetricLabelValue},
		},
		[]string{subnetLabel, subnetCIDRLabel, podnetARMIDLabel},
	)
	IpamPendingReleaseIPCount = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Name:        "cx_ipam_pending_release_ips",
			Help:        "IPs reserved but not available anymore (Pending Release).",
			ConstLabels: prometheus.Labels{customerMetricLabel: customerMetricLabelValue},
		},
		[]string{subnetLabel, subnetCIDRLabel, podnetARMIDLabel},
	)
	IpamPrimaryIPCount = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Name:        "cx_ipam_primary_ips",
			Help:        "NC Primary IP count (reserved from Pod Subnet for DNS and IMDS SNAT).",
			ConstLabels: prometheus.Labels{customerMetricLabel: customerMetricLabelValue},
		},
		[]string{subnetLabel, subnetCIDRLabel, podnetARMIDLabel},
	)
	IpamRequestedIPConfigCount = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Name:        "cx_ipam_requested_ips",
			Help:        "Secondary Pod Subnet IPs requested by this CNS Node (for Pods).",
			ConstLabels: prometheus.Labels{customerMetricLabel: customerMetricLabelValue},
		},
		[]string{subnetLabel, subnetCIDRLabel, podnetARMIDLabel},
	)
	IpamSecondaryIPCount = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Name:        "cx_ipam_secondary_ips",
			Help:        "Node NC Secondary IP count (reserved usable by Pods).",
			ConstLabels: prometheus.Labels{customerMetricLabel: customerMetricLabelValue},
		},
		[]string{subnetLabel, subnetCIDRLabel, podnetARMIDLabel},
	)
	IpamTotalIPCount = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Name:        "cx_ipam_total_ips",
			Help:        "Count of total IP pool size allocated to CNS by DNC.",
			ConstLabels: prometheus.Labels{customerMetricLabel: customerMetricLabelValue},
		},
		[]string{subnetLabel, subnetCIDRLabel, podnetARMIDLabel},
	)
	IpamSubnetExhaustionState = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Name:        "cx_ipam_subnet_exhaustion_state",
			Help:        "IPAM view of subnet exhaustion state",
			ConstLabels: prometheus.Labels{customerMetricLabel: customerMetricLabelValue},
		},
		[]string{subnetLabel, subnetCIDRLabel, podnetARMIDLabel},
	)
	IpamSubnetExhaustionCount = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Name: "cx_ipam_subnet_exhaustion_state_count_total",
			Help: "Count of the number of times the ipam pool monitor sees subnet exhaustion",
		},
		[]string{subnetLabel, subnetCIDRLabel, podnetARMIDLabel, subnetExhaustionStateLabel},
	)
)

Functions

func CalculateMaxFreeIPs

func CalculateMaxFreeIPs(scaler v1alpha.Scaler) int64

CalculateMaxFreeIPs calculates the maximum free IP quantity based on the Scaler in the passed NodeNetworkConfig. Half of odd batches are rounded up!

func CalculateMinFreeIPs

func CalculateMinFreeIPs(scaler v1alpha.Scaler) int64

CalculateMinFreeIPs calculates the minimum free IP quantity based on the Scaler in the passed NodeNetworkConfig. Half of odd batches are rounded up!

func GenerateARMID

func GenerateARMID(nc *v1alpha.NetworkContainer) string

GenerateARMID uses the Subnet ARM ID format to populate the ARM ID with the metadata. If either of the metadata attributes are empty, then the ARM ID will be an empty string.

Types

type Monitor

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

func NewMonitor

func NewMonitor(httpService cns.HTTPService, nnccli nodeNetworkConfigSpecUpdater, cssSource <-chan v1alpha1.ClusterSubnetState, opts *Options) *Monitor

func (*Monitor) GetStateSnapshot

func (pm *Monitor) GetStateSnapshot() cns.IpamPoolMonitorStateSnapshot

GetStateSnapshot gets a snapshot of the IPAMPoolMonitor struct.

func (*Monitor) Start

func (pm *Monitor) Start(ctx context.Context) error

Start begins the Monitor's pool reconcile loop. On first run, it will block until a NodeNetworkConfig is received (through a call to Update()). Subsequently, it will run run once per RefreshDelay and attempt to re-reconcile the pool.

func (*Monitor) Update

func (pm *Monitor) Update(nnc *v1alpha.NodeNetworkConfig) error

Update ingests a NodeNetworkConfig, clamping some values to ensure they are legal and then pushing it to the Monitor's source channel. If the Monitor has been Started but is blocking until it receives an NNC, this will start the pool reconcile loop. If the Monitor has not been Started, this will block until Start() is called, which will immediately read this passed NNC and start the pool reconcile loop.

type Options

type Options struct {
	RefreshDelay time.Duration
	MaxIPs       int64
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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