Documentation
¶
Index ¶
- type Cache
- type CostAnalysis
- type CostAnalyzer
- type CostBreakdown
- type DescribeOptions
- type EKSAPI
- type InstanceDetails
- type ListOptions
- type NodegroupDetails
- type NodegroupSummary
- type ScaleOptions
- type ScalingConfig
- type Service
- type ServiceImpl
- func (s *ServiceImpl) Describe(ctx context.Context, clusterName, nodegroupName string, ...) (*NodegroupDetails, error)
- func (s *ServiceImpl) List(ctx context.Context, clusterName string, options ListOptions) ([]NodegroupSummary, error)
- func (s *ServiceImpl) Scale(ctx context.Context, clusterName, nodegroupName string, ...) error
- type SummaryCost
- type SummaryMetrics
- type UtilizationCollector
- func (u *UtilizationCollector) CollectAllMetrics(ctx context.Context, instanceIDs []string, window string) UtilizationMetrics
- func (u *UtilizationCollector) CollectDiskForInstances(ctx context.Context, instanceIDs []string, window string) (UtilizationData, bool)
- func (u *UtilizationCollector) CollectEC2CPUForInstances(ctx context.Context, instanceIDs []string, window string) (UtilizationData, bool)
- func (u *UtilizationCollector) CollectMemoryForInstances(ctx context.Context, instanceIDs []string, window string) (UtilizationData, bool)
- func (u *UtilizationCollector) CollectNetworkForInstances(ctx context.Context, instanceIDs []string, window string) (UtilizationData, bool)
- type UtilizationData
- type UtilizationMetrics
- type WorkloadInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 (*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). It queries the Pricing API first, then falls back to the static price map.
func (*CostAnalyzer) GetFallbackPrice ¶ added in v0.4.0
func (c *CostAnalyzer) GetFallbackPrice(instanceType string) (perHour float64, perMonth float64, ok bool)
GetFallbackPrice returns a static price when API is unavailable
func (*CostAnalyzer) SetEC2Client ¶ added in v0.4.0
func (c *CostAnalyzer) SetEC2Client(ec2Client *ec2.Client)
SetEC2Client sets the EC2 client for spot pricing queries
type CostBreakdown ¶
type CostBreakdown struct{}
CostBreakdown holds itemized cost components for a nodegroup. Fields will be populated as Cost Explorer integration is added.
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 EC2 instance backing a nodegroup.
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"`
}
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 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
}
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 single nodegroup.
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) CollectAllMetrics ¶ added in v0.4.0
func (u *UtilizationCollector) CollectAllMetrics(ctx context.Context, instanceIDs []string, window string) UtilizationMetrics
CollectAllMetrics collects CPU, memory, network, and disk metrics for instances
func (*UtilizationCollector) CollectDiskForInstances ¶ added in v0.4.0
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.0
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.0
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