nodegroup

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ASGClient added in v0.4.1

type ASGClient interface {
	DescribeAutoScalingGroups(ctx context.Context, params *autoscaling.DescribeAutoScalingGroupsInput, optFns ...func(*autoscaling.Options)) (*autoscaling.DescribeAutoScalingGroupsOutput, error)
}

ASGClient abstracts autoscaling client methods needed for recommendations

type Cache

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

func NewCache

func NewCache() *Cache

func (*Cache) Get

func (c *Cache) Get(key string) (any, bool)

func (*Cache) Set

func (c *Cache) Set(key string, value any, ttl time.Duration)

type CostAnalysis

type CostAnalysis struct {
	CurrentMonthlyCost    float64       `json:"currentMonthlyCost"`
	ProjectedMonthlyCost  float64       `json:"projectedMonthlyCost"`
	CostPerNode           float64       `json:"costPerNode"`
	CostBreakdown         CostBreakdown `json:"costBreakdown"`
	OptimizationPotential float64       `json:"optimizationPotential"`
}

CostAnalysis captures high-level cost data and potential

type CostAnalyzer

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

func NewCostAnalyzer

func NewCostAnalyzer(p *pricing.Client, logger *slog.Logger, cache *Cache, region string) *CostAnalyzer

func (*CostAnalyzer) CalculateSpotSavings added in v0.4.1

func (c *CostAnalyzer) CalculateSpotSavings(ctx context.Context, instanceType string) (savingsPercent float64, ok bool)

CalculateSpotSavings compares on-demand vs spot pricing and returns savings percentage

func (*CostAnalyzer) CompareCosts added in v0.4.1

func (c *CostAnalyzer) CompareCosts(ctx context.Context, instanceType string, nodeCount int) (*CostComparison, error)

CompareCosts provides a full comparison between on-demand and spot pricing

func (*CostAnalyzer) EstimateOnDemandUSD

func (c *CostAnalyzer) EstimateOnDemandUSD(ctx context.Context, instanceType string) (perHour float64, perMonth float64, ok bool)

EstimateOnDemandUSD returns monthly and per-hour costs for an instance type (Linux/on-demand)

func (*CostAnalyzer) EstimateSpotUSD added in v0.4.1

func (c *CostAnalyzer) EstimateSpotUSD(ctx context.Context, instanceType string) (perHour float64, perMonth float64, ok bool)

EstimateSpotUSD returns current spot price for an instance type

func (*CostAnalyzer) GetFallbackPrice added in v0.4.1

func (c *CostAnalyzer) GetFallbackPrice(instanceType string) (perHour float64, perMonth float64, ok bool)

GetFallbackPrice returns a static price when API is unavailable

func (*CostAnalyzer) GetSpotPricesByAZ added in v0.4.1

func (c *CostAnalyzer) GetSpotPricesByAZ(ctx context.Context, instanceType string) ([]SpotPriceResult, error)

GetSpotPricesByAZ returns spot prices broken down by availability zone

func (*CostAnalyzer) SetEC2Client added in v0.4.1

func (c *CostAnalyzer) SetEC2Client(ec2Client *ec2.Client)

SetEC2Client sets the EC2 client for spot pricing queries

type CostBreakdown

type CostBreakdown struct{}

CostBreakdown is a placeholder for future detailed cost components

type CostComparison added in v0.4.1

type CostComparison struct {
	InstanceType        string  `json:"instanceType"`
	OnDemandHourly      float64 `json:"onDemandHourly"`
	OnDemandMonthly     float64 `json:"onDemandMonthly"`
	SpotHourly          float64 `json:"spotHourly"`
	SpotMonthly         float64 `json:"spotMonthly"`
	SavingsPercent      float64 `json:"savingsPercent"`
	EstimatedRisk       string  `json:"estimatedRisk"` // low, medium, high based on spot frequency
	RecommendedCapacity string  `json:"recommendedCapacity"`
}

CostComparison contains a full cost comparison between capacity types

type DescribeOptions

type DescribeOptions struct {
	ShowInstances    bool   `json:"showInstances"`
	ShowUtilization  bool   `json:"showUtilization"`
	ShowWorkloads    bool   `json:"showWorkloads"`
	ShowCosts        bool   `json:"showCosts"`
	ShowOptimization bool   `json:"showOptimization"`
	Timeframe        string `json:"timeframe"`
}

DescribeOptions controls describe behavior for nodegroups

type EKSAPI

type EKSAPI interface {
	ListNodegroups(ctx context.Context, params *eks.ListNodegroupsInput, optFns ...func(*eks.Options)) (*eks.ListNodegroupsOutput, error)
	DescribeNodegroup(ctx context.Context, params *eks.DescribeNodegroupInput, optFns ...func(*eks.Options)) (*eks.DescribeNodegroupOutput, error)
	DescribeCluster(ctx context.Context, params *eks.DescribeClusterInput, optFns ...func(*eks.Options)) (*eks.DescribeClusterOutput, error)
	UpdateNodegroupConfig(ctx context.Context, params *eks.UpdateNodegroupConfigInput, optFns ...func(*eks.Options)) (*eks.UpdateNodegroupConfigOutput, error)
}

EKSAPI abstracts the subset of EKS client methods used for nodegroups

type InstanceDetails

type InstanceDetails struct {
	InstanceID   string    `json:"instanceId"`
	InstanceType string    `json:"instanceType"`
	LaunchTime   time.Time `json:"launchTime"`
	Lifecycle    string    `json:"lifecycle"` // on-demand, spot
	State        string    `json:"state"`
	AZ           string    `json:"availabilityZone"`
}

InstanceDetails describes an instance in a nodegroup (placeholder for now)

type ListOptions

type ListOptions struct {
	ShowHealth      bool              `json:"showHealth"`
	ShowCosts       bool              `json:"showCosts"`
	ShowUtilization bool              `json:"showUtilization"`
	ShowInstances   bool              `json:"showInstances"`
	Filters         map[string]string `json:"filters"`
	Timeframe       string            `json:"timeframe"`
}

ListOptions controls nodegroup listing behavior

type NodegroupAnalysisData added in v0.4.1

type NodegroupAnalysisData struct {
	Name         string
	InstanceType string
	DesiredSize  int32
	MinSize      int32
	MaxSize      int32
	CapacityType string
	Instances    []InstanceDetails
	CPUUtil      UtilizationData
	HasCPUData   bool
	HourlyCost   float64
	MonthlyCost  float64
	HasCostData  bool
}

NodegroupAnalysisData contains data collected for analysis

type NodegroupDetails

type NodegroupDetails struct {
	Name         string `json:"name"`
	Status       string `json:"status"`
	InstanceType string `json:"instanceType"`
	AmiType      string `json:"amiType"`
	CapacityType string `json:"capacityType"` // ON_DEMAND, SPOT

	// AMI information - core functionality of refresh tool
	CurrentAMI string          `json:"currentAmi"`
	LatestAMI  string          `json:"latestAmi"`
	AMIStatus  types.AMIStatus `json:"amiStatus"`

	Scaling     ScalingConfig        `json:"scaling"`
	Health      *health.HealthStatus `json:"health,omitempty"`
	Utilization UtilizationMetrics   `json:"utilization"`
	Cost        CostAnalysis         `json:"costAnalysis"`

	Instances []InstanceDetails `json:"instances"`
	Workloads WorkloadInfo      `json:"workloads"`

	Recommendations []Recommendation `json:"recommendations,omitempty"`
}

NodegroupDetails extends summary with health, cost, and optional instance/workload details

type NodegroupSummary

type NodegroupSummary struct {
	Name         string `json:"name"`
	Status       string `json:"status"`
	InstanceType string `json:"instanceType"`
	DesiredSize  int32  `json:"desiredSize"`
	ReadyNodes   int32  `json:"readyNodes"`
	// AMI information - core functionality of refresh tool
	CurrentAMI string          `json:"currentAmi"`
	AMIStatus  types.AMIStatus `json:"amiStatus"`
	// Optional enrichments for list output
	Metrics SummaryMetrics `json:"metrics,omitempty"`
	Cost    SummaryCost    `json:"cost,omitempty"`
}

NodegroupSummary contains basic nodegroup info for listings

type Recommendation

type Recommendation struct {
	Type            string  `json:"type"`     // right-size, spot-integration, scaling
	Priority        string  `json:"priority"` // high, medium, low
	Impact          string  `json:"impact"`   // cost, performance, reliability
	Description     string  `json:"description"`
	Implementation  string  `json:"implementation"`
	ExpectedSavings float64 `json:"expectedSavings"`
	RiskLevel       string  `json:"riskLevel"`
}

Recommendation proposes an optimization or action

type RecommendationOptions

type RecommendationOptions struct {
	Nodegroup               string `json:"nodegroup"`
	CostOptimization        bool   `json:"costOptimization"`
	PerformanceOptimization bool   `json:"performanceOptimization"`
	SpotAnalysis            bool   `json:"spotAnalysis"`
	RightSizing             bool   `json:"rightSizing"`
	Timeframe               string `json:"timeframe"` // 7d, 30d, 90d
}

RecommendationOptions controls recommendation analysis

type RecommendationsAnalyzer added in v0.4.1

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

RecommendationsAnalyzer generates optimization recommendations for nodegroups

func NewRecommendationsAnalyzer added in v0.4.1

func NewRecommendationsAnalyzer(eksClient EKSAPI, ec2Client *ec2.Client, asgClient ASGClient, util *UtilizationCollector, cost *CostAnalyzer, logger *slog.Logger, cache *Cache) *RecommendationsAnalyzer

NewRecommendationsAnalyzer creates a new analyzer

func (*RecommendationsAnalyzer) AnalyzeNodegroups added in v0.4.1

func (a *RecommendationsAnalyzer) AnalyzeNodegroups(ctx context.Context, clusterName string, options RecommendationOptions) ([]Recommendation, error)

AnalyzeNodegroups generates recommendations based on actual cluster data

type ScaleOptions

type ScaleOptions struct {
	HealthCheck bool          `json:"healthCheck"`
	CheckPDBs   bool          `json:"checkPdbs"`
	Wait        bool          `json:"wait"`
	Timeout     time.Duration `json:"timeout"`
	DryRun      bool          `json:"dryRun"`
}

ScaleOptions controls intelligent scaling behavior

type ScalingConfig

type ScalingConfig struct {
	DesiredSize int32 `json:"desiredSize"`
	MinSize     int32 `json:"minSize"`
	MaxSize     int32 `json:"maxSize"`
	AutoScaling bool  `json:"autoScaling"`
}

ScalingConfig models the EKS managed nodegroup scaling configuration

type Service

type Service interface {
	List(ctx context.Context, clusterName string, options ListOptions) ([]NodegroupSummary, error)
	Describe(ctx context.Context, clusterName, nodegroupName string, options DescribeOptions) (*NodegroupDetails, error)
	Scale(ctx context.Context, clusterName, nodegroupName string, desired, min, max *int32, options ScaleOptions) error
	GetRecommendations(ctx context.Context, clusterName string, options RecommendationOptions) ([]Recommendation, error)
}

Service defines nodegroup operations

type ServiceImpl

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

ServiceImpl implements Service

func NewService

func NewService(awsConfig aws.Config, healthChecker *health.HealthChecker, logger *slog.Logger) *ServiceImpl

NewService creates a new nodegroup service

func (*ServiceImpl) Describe

func (s *ServiceImpl) Describe(ctx context.Context, clusterName, nodegroupName string, options DescribeOptions) (*NodegroupDetails, error)

Describe returns expanded details for a nodegroup (minimal for now)

func (*ServiceImpl) GetRecommendations

func (s *ServiceImpl) GetRecommendations(ctx context.Context, clusterName string, options RecommendationOptions) ([]Recommendation, error)

GetRecommendations analyzes nodegroups and returns actionable recommendations

func (*ServiceImpl) List

func (s *ServiceImpl) List(ctx context.Context, clusterName string, options ListOptions) ([]NodegroupSummary, error)

List returns basic nodegroup summaries for a cluster

func (*ServiceImpl) Scale

func (s *ServiceImpl) Scale(ctx context.Context, clusterName, nodegroupName string, desired, min, max *int32, options ScaleOptions) error

Scale updates the desired/min/max size for a nodegroup

type SpotPriceResult added in v0.4.1

type SpotPriceResult struct {
	InstanceType     string    `json:"instanceType"`
	AvailabilityZone string    `json:"availabilityZone"`
	SpotPrice        float64   `json:"spotPrice"`
	Timestamp        time.Time `json:"timestamp"`
}

SpotPriceResult contains spot pricing information

type SummaryCost

type SummaryCost struct {
	Monthly float64 `json:"monthly"`
}

SummaryCost contains lightweight cost info for list views

type SummaryMetrics

type SummaryMetrics struct {
	CPU float64 `json:"cpu"` // percent 0-100
}

SummaryMetrics contains lightweight metrics for list views

type UtilizationCollector

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

func NewUtilizationCollector

func NewUtilizationCollector(cw *cloudwatch.Client, logger *slog.Logger, cache *Cache) *UtilizationCollector

func (*UtilizationCollector) CollectAllMetrics added in v0.4.1

func (u *UtilizationCollector) CollectAllMetrics(ctx context.Context, instanceIDs []string, window string) UtilizationMetrics

CollectAllMetrics collects CPU, memory, network, and disk metrics for instances

func (*UtilizationCollector) CollectBasicCPU

func (u *UtilizationCollector) CollectBasicCPU(ctx context.Context, clusterName, nodegroupName, timeframe string) (UtilizationData, bool)

CollectBasicCPU returns a coarse CPU utilization over timeframe for a nodegroup (cluster-level namespace metric) This is a placeholder using a generic metric and will be refined later.

func (*UtilizationCollector) CollectDiskForInstances added in v0.4.1

func (u *UtilizationCollector) CollectDiskForInstances(ctx context.Context, instanceIDs []string, window string) (UtilizationData, bool)

CollectDiskForInstances collects disk utilization metrics (EBS)

func (*UtilizationCollector) CollectEC2CPUForInstances

func (u *UtilizationCollector) CollectEC2CPUForInstances(ctx context.Context, instanceIDs []string, window string) (UtilizationData, bool)

CollectEC2CPUForInstances aggregates EC2 CPUUtilization for instance IDs over a short window

func (*UtilizationCollector) CollectMemoryForInstances added in v0.4.1

func (u *UtilizationCollector) CollectMemoryForInstances(ctx context.Context, instanceIDs []string, window string) (UtilizationData, bool)

CollectMemoryForInstances collects memory utilization using CloudWatch agent metrics Note: This requires CloudWatch agent to be installed and configured on nodes

func (*UtilizationCollector) CollectNetworkForInstances added in v0.4.1

func (u *UtilizationCollector) CollectNetworkForInstances(ctx context.Context, instanceIDs []string, window string) (UtilizationData, bool)

CollectNetworkForInstances collects network utilization metrics

type UtilizationData

type UtilizationData struct {
	Current float64 `json:"current"`
	Average float64 `json:"average"`
	Peak    float64 `json:"peak"`
	Trend   string  `json:"trend"` // increasing, stable, decreasing
}

UtilizationData represents a simple utilization snapshot/trend

type UtilizationMetrics

type UtilizationMetrics struct {
	CPU       UtilizationData `json:"cpu"`
	Memory    UtilizationData `json:"memory"`
	Network   UtilizationData `json:"network"`
	Storage   UtilizationData `json:"storage"`
	TimeRange string          `json:"timeRange"`
}

UtilizationMetrics groups major resource utilization metrics

type WorkloadInfo

type WorkloadInfo struct {
	TotalPods     int    `json:"totalPods"`
	CriticalPods  int    `json:"criticalPods"`
	PodDisruption string `json:"podDisruption"` // summarized for now
}

WorkloadInfo summarizes pods/workloads placed on a nodegroup

Jump to

Keyboard shortcuts

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