v1alpha1

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Initial release of the MikroLB API, providing IPPool and IPAllocation resources. +kubebuilder:object:generate=true +groupName=mikrolb.de

Index

Constants

View Source
const (
	ConditionTypeReady      = "Ready"
	ConditionTypeAllocated  = "Allocated"
	ConditionTypeProgrammed = "Programmed"
)

Variables

View Source
var (
	GroupVersion  = schema.GroupVersion{Group: "mikrolb.de", Version: "v1alpha1"}
	SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
	AddToScheme   = SchemeBuilder.AddToScheme
)

Functions

This section is empty.

Types

type IPAllocation

type IPAllocation struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	// Desired state of the IP allocation.
	Spec IPAllocationSpec `json:"spec,omitempty"`

	// Observed state of the IP allocation.
	Status IPAllocationStatus `json:"status,omitempty"`
}

IPAllocation tracks the allocation of a single IP address for a service. The service reference is stored in the labels `mikrolb.de/service-namespace` and `mikrolb.de/service-name`. +kubebuilder:object:root=true +kubebuilder:subresource:status +kubebuilder:resource:scope=Cluster,shortName=ipa +kubebuilder:printcolumn:name="Namespace",type=string,JSONPath=`.metadata.labels.mikrolb\.de/service-namespace` +kubebuilder:printcolumn:name="Service",type=string,JSONPath=`.metadata.labels.mikrolb\.de/service-name` +kubebuilder:printcolumn:name="Family",type=string,JSONPath=`.spec.ipFamily`,priority=1 +kubebuilder:printcolumn:name="Pool",type=string,JSONPath=`.spec.poolName`,priority=1 +kubebuilder:printcolumn:name="Configured Address",type=string,JSONPath=`.spec.address`,priority=1 +kubebuilder:printcolumn:name="Address",type=string,JSONPath=`.status.address` +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.phase` +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].status` +kubebuilder:printcolumn:name="Reason",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].reason` +kubebuilder:printcolumn:name="Message",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].message` +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`

func (*IPAllocation) DeepCopy

func (in *IPAllocation) DeepCopy() *IPAllocation

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAllocation.

func (*IPAllocation) DeepCopyInto

func (in *IPAllocation) DeepCopyInto(out *IPAllocation)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*IPAllocation) DeepCopyObject

func (in *IPAllocation) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

type IPAllocationList

type IPAllocationList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []IPAllocation `json:"items"`
}

+kubebuilder:object:root=true

func (*IPAllocationList) DeepCopy

func (in *IPAllocationList) DeepCopy() *IPAllocationList

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAllocationList.

func (*IPAllocationList) DeepCopyInto

func (in *IPAllocationList) DeepCopyInto(out *IPAllocationList)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*IPAllocationList) DeepCopyObject

func (in *IPAllocationList) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

type IPAllocationPhase

type IPAllocationPhase string

IPAllocationPhase defines the current phase of the IPAllocation.

const (
	// The IP allocation was not yet processed by the controller. This is the initial
	// phase after creation.
	IPAllocationPhasePending IPAllocationPhase = "Pending"
	// An IP address has been successfully allocated for the service. If the address
	// is not configured for advertisement, this is the final phase. Otherwise, the
	// controller will attempt to program the address on the router and transition to
	// "Programmed".
	IPAllocationPhaseAllocated IPAllocationPhase = "Allocated"
	// The allocated IP address has been successfully programmed for advertisement on
	// the router. This is the final phase for advertised addresses.
	IPAllocationPhaseProgrammed IPAllocationPhase = "Programmed"
	// The controller failed to allocate an IP address for the service or to program
	// the allocated address on the router. This is a terminal phase.
	IPAllocationPhaseFailed IPAllocationPhase = "Failed"
)

type IPAllocationSpec

type IPAllocationSpec struct {
	// Desired IP family of the address to allocate. Must be either "IPv4" or "IPv6".
	// +kubebuilder:validation:Enum=IPv4;IPv6
	// +optional
	IPFamily corev1.IPFamily `json:"ipFamily,omitempty"`

	// Name of the desired IP pool to allocate an address from.
	// +kubebuilder:validation:MaxLength=253
	// +kubebuilder:validation:Pattern=`^[a-z0-9]([a-z0-9\-\.]*[a-z0-9])?$`
	// +optional
	PoolName string `json:"poolName,omitempty"`

	// Specific IP address to allocate. Must be a valid IPv4 or IPv6 address.
	// +optional
	Address string `json:"address,omitempty"`
}

IPAllocationSpec defines the desired ip family, pool or address to allocate for a service. Exactly one and no more of the fields must be specified. +kubebuilder:object:generate=true +kubebuilder:validation:XValidation:rule="(has(self.ipFamily) && self.ipFamily != \"\") || (has(self.poolName) && self.poolName != \"\") || (has(self.address) && self.address != \"\")",message="Either ipFamily, poolName or address must be specified" +kubebuilder:validation:XValidation:rule="[(has(self.ipFamily) && self.ipFamily != \"\"), (has(self.poolName) && self.poolName != \"\"), (has(self.address) && self.address != \"\")].filter(x, x).size() <= 1",message="Only one of ipFamily, poolName or address can be specified"

func (*IPAllocationSpec) DeepCopy

func (in *IPAllocationSpec) DeepCopy() *IPAllocationSpec

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAllocationSpec.

func (*IPAllocationSpec) DeepCopyInto

func (in *IPAllocationSpec) DeepCopyInto(out *IPAllocationSpec)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type IPAllocationStatus

type IPAllocationStatus struct {
	// Phase is the current status phase of the allocation.
	// +optional
	// +kubebuilder:default=Pending
	Phase IPAllocationPhase `json:"phase,omitempty"`

	// Address is the allocated IP address. This is only set if Phase is "Allocated"
	// or "Programmed".
	// +optional
	Address string `json:"address,omitempty"`

	// Whether the allocated address is configured for advertisement via ARP/NDP on
	// the router. This is only set if Phase is "Allocated" or "Programmed".
	// +optional
	Advertised bool `json:"advertised,omitempty"`

	// InterfaceName is the name of the network interface the allocated address is
	// advertised on. This is only definitly set in phase "Programmed" and might be
	// set in phase "Allocated".
	// +optional
	InterfaceName string `json:"interfaceName,omitempty"`

	// Conditions hold the latest available observations of the IPAllocation's state.
	// +optional
	// +patchMergeKey=type
	// +patchStrategy=merge
	// +listType=map
	// +listMapKey=type
	Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`

	// ObservedGeneration is the most recent generation observed by the controller for
	// this IPAllocation. It is used to detect if the spec has been updated since the
	// last reconciliation.
	// +optional
	ObservedGeneration int64 `json:"observedGeneration,omitempty"`
}

IPAllocationStatus defines the observed state of IPAllocation +kubebuilder:object:generate=true

func (*IPAllocationStatus) DeepCopy

func (in *IPAllocationStatus) DeepCopy() *IPAllocationStatus

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAllocationStatus.

func (*IPAllocationStatus) DeepCopyInto

func (in *IPAllocationStatus) DeepCopyInto(out *IPAllocationStatus)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type IPPool

type IPPool struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	// Desired state of the IP pool.
	Spec IPPoolSpec `json:"spec,omitempty"`

	// Observed state of the IP pool.
	Status IPPoolStatus `json:"status,omitempty"`
}

IPPool represents a pool of IP addresses that can be allocated to services. It defines the IP family, the list of addresses or CIDRs in the pool, and other configuration options. The status tracks the total number of addresses in the pool and how many are currently allocated. +kubebuilder:object:root=true +kubebuilder:subresource:status +kubebuilder:resource:scope=Cluster,shortName=ipp +kubebuilder:printcolumn:name="Family",type=string,JSONPath=`.spec.ipFamily` +kubebuilder:printcolumn:name="Auto-Assign",type=boolean,JSONPath=`.spec.autoAssign` +kubebuilder:printcolumn:name="Advertise",type=boolean,JSONPath=`.spec.advertise` +kubebuilder:printcolumn:name="Interface",type=string,JSONPath=`.spec.interfaceName`,priority=1 +kubebuilder:printcolumn:name="Total",type=string,JSONPath=`.status.totalAddresses`,priority=1 +kubebuilder:printcolumn:name="Allocated",type=string,JSONPath=`.status.allocatedAddresses`,priority=1 +kubebuilder:printcolumn:name="Free",type=string,JSONPath=`.status.freeAddresses` +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"

func (*IPPool) DeepCopy

func (in *IPPool) DeepCopy() *IPPool

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPPool.

func (*IPPool) DeepCopyInto

func (in *IPPool) DeepCopyInto(out *IPPool)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*IPPool) DeepCopyObject

func (in *IPPool) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

type IPPoolList

type IPPoolList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []IPPool `json:"items"`
}

+kubebuilder:object:root=true

func (*IPPoolList) DeepCopy

func (in *IPPoolList) DeepCopy() *IPPoolList

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPPoolList.

func (*IPPoolList) DeepCopyInto

func (in *IPPoolList) DeepCopyInto(out *IPPoolList)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*IPPoolList) DeepCopyObject

func (in *IPPoolList) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

type IPPoolSpec

type IPPoolSpec struct {
	// IP family of the addresses in this pool. Must be either "IPv4" or "IPv6".
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:Enum=IPv4;IPv6
	IPFamily corev1.IPFamily `json:"ipFamily"`

	// List of CIDRs, ranges or individual IPs, e.g. "192.168.1.0/24", "10.0.0.5",
	// "172.16.10.7-172.16.10.10" or "fd37:274a:df59::/64". You can use the prefix "!"
	// to exclude specific addresses or ranges from the pool, e.g. "!10.1.2.3" or
	// "!10.1.0.0/24". Exclusions take precedence over inclusions, so if an IP matches
	// both an inclusion and an exclusion, it will be excluded.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:MinItems=1
	// +listType=set
	Addresses []string `json:"addresses"`

	// If `false`, IPs from this pool will not be auto-assigned to services. Services
	// must explicitly request this pool via annotation.
	// +kubebuilder:default=true
	AutoAssign bool `json:"autoAssign,omitempty"`

	// If `true`, IPs from this pool will be allocated in a way that avoids
	// known buggy addresses (e.g. .0, .1, .255 in IPv4 subnets). This only has
	// an effect if the pool contains CIDR blocks, and is ignored for explicitly
	// listed IPs or ranges. Enabling this may reduce the number of usable
	// addresses in small subnets.
	// +kubebuilder:default=true
	AvoidBuggyIPs bool `json:"avoidBuggyIPs,omitempty"`

	// Whether IPs from this pool should be advertised via ARP/NDP on the
	// router. If `false`, addresses are allocated, load balancers and SNAT are
	// configured, but the address will NOT be configured on an interface in
	// RouterOS.
	// +kubebuilder:default=true
	Advertise bool `json:"advertise,omitempty"`

	// Network interface the router will use for ARP/NDP advertisement. If
	// empty, no interface hint is passed and the most suitable interface is
	// determined by the router's routing table.
	// +kubebuilder:validation:Pattern=`^(|[a-zA-Z0-9][a-zA-Z0-9\-\.]*[a-zA-Z0-9])$`
	// +optional
	InterfaceName string `json:"interfaceName,omitempty"`
}

IPPoolSpec defines the desired state of an IP pool, including the IP family, the list of addresses or CIDRs in the pool, and other configuration options. +kubebuilder:object:generate=true

func (*IPPoolSpec) DeepCopy

func (in *IPPoolSpec) DeepCopy() *IPPoolSpec

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPPoolSpec.

func (*IPPoolSpec) DeepCopyInto

func (in *IPPoolSpec) DeepCopyInto(out *IPPoolSpec)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type IPPoolStatus

type IPPoolStatus struct {
	// Total number of allocatable addresses in this pool in a human-readable format,
	// e.g. "256", "1K" or "1M".
	// +optional
	TotalAddresses string `json:"totalAddresses,omitempty"`

	// Number of currently allocated addresses in a human-readable format, e.g.
	// "256", "1K" or "1M".
	// +optional
	AllocatedAddresses string `json:"allocatedAddresses,omitempty"`

	// Number of currently unallocated addresses in a human-readable format, e.g.
	// "256", "1K" or "1M".
	// +optional
	FreeAddresses string `json:"freeAddresses,omitempty"`

	// Conditions represent the latest available observations of the IP pool's state.
	// +optional
	// +listType=map
	// +listMapKey=type
	// +patchStrategy=merge
	// +patchMergeKey=type
	Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`

	// ObservedGeneration is the most recent generation observed by the controller for this IPPool.
	// It is used to detect if the spec has been updated since the last reconciliation.
	// +optional
	ObservedGeneration int64 `json:"observedGeneration,omitempty"`
}

IPPoolStatus defines the observed state of an IP pool, including the total number of addresses in the pool, how many are currently allocated, and any relevant conditions. +kubebuilder:object:generate=true

func (*IPPoolStatus) DeepCopy

func (in *IPPoolStatus) DeepCopy() *IPPoolStatus

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPPoolStatus.

func (*IPPoolStatus) DeepCopyInto

func (in *IPPoolStatus) DeepCopyInto(out *IPPoolStatus)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

Jump to

Keyboard shortcuts

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