config

package
v0.2.3-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package config defines the intermediate representation (IR) for agent configuration. These types are the shared contract between the agent library and its consumers.

Consumers should define their own public-facing configuration representation and translate to/from these IR types. For example, AKS Flex Node maintains its own JSON config schema and maps it to these structs before calling agent library functions.

TODO: the versioning and stability guarantees for this package are not yet finalized and will be revisited in a future iteration.

Index

Constants

View Source
const (
	DefaultLocalDNSNodeListenerIP    = "169.254.10.10"
	DefaultLocalDNSClusterListenerIP = "169.254.10.11"
	DefaultLocalDNSMetricsPort       = "9253"
	DefaultLocalDNSCPUMilliCores     = 2000
	DefaultLocalDNSMemoryLimitMB     = 128
)

Variables

This section is empty.

Functions

func IsSystemdDeviceGroupSpecifier added in v0.1.22

func IsSystemdDeviceGroupSpecifier(value string) bool

IsSystemdDeviceGroupSpecifier reports whether value is a systemd DeviceAllow device group specifier, such as char-input or block-*. Group names accept ASCII letters, digits, underscores, hyphens, and the '*' wildcard only.

func ValidateAdditionalHostDevices added in v0.1.20

func ValidateAdditionalHostDevices(paths []string) error

ValidateAdditionalHostDevices checks that configured host device paths and systemd device group specifiers are safe to render into nspawn directives.

func ValidateAdditionalHostMounts added in v0.1.23

func ValidateAdditionalHostMounts(mounts []AdditionalHostMount) error

ValidateAdditionalHostMounts checks that configured host bind-mount paths are safe to render into nspawn directives.

Types

type AdditionalHostMount added in v0.1.23

type AdditionalHostMount struct {
	Source   string `json:"Source"`
	Target   string `json:"Target,omitempty"`
	ReadOnly bool   `json:"ReadOnly,omitempty"`
}

AdditionalHostMount configures a host path bind mount for the nspawn machine. Target defaults to Source when omitted.

type AgentClusterConfig

type AgentClusterConfig struct {
	CaCertBase64 string `json:"CaCertBase64"`
	ClusterDNS   string `json:"ClusterDNS"`
	Version      string `json:"Version"`
}

AgentClusterConfig holds the cluster-level values the agent needs to join the Kubernetes control plane.

type AgentConfig

type AgentConfig struct {
	MachineName string `json:"MachineName"`
	// NodeName is the Kubernetes Node name used by kubelet and host-side
	// daemon watches. During goal-state resolution this field is backfilled
	// once. Resolution prefers an explicitly configured value, then a valid
	// host hostname, then MachineName. Explicit and resolved values must be
	// valid Kubernetes DNS subdomains.
	NodeName string               `json:"NodeName,omitempty"`
	Cluster  AgentClusterConfig   `json:"Cluster"`
	Kubelet  AgentKubeletConfig   `json:"Kubelet"`
	CRI      CRIConfig            `json:"CRI"`
	CNI      CNIConfig            `json:"CNI"`
	Gantry   *GantryConfig        `json:"Gantry,omitempty"`
	LocalDNS *AgentLocalDNSConfig `json:"LocalDNS,omitempty"`

	// OCIImage is an OCI registry reference, local OCI layout, or HTTPS URL
	// to a tarred OCI image layout used to bootstrap the machine rootfs. HTTPS
	// archives must contain exactly one tagged image reference, which the agent
	// selects automatically. HTTPS URLs may contain signed query parameters.
	// When empty the agent uses the built-in default image.
	OCIImage string `json:"OCIImage,omitempty"`

	// AdditionalHostDevices lists extra host device nodes under /dev or systemd
	// device group specifiers that should be exposed to the nspawn machine in
	// addition to automatically discovered devices.
	AdditionalHostDevices []string `json:"AdditionalHostDevices,omitempty"`

	// AdditionalHostMounts lists extra host paths that should be bind-mounted
	// into the nspawn machine. ReadOnly should be used unless write access is
	// required.
	AdditionalHostMounts []AdditionalHostMount `json:"AdditionalHostMounts,omitempty"`

	// OfflineArtifacts points to a complete offline binary artifact source.
	// When set, it takes precedence over download overrides. Source is rendered
	// as a strict Go template using the cluster Kubernetes version, then
	// resolved as an absolute filesystem path, file:// URL, HTTPS archive, or
	// oci:// artifact reference. HTTPS URLs may contain signed query parameters.
	OfflineArtifacts *AgentOfflineArtifacts `json:"OfflineArtifacts,omitempty"`
}

AgentConfig is the core configuration needed to bootstrap a Kubernetes node. It contains only the cloud-agnostic fields required by the shared agent library. Platform-specific extensions (e.g. attestation, cloud provider identity) should be defined in the consuming application.

func (*AgentConfig) BackfillNodeName added in v0.1.5

func (a *AgentConfig) BackfillNodeName() error

BackfillNodeName resolves and stores the Kubernetes Node name once. An explicit NodeName wins when set. Otherwise, a valid host hostname wins, then MachineName is used as the final fallback.

func (*AgentConfig) DeepCopy added in v0.1.4

func (a *AgentConfig) DeepCopy() *AgentConfig

DeepCopy returns a copy of AgentConfig with mutable nested values cloned.

func (*AgentConfig) OfflineArtifactsConfigured added in v0.1.21

func (a *AgentConfig) OfflineArtifactsConfigured() bool

OfflineArtifactsConfigured reports whether an offline artifact source is configured.

func (*AgentConfig) Validate added in v0.1.20

func (a *AgentConfig) Validate() error

Validate checks that required agent configuration fields are present and internally consistent. Kubelet auth is validated when present; callers that require a bootstrap credential should enforce that separately because some flows fill the credential later through attestation.

type AgentKubeletConfig

type AgentKubeletConfig struct {
	ApiServer string `json:"ApiServer"`
	// NodeIP overrides kubelet --node-ip. Supports a single IP or a
	// comma-separated dual-stack pair.
	NodeIP             string            `json:"NodeIP,omitempty"`
	Auth               KubeletAuthInfo   `json:"Auth"`
	Labels             map[string]string `json:"Labels"`
	RegisterWithTaints []string          `json:"RegisterWithTaints"`

	// Configuration is merged over the agent's baseline kubelet configuration
	// and rendered as a kubelet.config.k8s.io/v1beta1
	// KubeletConfiguration. apiVersion, kind, authentication,
	// authorization.mode, clusterDNS, containerRuntimeEndpoint,
	// registerWithTaints, and rotateCertificates are agent-owned and must not be
	// supplied here.
	Configuration map[string]any `json:"Configuration,omitempty"`

	// ImageCredentialProvider configures kubelet's exec image credential
	// provider paths inside the nspawn machine.
	ImageCredentialProvider *ImageCredentialProvider `json:"ImageCredentialProvider,omitempty"`
}

AgentKubeletConfig holds kubelet-specific overrides.

func (*AgentKubeletConfig) Validate

func (a *AgentKubeletConfig) Validate() error

Validate checks the kubelet configuration overlay and optional image credential provider paths. Kubelet authentication is validated separately because some consumers populate it after initial configuration resolution.

type AgentLocalDNSConfig

type AgentLocalDNSConfig struct {
	Enabled              bool     `json:"Enabled"`
	NodeListenerIP       string   `json:"NodeListenerIP,omitempty"`
	ClusterListenerIP    string   `json:"ClusterListenerIP,omitempty"`
	MetricsAddress       string   `json:"MetricsAddress,omitempty"`
	CPULimitInMilliCores *int     `json:"CPULimitInMilliCores,omitempty"`
	MemoryLimitInMB      *int     `json:"MemoryLimitInMB,omitempty"`
	RequiredPlugins      []string `json:"RequiredPlugins,omitempty"`
	CorefileTemplate     string   `json:"CorefileTemplate,omitempty"`
}

AgentLocalDNSConfig configures the CoreDNS cache running inside the nspawn machine.

func (*AgentLocalDNSConfig) DeepCopy

DeepCopy returns a copy with independently owned mutable fields.

func (*AgentLocalDNSConfig) Validate

func (c *AgentLocalDNSConfig) Validate(clusterDNS, nodeIP string) error

Validate checks LocalDNS fields that do not require host discovery.

type AgentOfflineArtifacts added in v0.1.21

type AgentOfflineArtifacts struct {
	Source string `json:"Source,omitempty"`
}

AgentOfflineArtifacts configures a complete offline source for binaries the agent installs into the nspawn rootfs.

func (*AgentOfflineArtifacts) DeepCopy added in v0.1.21

DeepCopy returns a copy of AgentOfflineArtifacts.

type CNIConfig

type CNIConfig struct {
	// PluginVersion overrides the default CNI plugin version (e.g. "1.5.1").
	PluginVersion string `json:"PluginVersion,omitempty"`
}

CNIConfig holds CNI plugin version overrides. Zero values fall back to the library defaults in goalstates/constants.go.

type CRIConfig

type CRIConfig struct {
	Containerd ContainerdConfig `json:"Containerd"`
	Runc       RuncConfig       `json:"Runc"`
}

CRIConfig holds container runtime version overrides. Zero values fall back to the library defaults in goalstates/constants.go.

type ContainerdConfig

type ContainerdConfig struct {
	// Version overrides the default containerd version (e.g. "2.1.8").
	Version string `json:"Version,omitempty"`

	// SandboxImage overrides the CRI sandbox image used by containerd
	// (e.g. "mcr.microsoft.com/oss/v2/kubernetes/pause:3.9").
	SandboxImage string `json:"SandboxImage,omitempty"`
}

ContainerdConfig holds containerd-specific overrides.

type GantryConfig added in v0.1.23

type GantryConfig struct {
	// Disabled skips writing the default containerd hosts.toml that points at
	// Gantry. This is a breakglass setting for environments that need to own
	// containerd registry routing independently.
	Disabled bool `json:"Disabled,omitempty"`
}

GantryConfig holds optional Gantry integration settings.

type ImageCredentialProvider

type ImageCredentialProvider struct {
	ConfigPath string `json:"ConfigPath"`
	BinDir     string `json:"BinDir"`
}

ImageCredentialProvider holds paths inside the nspawn machine for kubelet's exec image credential provider configuration and binaries. ConfigPath may identify a single configuration file or a directory supported by the installed kubelet version.

func (*ImageCredentialProvider) DeepCopy

DeepCopy returns a copy of ImageCredentialProvider.

func (*ImageCredentialProvider) Validate

func (provider *ImageCredentialProvider) Validate() error

Validate validates paths that kubelet consumes inside the nspawn machine. The paths are not required to exist in the unpacked rootfs because they may be supplied by nspawn bind mounts at start time.

type KubeletAuthInfo

type KubeletAuthInfo struct {
	// BootstrapToken is a Kubernetes bootstrap token in
	// "<token-id>.<token-secret>" format used for TLS bootstrapping.
	BootstrapToken string `json:"BootstrapToken,omitempty"`

	// ExecCredential configures kubelet to authenticate via a
	// client.authentication.k8s.io exec credential plugin.
	ExecCredential *clientcmdapi.ExecConfig `json:"ExecCredential,omitempty"`
}

KubeletAuthInfo holds the kubelet authentication configuration. Exactly one of BootstrapToken or ExecCredential must be set.

func (*KubeletAuthInfo) Validate

func (a *KubeletAuthInfo) Validate() error

Validate checks that exactly one auth method is configured.

type RuncConfig

type RuncConfig struct {
	// Version overrides the default runc version (e.g. "1.5.0").
	Version string `json:"Version,omitempty"`
}

RuncConfig holds runc-specific overrides.

Jump to

Keyboard shortcuts

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