ipam

package
v0.36.0-test-ci Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

README

IP address management example

Creat Network Attachment Definition

kubectl apply -f demo/ipam-nad.yaml

Run example

go run demo/ipam.go

Delete Network Attachment Definition

kubectl delete -f ipam-nad.yaml

Documentation

Index

Constants

View Source
const (
	// IP Acquire operation identifier
	Acquire = 0
	// IP Release operation identifier
	Release = 1

	UnnamedNetwork string = ""

	// kubernetes client-go rate limiter settings
	// https://pkg.go.dev/k8s.io/client-go@v0.27.2/rest#Config
	KubernetesClientQPS   = 100
	KubernetesClientBurst = 200

	// RequestTimeout for IPAM queries
	IpamRequestTimeout = 10 * time.Second

	// DatastoreRetries defines how many retries are attempted when reading/updating the IP Pool
	DatastoreRetries             = 5
	DatastoreRetriesDelay        = 100 * time.Millisecond
	DefaultLeaderLeaseDurationMs = 3000
	DefaultLeaderRenewDeadlineMs = 2500
	DefaultLeaderRetryPeriodMs   = 2000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Set of kubernetets clients

func NewKubeClient

func NewKubeClient(cfg *rest.Config) (*Client, error)

type IPAM

type IPAM struct {
	Client
	Config IPAMConfig
}

func New

func New(ctx context.Context, nadName string, nadNamespace string) (*IPAM, error)

New returns a new IPAM object with ipam config and k8s/crd clients

func (*IPAM) AcquireIP

func (i *IPAM) AcquireIP(ctx context.Context, vmName string, vmNamespace string) (net.IPNet, error)

func (*IPAM) Close

func (i *IPAM) Close() error

TODO: think about

func (*IPAM) ReleaseIP

func (i *IPAM) ReleaseIP(ctx context.Context, vmName string, vmNamespace string) (net.IPNet, error)

func (*IPAM) Status

func (i *IPAM) Status(ctx context.Context) error

Status do List() request to check NeonVM client connectivity

type IPAMConfig

type IPAMConfig struct {
	Routes           []*cnitypes.Route    `json:"routes"`
	IPRanges         []RangeConfiguration `json:"ipRanges"`
	OmitRanges       []string             `json:"exclude,omitempty"`
	DNS              cnitypes.DNS         `json:"dns"`
	Range            string               `json:"range"`
	RangeStart       net.IP               `json:"range_start,omitempty"`
	RangeEnd         net.IP               `json:"range_end,omitempty"`
	NetworkNamespace string
	NetworkName      string `json:"network_name,omitempty"`
}

IPAMConfig describes the expected json configuration for this plugin

func LoadFromNad

func LoadFromNad(nadConfig string, nadNamespace string) (*IPAMConfig, error)

Load Network Attachment Definition and parse config to fill IPAM config

type Nad

type Nad struct {
	IPAM *IPAMConfig `json:"ipam"`
}

type NeonvmIPPool

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

NeonvmIPPool represents an IPPool resource and its parsed set of allocations

func (*NeonvmIPPool) Allocations

Allocations returns the initially retrieved set of allocations for this pool

func (*NeonvmIPPool) Update

func (p *NeonvmIPPool) Update(ctx context.Context, reservation []whereaboutstypes.IPReservation) error

Update NeonvmIPPool with new IP reservation

type RangeConfiguration

type RangeConfiguration struct {
	OmitRanges []string `json:"exclude,omitempty"`
	Range      string   `json:"range"`
	RangeStart net.IP   `json:"range_start,omitempty"`
	RangeEnd   net.IP   `json:"range_end,omitempty"`
}

type Temporary

type Temporary interface {
	Temporary() bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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