config

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultContainerdMetricsAddress = "0.0.0.0:10257"
	DefaultSandboxImage             = "mcr.microsoft.com/oss/kubernetes/pause:3.9"

	DefaultCNIBinDir    = "/opt/cni/bin"
	DefaultCNIConfigDir = "/etc/cni/net.d"

	DefaultBinaryPath = "/usr/local/bin"

	DefaultNvidiaContainerRuntimePath = "/usr/bin/nvidia-container-runtime"
	DefaultNvidiaRuntimeClassName     = "nvidia"

	DefaultCNIPluginsVersion = "1.5.1"
	DefaultCNISpecVersion    = "0.3.1"
	DefaultNPDVersion        = "v1.35.1"
	DefaultRunCVersion       = "1.1.12"
	DefaultContainerdVersion = "2.0.4" // FIXME: confirm if we still want containerd 1.x

	KubeletKubeconfigPath          = "/var/lib/kubelet/kubeconfig"
	KubeletBootstrapKubeconfigPath = "/var/lib/kubelet/bootstrap-kubeconfig"
)

Variables

View Source
var AKSClusterResourceIDPattern = regexp.MustCompile(`(?i)^/subscriptions/([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})/resourcegroups/([a-zA-Z0-9_\-\.]+)/providers/microsoft\.containerservice/managedclusters/([a-zA-Z0-9_\-\.]+)$`)

AKSClusterResourceIDPattern is AKS cluster resource ID regex pattern with capture groups Format: /subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.ContainerService/managedClusters/{cluster-name} Pattern is case insensitive to handle variations in Azure resource path casing

View Source
var BootstrapTokenPattern = regexp.MustCompile(`^[a-z0-9]{6}\.[a-z0-9]{16}$`)

BootstrapTokenPattern is the regex pattern for Kubernetes bootstrap tokens Format: <token-id>.<token-secret> where token-id is 6 chars [a-z0-9] and token-secret is 16 chars [a-z0-9]

Functions

This section is empty.

Types

type AgentConfig

type AgentConfig struct {
	LogLevel string `json:"logLevel"` // Logging level: debug, info, warning, error
	LogDir   string `json:"logDir"`   // Directory for log files
}

AgentConfig holds agent-specific operational configuration.

type ArcConfig

type ArcConfig struct {
	Enabled       bool              `json:"enabled"`       // Whether to enable Azure Arc registration
	MachineName   string            `json:"machineName"`   // Name for the Arc machine resource
	Tags          map[string]string `json:"tags"`          // Tags to apply to the Arc machine
	ResourceGroup string            `json:"resourceGroup"` // Azure resource group for Arc machine
	Location      string            `json:"location"`      // Azure region for Arc machine
}

ArcConfig holds Azure Arc machine configuration for registering the machine with Azure Arc.

type AzureConfig

type AzureConfig struct {
	SubscriptionID   string                  `json:"subscriptionId"`             // Azure subscription ID
	TenantID         string                  `json:"tenantId"`                   // Azure tenant ID
	Cloud            string                  `json:"cloud"`                      // Azure cloud environment (defaults to AzurePublicCloud)
	ServicePrincipal *ServicePrincipalConfig `json:"servicePrincipal,omitempty"` // Optional service principal authentication
	ManagedIdentity  *ManagedIdentityConfig  `json:"managedIdentity,omitempty"`  // Optional managed identity authentication
	BootstrapToken   *BootstrapTokenConfig   `json:"bootstrapToken,omitempty"`   // Optional bootstrap token authentication
	Arc              *ArcConfig              `json:"arc"`                        // Azure Arc machine configuration
	TargetCluster    *TargetClusterConfig    `json:"targetCluster"`              // Target AKS cluster configuration
}

AzureConfig holds Azure-specific configuration required for connecting to Azure services. All fields except Cloud are required for proper operation.

type BootstrapTokenConfig

type BootstrapTokenConfig struct {
	Token string `json:"token"` // Bootstrap token in format: <token-id>.<token-secret>
}

BootstrapTokenConfig holds Kubernetes bootstrap token authentication configuration. Bootstrap tokens provide a lightweight authentication method for node joining.

type CNIConfig

type CNIConfig struct {
	Version string `json:"version"`
}

CNIPathsConfig holds file system paths related to CNI plugins and configurations.

type Config

type Config struct {
	Azure      AzureConfig      `json:"azure"`
	Agent      AgentConfig      `json:"agent"`
	Containerd ContainerdConfig `json:"containerd"`
	Kubernetes KubernetesConfig `json:"kubernetes"`
	CNI        CNIConfig        `json:"cni"`
	Runc       RuncConfig       `json:"runc"`
	Node       NodeConfig       `json:"node"`
	Paths      PathsConfig      `json:"paths"`
	Npd        NPDConfig        `json:"npd"`
	// contains filtered or unexported fields
}

Config represents the complete agent configuration structure. It contains Azure-specific settings and agent operational settings.

func GetConfig

func GetConfig() *Config

GetConfig returns the singleton configuration instance. Returns nil if configuration has not been loaded yet. Use LoadConfig() first. This function is thread-safe and handles concurrent access correctly.

func LoadConfig

func LoadConfig(configPath string) (*Config, error)

LoadConfig loads configuration from a JSON file and environment variables. The configPath parameter is required and cannot be empty. Environment variables can override config file values using the AKS_NODE_CONTROLLER_ prefix. For example: AKS_NODE_CONTROLLER_AZURE_LOCATION=westus2

func (*Config) GetArcLocation

func (cfg *Config) GetArcLocation() string

GetArcLocation returns the Arc machine location from configuration or defaults to the target cluster location

func (*Config) GetArcMachineName

func (cfg *Config) GetArcMachineName() string

GetArcMachineName returns the Arc machine name from configuration or defaults to the system hostname

func (*Config) GetArcResourceGroup

func (cfg *Config) GetArcResourceGroup() string

GetArcResourceGroup returns the Arc machine resource group from configuration or defaults to the target cluster resource group

func (*Config) GetArcTags

func (cfg *Config) GetArcTags() map[string]string

GetArcTags returns the Arc machine tags from configuration or an empty map if none are set

func (*Config) GetKubernetesVersion

func (cfg *Config) GetKubernetesVersion() string

GetKubernetesVersion returns the Kubernetes version from configuration

func (*Config) GetSubscriptionID

func (cfg *Config) GetSubscriptionID() string

GetSubscriptionID returns the Azure subscription ID from configuration

func (*Config) GetTargetClusterID

func (cfg *Config) GetTargetClusterID() string

GetTargetClusterID returns the target AKS cluster resource ID from configuration

func (*Config) GetTargetClusterLocation

func (cfg *Config) GetTargetClusterLocation() string

GetTargetClusterLocation returns the target AKS cluster location from configuration

func (*Config) GetTargetClusterName

func (cfg *Config) GetTargetClusterName() string

GetTargetClusterName returns the target AKS cluster name from configuration

func (*Config) GetTargetClusterResourceGroup

func (cfg *Config) GetTargetClusterResourceGroup() string

GetTargetClusterResourceGroup returns the target AKS cluster resource group from configuration

func (*Config) GetTargetClusterSubscriptionID

func (cfg *Config) GetTargetClusterSubscriptionID() string

GetTargetClusterSubscriptionID returns the target AKS cluster subscription ID from configuration

func (*Config) GetTenantID

func (cfg *Config) GetTenantID() string

GetTenantID returns the Azure tenant ID from configuration

func (*Config) IsARCEnabled

func (cfg *Config) IsARCEnabled() bool

IsARCEnabled checks if Azure Arc registration is enabled in the configuration

func (*Config) IsBootstrapTokenConfigured

func (cfg *Config) IsBootstrapTokenConfigured() bool

IsBootstrapTokenConfigured checks if bootstrap token credentials are provided in the configuration

func (*Config) IsMIConfigured

func (cfg *Config) IsMIConfigured() bool

IsMIConfigured checks if managed identity configuration is provided in the configuration Uses internal flag set during config loading to handle viper's empty object behavior

func (*Config) IsSPConfigured

func (cfg *Config) IsSPConfigured() bool

IsSPConfigured checks if service principal credentials are provided in the configuration

func (*Config) SetDefaults

func (c *Config) SetDefaults()

SetDefaults sets default values for any missing configuration fields

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the configuration and ensures all required fields are set

type ContainerdConfig

type ContainerdConfig struct {
	Version        string `json:"version"`
	PauseImage     string `json:"pauseImage"`
	MetricsAddress string `json:"metricsAddress"`
}

ContainerdConfig holds configuration settings for the containerd runtime.

type KubeletConfig

type KubeletConfig struct {
	KubeReserved         map[string]string `json:"kubeReserved"`
	EvictionHard         map[string]string `json:"evictionHard"`
	Verbosity            int               `json:"verbosity"`
	ImageGCHighThreshold int               `json:"imageGCHighThreshold"`
	ImageGCLowThreshold  int               `json:"imageGCLowThreshold"`
	DNSServiceIP         string            `json:"dnsServiceIP"` // Cluster DNS service IP (default: 10.0.0.10 for AKS)
	ServerURL            string            `json:"serverURL"`    // Kubernetes API server URL
	CACertData           string            `json:"caCertData"`   // Base64-encoded CA certificate data
}

KubeletConfig holds kubelet-specific configuration settings.

type KubernetesConfig

type KubernetesConfig struct {
	Version     string `json:"version"`
	URLTemplate string `json:"urlTemplate"`
}

KubernetesConfig holds configuration settings for Kubernetes components.

type KubernetesPathsConfig

type KubernetesPathsConfig struct {
	ConfigDir       string `json:"configDir"`
	CertsDir        string `json:"certsDir"`
	ManifestsDir    string `json:"manifestsDir"`
	VolumePluginDir string `json:"volumePluginDir"`
	KubeletDir      string `json:"kubeletDir"`
}

KubernetesPathsConfig holds file system paths related to Kubernetes components.

type ManagedIdentityConfig

type ManagedIdentityConfig struct {
	ClientID string `json:"clientId,omitempty"` // Client ID of the managed identity (optional, for VMs with multiple identities)
}

ManagedIdentityConfig holds managed identity authentication configuration. It can only be used when the agent is running on an Azure VM with a managed identity assigned.

type NPDConfig

type NPDConfig struct {
	Version string `json:"version"`
}

NPDConfig holds configuration settings for the Node Problem Detector (NPD).

type NodeConfig

type NodeConfig struct {
	MaxPods int               `json:"maxPods"`
	Labels  map[string]string `json:"labels"`
	Kubelet KubeletConfig     `json:"kubelet"`
}

NodeConfig holds configuration settings for the Kubernetes node.

type PathsConfig

type PathsConfig struct {
	Kubernetes KubernetesPathsConfig `json:"kubernetes"`
}

PathsConfig holds file system paths used by the agent for Kubernetes and CNI configurations.

type RuncConfig

type RuncConfig struct {
	Version string `json:"version"`
	URL     string `json:"url"`
}

RuncConfig holds configuration settings for the container runtime (runc).

type ServicePrincipalConfig

type ServicePrincipalConfig struct {
	TenantID     string `json:"tenantId"`     // Azure AD tenant ID
	ClientID     string `json:"clientId"`     // Azure AD application (client) ID
	ClientSecret string `json:"clientSecret"` // Azure AD application client secret
}

ServicePrincipalConfig holds Azure service principal authentication configuration. When provided, service principal authentication will be used instead of Azure CLI.

type TargetClusterConfig

type TargetClusterConfig struct {
	ResourceID        string `json:"resourceId"` // Full resource ID of the target AKS cluster
	Location          string `json:"location"`   // Azure region of the cluster (e.g., "eastus", "westus2")
	Name              string // will be populated from ResourceID
	ResourceGroup     string // will be populated from ResourceID
	SubscriptionID    string // will be populated from ResourceID
	NodeResourceGroup string // will be populated from ResourceID
}

TargetClusterConfig holds configuration for the target AKS cluster the ARC machine will connect to.

Jump to

Keyboard shortcuts

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