Documentation
¶
Index ¶
- Constants
- func DesiredKubernetesVersion(specSnap *ManagedClusterSpec) string
- func GetManagedClusterSpecFilePath() string
- func GetSpecDir() string
- func ManagedClusterSpecFilePath(specDir string) string
- func OverrideKubernetesVersionFromManagedClusterSpec(cfg *config.Config) (changed bool, oldVersion, newVersion string, err error)
- func OverrideKubernetesVersionFromManagedClusterSpecFile(cfg *config.Config, path string) (changed bool, oldVersion, newVersion string, err error)
- func RemoveManagedClusterSpecSnapshot() (removed bool, err error)
- func RemoveManagedClusterSpecSnapshotAtPath(path string) (removed bool, err error)
- type ManagedClusterClient
- type ManagedClusterSpec
- type ManagedClusterSpecCollector
- type ManagedClusterSpecEnricher
Constants ¶
const (
// ManagedClusterSpecSchemaVersion is incremented when the persisted JSON schema changes.
ManagedClusterSpecSchemaVersion = 1
)
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:
- CurrentKubernetesVersion (typically a full patch version)
- KubernetesVersion (typically major.minor or a less specific version)
func GetManagedClusterSpecFilePath ¶
func GetManagedClusterSpecFilePath() string
GetManagedClusterSpecFilePath returns the path where the managed cluster spec snapshot is stored.
func GetSpecDir ¶
func GetSpecDir() string
GetSpecDir returns the appropriate directory for spec artifacts. Uses /run/aks-flex-node when running as systemd service (RuntimeDirectory creates this) Uses /tmp/aks-flex-node for direct user execution (testing/development)
func ManagedClusterSpecFilePath ¶ added in v0.0.17
ManagedClusterSpecFilePath returns the managed cluster spec snapshot file path under a provided directory.
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
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
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 ¶
func (c *ManagedClusterSpecCollector) AddEnricher(enricher ManagedClusterSpecEnricher)
AddEnricher appends a spec enricher.
func (*ManagedClusterSpecCollector) Collect ¶
func (c *ManagedClusterSpecCollector) Collect(ctx context.Context) (*ManagedClusterSpec, error)
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.