Documentation
¶
Overview ¶
Package controller implements the Kubernetes node controller for CIDR allocation.
Package controller implements the GatewayPool controller for managing gateway node pools.
Package controller implements the Peering aggregation controller.
Package controller implements site labeling and pod CIDR assignment.
Index ¶
- Constants
- Variables
- type AssignmentAllocatorDebugState
- type Controller
- type GatewayPoolController
- type PeeringAggregationController
- type SiteController
- func (sc *SiteController) DebugState() SiteControllerDebugState
- func (sc *SiteController) GetNodeLister() corev1listers.NodeLister
- func (sc *SiteController) GetSiteForNode(node *corev1.Node) string
- func (sc *SiteController) GetSiteInformer() cache.SharedIndexInformer
- func (sc *SiteController) Run(ctx context.Context, workers int) error
- func (sc *SiteController) TryAllocateForNode(nodeName string, internalIPs []string) (string, []string, string, bool)
- type SiteControllerDebugState
Constants ¶
const ( // SiteLabelKey is the label key used to identify which site a node belongs to SiteLabelKey = "net.unbounded-cloud.io/site" // WireGuardPubKeyAnnotation is the annotation key for a node's WireGuard public key WireGuardPubKeyAnnotation = "net.unbounded-cloud.io/wg-pubkey" // WireGuardPortAnnotation is the annotation key for a gateway node's // assigned WireGuard port (used for gateway-to-gateway peering). WireGuardPortAnnotation = "net.unbounded-cloud.io/wireguard-port" // TunnelMTUAnnotation is the annotation key for a node's detected // maximum tunnel MTU (default-route MTU minus encapsulation // overhead). The controller compares this against the configured node MTU // to surface warnings when the configured value is too high. TunnelMTUAnnotation = "net.unbounded-cloud.io/tunnel-mtu" // ProtectionFinalizer prevents deletion of Sites and GatewayPools that // still have active nodes assigned. The controller adds this finalizer // when nodes are present and removes it when the last node is unassigned. ProtectionFinalizer = "net.unbounded-cloud.io/protection" )
Variables ¶
var ( SiteNodesGauge = promauto.NewGaugeVec(prometheus.GaugeOpts{ Namespace: controllerNamespace, Name: "site_nodes_total", Help: "Number of nodes in each site.", }, []string{"site"}) SiteNodeSlicesGauge = promauto.NewGaugeVec(prometheus.GaugeOpts{ Namespace: controllerNamespace, Name: "site_node_slices_total", Help: "Number of SiteNodeSlice objects per site.", }, []string{"site"}) PodCIDRAllocations = promauto.NewCounter(prometheus.CounterOpts{ Namespace: controllerNamespace, Name: "pod_cidr_allocations_total", Help: "Total pod CIDR allocations.", }) PodCIDRReleases = promauto.NewCounter(prometheus.CounterOpts{ Namespace: controllerNamespace, Name: "pod_cidr_releases_total", Help: "Total pod CIDR releases.", }) PodCIDRExhaustion = promauto.NewCounter(prometheus.CounterOpts{ Namespace: controllerNamespace, Name: "pod_cidr_exhaustion_total", Help: "Total pod CIDR pool exhaustion events.", }) GatewayPoolNodesGauge = promauto.NewGaugeVec(prometheus.GaugeOpts{ Namespace: controllerNamespace, Name: "gateway_pool_nodes_total", Help: "Number of nodes in each gateway pool.", }, []string{"pool"}) GatewayPoolReachableSitesGauge = promauto.NewGaugeVec(prometheus.GaugeOpts{ Namespace: controllerNamespace, Name: "gateway_pool_reachable_sites_total", Help: "Number of reachable sites per gateway pool.", }, []string{"pool"}) GatewayPoolRoutesGauge = promauto.NewGaugeVec(prometheus.GaugeOpts{ Namespace: controllerNamespace, Name: "gateway_pool_routes_total", Help: "Number of routes per gateway pool.", }, []string{"pool"}) )
Resource state metrics -- set after each successful reconciliation.
var ( CRDEnsureDuration = promauto.NewHistogramVec(prometheus.HistogramOpts{ Namespace: controllerNamespace, Name: "crd_ensure_duration_seconds", Help: "Duration of CRD ensure operations in seconds.", Buckets: metrics.DefaultDurationBuckets, }, []string{"crd"}) CRDEnsureErrors = promauto.NewCounterVec(prometheus.CounterOpts{ Namespace: controllerNamespace, Name: "crd_ensure_errors_total", Help: "Total CRD ensure errors by CRD name.", }, []string{"crd"}) )
CRD management metrics.
Functions ¶
This section is empty.
Types ¶
type AssignmentAllocatorDebugState ¶
type AssignmentAllocatorDebugState struct {
Key string `json:"key"`
SiteName string `json:"siteName"`
AssignmentIndex int `json:"assignmentIndex"`
CidrBlocks []string `json:"cidrBlocks"`
NodeRegexes []string `json:"nodeRegexes,omitempty"`
Allocator allocator.AllocatorDebugState `json:"allocator"`
}
AssignmentAllocatorDebugState contains debug info for one assignment allocator.
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller manages CIDR allocation for Kubernetes nodes.
func NewController ¶
func NewController( clientset kubernetes.Interface, informerFactory informers.SharedInformerFactory, alloc *allocator.Allocator, nodeRegexPattern string, recorder record.EventRecorder, ) (*Controller, error)
NewController creates a new node CIDR controller. If nodeRegexPattern is non-empty, only nodes matching the regex will be processed.
func (*Controller) DryRun ¶
func (c *Controller) DryRun(ctx context.Context) error
DryRun performs a single evaluation pass and prints proposed changes without applying them.
func (*Controller) InformerSynced ¶
func (c *Controller) InformerSynced() bool
InformerSynced returns true if the informer cache has been synced.
func (*Controller) InitializeAllocator ¶
func (c *Controller) InitializeAllocator(ctx context.Context) error
InitializeAllocator scans all existing nodes and marks their CIDRs as allocated. Note: This marks CIDRs from ALL nodes as allocated, regardless of the node filter, to avoid allocating CIDRs that are already in use by nodes outside the filter.
type GatewayPoolController ¶
type GatewayPoolController struct {
// contains filtered or unexported fields
}
GatewayPoolController manages GatewayPool status based on node selector matches.
func NewGatewayPoolController ¶
func NewGatewayPoolController( clientset kubernetes.Interface, dynamicClient dynamic.Interface, dynamicInformerFactory dynamicinformer.DynamicSharedInformerFactory, nodeInformerFactory informers.SharedInformerFactory, ) (*GatewayPoolController, error)
NewGatewayPoolController creates a new gateway pool controller.
type PeeringAggregationController ¶
type PeeringAggregationController struct {
// contains filtered or unexported fields
}
PeeringAggregationController updates GatewayPool status based on Peering relationships.
func NewPeeringAggregationController ¶
func NewPeeringAggregationController( dynamicClient dynamic.Interface, dynamicInformerFactory dynamicinformer.DynamicSharedInformerFactory, ) (*PeeringAggregationController, error)
NewPeeringAggregationController creates a new peering aggregation controller.
type SiteController ¶
type SiteController struct {
// contains filtered or unexported fields
}
SiteController manages site labeling and pod CIDR assignment for nodes.
func NewSiteController ¶
func NewSiteController( clientset kubernetes.Interface, dynamicClient dynamic.Interface, dynamicInformerFactory dynamicinformer.DynamicSharedInformerFactory, nodeInformerFactory informers.SharedInformerFactory, ) (*SiteController, error)
NewSiteController creates a new site controller.
func (*SiteController) DebugState ¶
func (sc *SiteController) DebugState() SiteControllerDebugState
DebugState returns a snapshot of the site controller's internal state.
func (*SiteController) GetNodeLister ¶
func (sc *SiteController) GetNodeLister() corev1listers.NodeLister
GetNodeLister returns the node lister for use by other components.
func (*SiteController) GetSiteForNode ¶
func (sc *SiteController) GetSiteForNode(node *corev1.Node) string
GetSiteForNode looks up which site a node belongs to using the cached sites. This is a faster lookup for use by other components.
func (*SiteController) GetSiteInformer ¶
func (sc *SiteController) GetSiteInformer() cache.SharedIndexInformer
GetSiteInformer returns the site informer for use by other components.
func (*SiteController) Run ¶
func (sc *SiteController) Run(ctx context.Context, workers int) error
Run starts the site controller
func (*SiteController) TryAllocateForNode ¶
func (sc *SiteController) TryAllocateForNode(nodeName string, internalIPs []string) (string, []string, string, bool)
TryAllocateForNode attempts to allocate pod CIDRs for a node based on its internal IPs. Returns (podCIDR, podCIDRs, true) on success or ("", nil, false) if allocation is not possible.
type SiteControllerDebugState ¶
type SiteControllerDebugState struct {
HasSynced bool `json:"hasSynced"`
AllocatorsReady bool `json:"allocatorsReady"`
WorkqueueLength int `json:"workqueueLength"`
SiteCount int `json:"siteCount"`
Allocators []AssignmentAllocatorDebugState `json:"allocators"`
InformerCounts map[string]int `json:"informerCounts"`
}
SiteControllerDebugState contains debug info for the site controller.