nodegroup

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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) 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)

type CostBreakdown

type CostBreakdown struct{}

CostBreakdown is a placeholder for future detailed cost components

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 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 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 returns placeholder recommendations until analyzers are implemented

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 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) 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) 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

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