spec

package
v0.0.19 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const ManagedClusterSpecPath = RuntimeDir + "/managedcluster-spec.json"

ManagedClusterSpecPath is the path to the managed cluster spec snapshot file.

View Source
const (
	// ManagedClusterSpecSchemaVersion is incremented when the persisted JSON schema changes.
	ManagedClusterSpecSchemaVersion = 1
)
View Source
const RuntimeDir = "/run/aks-flex-node"

RuntimeDir is the single runtime directory used for spec and status artifacts. Under systemd, RuntimeDirectory=aks-flex-node creates this before ExecStart. For CLI invocations, call EnsureRuntimeDir early to create it.

View Source
const StatusFilePath = RuntimeDir + "/status.json"

StatusFilePath is the path to the node status snapshot file.

Variables

This section is empty.

Functions

func DesiredKubernetesVersion added in v0.0.17

func DesiredKubernetesVersion(specSnap *ManagedClusterSpec) string

DesiredKubernetesVersion returns the preferred Kubernetes version from a managed cluster spec.

Priority:

  1. CurrentKubernetesVersion (typically a full patch version)
  2. KubernetesVersion (typically major.minor or a less specific version)

func EnsureRuntimeDir added in v0.0.19

func EnsureRuntimeDir() error

EnsureRuntimeDir creates the runtime directory with restricted permissions. Call this once at process startup before any code that reads or writes spec/status files. Returns an error if the directory cannot be created.

func OverrideKubernetesVersionFromManagedClusterSpec added in v0.0.17

func OverrideKubernetesVersionFromManagedClusterSpec(cfg *config.Config) (changed bool, oldVersion, newVersion string, err error)

OverrideKubernetesVersionFromManagedClusterSpec loads the managed cluster spec snapshot from disk and, if it contains a Kubernetes version, overwrites cfg.Kubernetes.Version.

This is best-effort: callers may choose to ignore errors if the spec file doesn't exist yet.

func OverrideKubernetesVersionFromManagedClusterSpecFile added in v0.0.17

func OverrideKubernetesVersionFromManagedClusterSpecFile(cfg *config.Config, path string) (changed bool, oldVersion, newVersion string, err error)

OverrideKubernetesVersionFromManagedClusterSpecFile loads the spec snapshot from the given file path and overwrites cfg.Kubernetes.Version if a desired Kubernetes version is present.

func RemoveManagedClusterSpecSnapshot added in v0.0.17

func RemoveManagedClusterSpecSnapshot() (removed bool, err error)

RemoveManagedClusterSpecSnapshot removes the managed cluster spec snapshot file.

It returns (removed=false, err=nil) when the file does not exist.

func RemoveManagedClusterSpecSnapshotAtPath added in v0.0.17

func RemoveManagedClusterSpecSnapshotAtPath(path string) (removed bool, err error)

RemoveManagedClusterSpecSnapshotAtPath removes the managed cluster spec snapshot file at the given path.

It returns (removed=false, err=nil) when the file does not exist.

Types

type ManagedClusterClient

type ManagedClusterClient interface {
	Get(ctx context.Context, resourceGroupName, resourceName string, options *armcontainerservice.ManagedClustersClientGetOptions) (armcontainerservice.ManagedClustersClientGetResponse, error)
}

ManagedClusterClient is the subset of the Azure SDK managed clusters client we need. It exists to allow lightweight mocking in unit tests.

type ManagedClusterSpec

type ManagedClusterSpec struct {
	SchemaVersion int `json:"schemaVersion"`

	ClusterResourceID string `json:"clusterResourceId,omitempty"`
	ClusterName       string `json:"clusterName,omitempty"`
	ResourceGroup     string `json:"resourceGroup,omitempty"`

	// KubernetesVersion is kept as a first-class field because many components care about it.
	KubernetesVersion        string `json:"kubernetesVersion,omitempty"`        // "e.g., 1.32"
	CurrentKubernetesVersion string `json:"currentKubernetesVersion,omitempty"` // "e.g., 1.32.7"
	Fqdn                     string `json:"fqdn,omitempty"`

	// metadata
	CollectedAt time.Time `json:"collectedAt"`
}

ManagedClusterSpec is the persisted spec snapshot of the target AKS managed cluster. It is intentionally extensible so we can add more fields over time without rewriting the collector.

func LoadManagedClusterSpec added in v0.0.17

func LoadManagedClusterSpec() (*ManagedClusterSpec, error)

LoadManagedClusterSpec loads the managed cluster spec snapshot from the default path.

func LoadManagedClusterSpecFromFile added in v0.0.17

func LoadManagedClusterSpecFromFile(path string) (*ManagedClusterSpec, error)

LoadManagedClusterSpecFromFile loads the managed cluster spec snapshot from a JSON file.

type ManagedClusterSpecCollector

type ManagedClusterSpecCollector struct {
	// contains filtered or unexported fields
}

ManagedClusterSpecCollector collects spec from the target AKS managed cluster and persists it to a local file for later checking.

func NewManagedClusterSpecCollector

func NewManagedClusterSpecCollector(cfg *config.Config, logger *logrus.Logger) *ManagedClusterSpecCollector

NewManagedClusterSpecCollector creates a collector that writes to the default spec path. The Azure client is created lazily on the first Collect call.

func NewManagedClusterSpecCollectorWithClient

func NewManagedClusterSpecCollectorWithClient(cfg *config.Config, logger *logrus.Logger, client ManagedClusterClient, outputPath string) *ManagedClusterSpecCollector

NewManagedClusterSpecCollectorWithClient allows injecting a ManagedClusterClient and output path (primarily for tests).

func (*ManagedClusterSpecCollector) AddEnricher

AddEnricher appends a spec enricher.

func (*ManagedClusterSpecCollector) Collect

Collect queries the Azure managed cluster resource to retrieve a spec snapshot. It writes a JSON payload to the configured output path and returns the collected spec.

type ManagedClusterSpecEnricher

type ManagedClusterSpecEnricher func(spec *ManagedClusterSpec, resp armcontainerservice.ManagedClustersClientGetResponse) error

ManagedClusterSpecEnricher enriches the collected spec snapshot based on the managed cluster response. It enables adding more spec signals in the future without changing the collector control-flow.

Jump to

Keyboard shortcuts

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