config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package config provides configuration types for the unbounded-net-controller.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoCIDRsConfigured is returned when neither IPv4 nor IPv6 CIDRs are configured.
	ErrNoCIDRsConfigured = errors.New("at least one of --ipv4-cidrs or --ipv6-cidrs must be specified")
	// ErrIPv4MaskSizeRequired is returned when IPv4 CIDRs are configured but no mask size is specified.
	ErrIPv4MaskSizeRequired = errors.New("--ipv4-mask-size is required when --ipv4-cidrs is specified")
	// ErrIPv6MaskSizeRequired is returned when IPv6 CIDRs are configured but no mask size is specified.
	ErrIPv6MaskSizeRequired = errors.New("--ipv6-mask-size is required when --ipv6-cidrs is specified")
	// ErrInvalidIPv6CIDR is returned when the first IPv6 CIDR cannot be parsed.
	ErrInvalidIPv6CIDR = errors.New("invalid IPv6 CIDR format")
)

Functions

func ParseDurationField

func ParseDurationField(raw, fieldName string) (time.Duration, error)

ParseDurationField parses a duration field and annotates parse errors.

func WatchConfigLogLevel

func WatchConfigLogLevel(ctx context.Context, configPath string)

WatchConfigLogLevel watches the runtime config file for changes and dynamically updates the klog verbosity when the common.logLevel field changes. Kubernetes ConfigMap volume mounts use symlink swaps, so we watch the parent directory for reliable notification. The function blocks until ctx is cancelled.

Types

type CommonRuntimeConfig

type CommonRuntimeConfig struct {
	AzureTenantID string `yaml:"azureTenantId"`
	LogLevel      *int   `yaml:"logLevel"`
	ApiserverURL  string `yaml:"apiserverURL"`
}

CommonRuntimeConfig contains settings shared by controller and node binaries.

type Config

type Config struct {
	// ConfigFile is the path to the runtime YAML config file, used for dynamic reloading.
	ConfigFile string
	// KubeconfigPath is the path to the kubeconfig file. Empty for in-cluster config.
	KubeconfigPath string
	// ApiserverURL overrides the Kubernetes API server URL. When set, this URL
	// is used instead of the in-cluster service host. Empty means use the default.
	ApiserverURL string
	// AzureTenantID is surfaced by the status UI for Azure portal links.
	AzureTenantID string
	// DryRun causes the controller to run a single evaluation and print proposed changes.
	DryRun bool
	// HealthPort is the port for the health check HTTP server. 0 disables the server.
	HealthPort int
	// NodeAgentHealthPort is the port where node agents serve their health/status endpoints.
	NodeAgentHealthPort int
	// InformerResyncPeriod is the resync period for informers.
	InformerResyncPeriod time.Duration
	// LeaderElection contains leader election configuration.
	LeaderElection LeaderElectionConfig
	// StatusStaleThreshold is the duration after which a node's pushed status is considered stale.
	// When stale, the controller falls back to pulling status directly from the node.
	StatusStaleThreshold time.Duration
	// RegisterAggregatedAPIServer controls whether the controller serves aggregated API status endpoints.
	RegisterAggregatedAPIServer bool
	// StatusWSKeepaliveInterval controls websocket ping cadence for node status streams.
	// Set to 0 to disable controller-side websocket keepalive pings.
	StatusWSKeepaliveInterval time.Duration
	// StatusWSKeepaliveFailureCount is the number of sequential websocket keepalive ping failures
	// before the controller closes a node status websocket connection.
	StatusWSKeepaliveFailureCount int
	// RequireDashboardAuth controls whether the status dashboard and JSON
	// endpoints require authentication and SubjectAccessReview authorization.
	RequireDashboardAuth bool
	// NodeMTU is the configured node MTU from the shared configmap (node.mtu).
	// Used to validate that no node's detected WireGuard MTU is lower than this value.
	// A value of 0 means the check is skipped.
	NodeMTU int
	// KubeProxyHealthInterval is the interval between kube-proxy health checks on the controller node.
	// Set to 0 to disable the check.
	KubeProxyHealthInterval time.Duration
	// NetlinkResyncPeriod is the interval between full netlink cache resyncs on node agents.
	NetlinkResyncPeriod time.Duration
	// NodeTokenLifetime is the lifetime of HMAC tokens issued to node agents.
	NodeTokenLifetime time.Duration
	// ViewerTokenLifetime is the lifetime of HMAC tokens issued to dashboard viewers.
	ViewerTokenLifetime time.Duration
}

Config holds the controller configuration.

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the configuration and returns an error if invalid. It also sets default mask sizes if not specified: - IPv4: defaults to /24 - IPv6: defaults to (first CIDR prefix size + 16), e.g., /64 -> /80

type ControllerLeaderElectionYAML

type ControllerLeaderElectionYAML struct {
	Enabled           *bool  `yaml:"enabled"`
	LeaseDuration     string `yaml:"leaseDuration"`
	RenewDeadline     string `yaml:"renewDeadline"`
	RetryPeriod       string `yaml:"retryPeriod"`
	ResourceNamespace string `yaml:"resourceNamespace"`
	ResourceName      string `yaml:"resourceName"`
}

ControllerLeaderElectionYAML configures controller leader election behavior.

type ControllerRuntimeConfig

type ControllerRuntimeConfig struct {
	InformerResyncPeriod        string                       `yaml:"informerResyncPeriod"`
	HealthPort                  *int                         `yaml:"healthPort"`
	NodeAgentHealthPort         *int                         `yaml:"nodeAgentHealthPort"`
	StatusStaleThreshold        string                       `yaml:"statusStaleThreshold"`
	StatusWSKeepaliveInterval   string                       `yaml:"statusWebsocketKeepaliveInterval"`
	StatusWSKeepaliveFailCount  *int                         `yaml:"statusWsKeepaliveFailureCount"`
	RegisterAggregatedAPIServer *bool                        `yaml:"registerAggregatedAPIServer"`
	RequireDashboardAuth        *bool                        `yaml:"requireDashboardAuth"`
	KubeProxyHealthInterval     string                       `yaml:"kubeProxyHealthInterval"`
	LeaderElection              ControllerLeaderElectionYAML `yaml:"leaderElection"`
}

ControllerRuntimeConfig contains controller-specific runtime settings.

type LeaderElectionConfig

type LeaderElectionConfig struct {
	// Enabled indicates whether leader election is enabled.
	Enabled bool
	// LeaseDuration is the duration that non-leader candidates will wait to force acquire leadership.
	LeaseDuration time.Duration
	// RenewDeadline is the duration that the acting leader will retry refreshing leadership before giving up.
	RenewDeadline time.Duration
	// RetryPeriod is the duration the LeaderElector clients should wait between tries of actions.
	RetryPeriod time.Duration
	// ResourceNamespace is the namespace in which the leader election resource will be created.
	ResourceNamespace string
	// ResourceName is the name of the leader election resource.
	ResourceName string
}

LeaderElectionConfig holds leader election configuration.

func DefaultLeaderElectionConfig

func DefaultLeaderElectionConfig() LeaderElectionConfig

DefaultLeaderElectionConfig returns the default leader election configuration.

type NodeRuntimeConfig

type NodeRuntimeConfig struct {
	InformerResyncPeriod string `yaml:"informerResyncPeriod"`
	NodeName             string `yaml:"nodeName"`
	CNIConfDir           string `yaml:"cniConfDir"`
	CNIConfFile          string `yaml:"cniConfFile"`
	BridgeName           string `yaml:"bridgeName"`
	WireGuardDir         string `yaml:"wireGuardDir"`
	WireGuardPort        *int   `yaml:"wireGuardPort"`
	// Deprecated: EnablePolicyRouting enables connmark/fwmark/ip-rule policy
	// routing on gateway interfaces. Replaced by per-interface FORWARD ACCEPT
	// rules. Defaults to false; retained for backward compatibility.
	EnablePolicyRouting                  *bool  `yaml:"enablePolicyRouting"`
	MTU                                  *int   `yaml:"mtu"`
	HealthPort                           *int   `yaml:"healthPort"`
	StatusPushEnabled                    *bool  `yaml:"statusPushEnabled"`
	StatusPushURL                        string `yaml:"statusPushURL"`
	StatusPushInterval                   string `yaml:"statusPushInterval"`
	StatusPushAPIServerInterval          string `yaml:"statusPushApiserverInterval"`
	StatusPushDelta                      *bool  `yaml:"statusPushDelta"`
	StatusWSEnabled                      *bool  `yaml:"statusWebsocketEnabled"`
	StatusWSURL                          string `yaml:"statusWebsocketURL"`
	StatusWSAPIServerMode                string `yaml:"statusWebsocketApiserverMode"`
	StatusWSAPIServerURL                 string `yaml:"statusWebsocketApiserverURL"`
	StatusWSAPIServerStartupDelay        string `yaml:"statusWebsocketApiserverStartupDelay"`
	StatusWSKeepaliveInterval            string `yaml:"statusWebsocketKeepaliveInterval"`
	StatusWSKeepaliveFailCount           *int   `yaml:"statusWsKeepaliveFailureCount"`
	RemoveConfigurationOnShutdown        *bool  `yaml:"removeConfigurationOnShutdown"`
	ShutdownRemoveWireGuardConfiguration *bool  `yaml:"shutdownRemoveWireGuardConfiguration"` // Deprecated: use RemoveConfigurationOnShutdown
	ShutdownRemoveIPRoutes               *bool  `yaml:"shutdownRemoveIPRoutes"`               // Deprecated: use RemoveConfigurationOnShutdown
	ShutdownRemoveMasqueradeRules        *bool  `yaml:"shutdownRemoveMasqueradeRules"`        // Deprecated: use RemoveConfigurationOnShutdown
	CriticalDeltaEvery                   string `yaml:"criticalDeltaEvery"`
	StatsDeltaEvery                      string `yaml:"statsDeltaEvery"`
	FullSyncEvery                        string `yaml:"fullSyncEvery"`
	PreferredPrivateNetworkEncapsulation string `yaml:"preferredPrivateNetworkEncapsulation"`
	PreferredPublicNetworkEncapsulation  string `yaml:"preferredPublicNetworkEncapsulation"`
	HealthFlapMaxBackoff                 string `yaml:"healthFlapMaxBackoff"`
	KubeProxyHealthInterval              string `yaml:"kubeProxyHealthInterval"`
	RouteTableID                         *int   `yaml:"routeTableId"`
	NetlinkResyncPeriod                  string `yaml:"netlinkResyncPeriod"`
	TunnelDataplane                      string `yaml:"tunnelDataplane"`
	TunnelDataplaneMapSize               *int   `yaml:"tunnelDataplaneMapSize"`
	TunnelIPFamily                       string `yaml:"tunnelIPFamily"`
	VXLANSrcPortLow                      *int   `yaml:"vxlanSrcPortLow"`
	VXLANSrcPortHigh                     *int   `yaml:"vxlanSrcPortHigh"`
}

NodeRuntimeConfig contains node-agent runtime settings.

type RuntimeConfig

type RuntimeConfig struct {
	Common     CommonRuntimeConfig     `yaml:"common"`
	Controller ControllerRuntimeConfig `yaml:"controller"`
	Node       NodeRuntimeConfig       `yaml:"node"`
}

RuntimeConfig is the root YAML runtime configuration schema.

func LoadRuntimeConfig

func LoadRuntimeConfig(path string) (*RuntimeConfig, error)

LoadRuntimeConfig reads and parses a runtime config YAML file.

Jump to

Keyboard shortcuts

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