nodeagentautoscaler

package
v0.2.121 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ManagedByLabel is the label used to identify DaemonSets managed by the autoscaler
	ManagedByLabel = "kubescape.io/managed-by"
	// ManagedByValue is the value for the managed-by label
	ManagedByValue = "operator-autoscaler"
	// NodeGroupLabel is the label used to identify which node group a DaemonSet targets
	NodeGroupLabelKey = "kubescape.io/node-group"

	// ArgoCD annotations to prevent pruning of operator-managed resources
	ArgoCDCompareOptionsAnnotation = "argocd.argoproj.io/compare-options"
	ArgoCDSyncOptionsAnnotation    = "argocd.argoproj.io/sync-options"
)
View Source
const (
	EventReasonCreated = "Created"
	EventReasonDeleted = "Deleted"
	EventReasonFailed  = "Failed"
)

Event reasons for Kubernetes events

Variables

This section is empty.

Functions

func GenerateDaemonSetName

func GenerateDaemonSetName(group NodeGroup) string

GenerateDaemonSetName generates a DaemonSet name for a node group

Types

type Autoscaler

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

Autoscaler manages node-agent DaemonSets based on node groups

func NewAutoscaler

func NewAutoscaler(client kubernetes.Interface, cfg config.NodeAgentAutoscalerConfig, namespace string, operatorDeploymentName string) (*Autoscaler, error)

NewAutoscaler creates a new Autoscaler instance

func (*Autoscaler) Reconcile

func (a *Autoscaler) Reconcile(ctx context.Context) error

Reconcile performs a single reconciliation cycle

func (*Autoscaler) Start

func (a *Autoscaler) Start(ctx context.Context)

Start begins the autoscaler reconciliation loop

func (*Autoscaler) Stop

func (a *Autoscaler) Stop()

Stop stops the autoscaler

type CalculatedResources

type CalculatedResources struct {
	Requests ResourcePair
	Limits   ResourcePair
}

CalculatedResources represents the calculated resource requests and limits

type NodeGroup

type NodeGroup struct {
	// LabelValue is the value of the grouping label (e.g., "m5.large")
	LabelValue string
	// SanitizedName is a DNS-safe name derived from LabelValue
	SanitizedName string
	// AllocatableCPU is the representative allocatable CPU from nodes in this group
	AllocatableCPU resource.Quantity
	// AllocatableMemory is the representative allocatable memory from nodes in this group
	AllocatableMemory resource.Quantity
	// NodeCount is the number of nodes in this group
	NodeCount int
}

NodeGroup represents a group of nodes with the same label value

type NodeGrouper

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

NodeGrouper groups nodes by label and calculates resources

func NewNodeGrouper

func NewNodeGrouper(client kubernetes.Interface, cfg config.NodeAgentAutoscalerConfig, namespace string) *NodeGrouper

NewNodeGrouper creates a new NodeGrouper

func (*NodeGrouper) CalculateResources

func (ng *NodeGrouper) CalculateResources(group NodeGroup) (CalculatedResources, error)

CalculateResources calculates the resource requests and limits for a node group

func (*NodeGrouper) GetNodeGroups

func (ng *NodeGrouper) GetNodeGroups(ctx context.Context) ([]NodeGroup, error)

GetNodeGroups returns all node groups based on the configured label

type ResourcePair

type ResourcePair struct {
	CPU    resource.Quantity
	Memory resource.Quantity
}

ResourcePair holds CPU and Memory quantities

type TemplateData

type TemplateData struct {
	// Name is the DaemonSet name (e.g., "node-agent-m5-large")
	Name string
	// NodeGroupLabel is the value of the node group label
	NodeGroupLabel string
	// Resources contains the calculated resource requests and limits
	Resources TemplateResources
}

TemplateData holds the data used to render the DaemonSet template

type TemplateRenderer

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

TemplateRenderer loads and renders DaemonSet templates

func NewTemplateRenderer

func NewTemplateRenderer(templatePath string) (*TemplateRenderer, error)

NewTemplateRenderer creates a new TemplateRenderer

func (*TemplateRenderer) ReloadTemplate

func (tr *TemplateRenderer) ReloadTemplate() error

ReloadTemplate reloads the template from disk

func (*TemplateRenderer) RenderDaemonSet

func (tr *TemplateRenderer) RenderDaemonSet(group NodeGroup, resources CalculatedResources) (*appsv1.DaemonSet, error)

RenderDaemonSet renders a DaemonSet for the given node group and resources

func (*TemplateRenderer) StartWatching

func (tr *TemplateRenderer) StartWatching(ctx context.Context) error

StartWatching starts watching the template file for changes When the ConfigMap is updated, Kubernetes updates the mounted file, triggering a reload

func (*TemplateRenderer) StopWatching

func (tr *TemplateRenderer) StopWatching()

StopWatching stops the file watcher

type TemplateResourcePair

type TemplateResourcePair struct {
	CPU    string
	Memory string
}

TemplateResourcePair holds CPU and Memory as strings for template rendering

type TemplateResources

type TemplateResources struct {
	Requests TemplateResourcePair
	Limits   TemplateResourcePair
}

TemplateResources holds the resource values for template rendering

Jump to

Keyboard shortcuts

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