lib

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2023 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

View Source
const (
	SingleCPUUnits int64 = 1024
	MbInGb         int64 = 1024
	AgentSize      int64 = 39 // memory consumed by the ECS agent
)

Variables

View Source
var InstanceTypes = map[string]InstanceType{
	"t2.nano": {
		CPUUnits: 1 * SingleCPUUnits,
		MemoryMb: MbInGb/2 - AgentSize,
	},
	"t2.micro": {
		CPUUnits: 1 * SingleCPUUnits,
		MemoryMb: 1*MbInGb - AgentSize,
	},
	"t2.small": {
		CPUUnits: 1 * SingleCPUUnits,
		MemoryMb: 2*MbInGb - AgentSize,
	},
	"t2.medium": {
		CPUUnits: 2 * SingleCPUUnits,
		MemoryMb: 4*MbInGb - AgentSize,
	},
	"t2.large": {
		CPUUnits: 2 * SingleCPUUnits,
		MemoryMb: 8*MbInGb - AgentSize,
	},
	"t2.xlarge": {
		CPUUnits: 4 * SingleCPUUnits,
		MemoryMb: 16*MbInGb - AgentSize,
	},
	"t2.2xlarge": {
		CPUUnits: 8 * SingleCPUUnits,
		MemoryMb: 32*MbInGb - AgentSize,
	},
	"t3.nano": {
		CPUUnits: 2 * SingleCPUUnits,
		MemoryMb: MbInGb/2 - AgentSize,
	},
	"t3.micro": {
		CPUUnits: 2 * SingleCPUUnits,
		MemoryMb: 1*MbInGb - AgentSize,
	},
	"t3.small": {
		CPUUnits: 2 * SingleCPUUnits,
		MemoryMb: 2*MbInGb - AgentSize,
	},
	"t3.medium": {
		CPUUnits: 2 * SingleCPUUnits,
		MemoryMb: 4*MbInGb - AgentSize,
	},
	"t3.large": {
		CPUUnits: 2 * SingleCPUUnits,
		MemoryMb: 8*MbInGb - AgentSize,
	},
	"t3.xlarge": {
		CPUUnits: 4 * SingleCPUUnits,
		MemoryMb: 16*MbInGb - AgentSize,
	},
	"t3.2xlarge": {
		CPUUnits: 8 * SingleCPUUnits,
		MemoryMb: 32*MbInGb - AgentSize,
	},
}

Functions

func DescribeEcsServicesForArns

func DescribeEcsServicesForArns(awsSess *session.Session, serviceArns []*string, cluster string) ([]*ecs.Service, error)

func DetachAndReplaceAsgInstances

func DetachAndReplaceAsgInstances(awsSess *session.Session, asgName string, instancesToTerminate []*string)

func GetAsg

func GetAsg(awsSess *session.Session, asgName string) *autoscaling.Group

func GetAsgNameForEcsCluster

func GetAsgNameForEcsCluster(awsSess *session.Session, cluster string) string

func GetAsgServerCount

func GetAsgServerCount(awsSess *session.Session, asgName string) (desired int64, min int64, max int64)

func GetInstanceIDsForEcsCluster

func GetInstanceIDsForEcsCluster(awsSess *session.Session, clusterName string) []*string

func GetInstanceIPsForEcsCluster

func GetInstanceIPsForEcsCluster(awsSess *session.Session, clusterName string) []string

func GetInstanceListForAsg

func GetInstanceListForAsg(awsSess *session.Session, asgName string) []*string

func GetInstanceListForEcsCluster

func GetInstanceListForEcsCluster(awsSess *session.Session, clusterName string) []*ecs.ContainerInstance

func GetInstanceTypeForAsg

func GetInstanceTypeForAsg(awsSess *session.Session, asgName string) string

func GetInstanceTypeFromLaunchConfiguration

func GetInstanceTypeFromLaunchConfiguration(awsSess *session.Session, launchConfigurationName string) string

func GetInstanceTypeFromLaunchTemplate

func GetInstanceTypeFromLaunchTemplate(awsSess *session.Session, launchTemplateName string) string

func GetLargestDesiredCountFromEcsServices

func GetLargestDesiredCountFromEcsServices(ecsServices []*ecs.Service) int64

func GetPendingEcsTasksCount

func GetPendingEcsTasksCount(awsSess *session.Session, cluster string) int64

func HowManyServersNeededForAsg

func HowManyServersNeededForAsg(serverType string, resourcesNeeded ResourceSizes) int64

HowManyServersNeededForAsg computes the theoretical number of servers needed based on the total resources needed, assuming near-perfect utilization of server resources. It does not take into account the "wasted" resources on an individual server when the free resources are not sufficient to place any of the desired containers.

func LambdaInvoke

func LambdaInvoke(awsSess *session.Session, functionName, payload string) (*lambda.InvokeOutput, error)

func ListServicesForEcsCluster

func ListServicesForEcsCluster(awsSess *session.Session, cluster string) []*ecs.Service

func RightSizeAsgForEcsCluster

func RightSizeAsgForEcsCluster(awsSess *session.Session, cluster string, atLeastServiceDesiredCount bool) error

func UpdateAsgServerCount

func UpdateAsgServerCount(awsSess *session.Session, asgName string, serverCount int64) error

Types

type InstanceType

type InstanceType struct {
	MemoryMb int64
	CPUUnits int64
}

type ResourceSizes added in v0.2.0

type ResourceSizes struct {
	TotalCPU       int64
	TotalMemory    int64
	LargestCPU     int64
	LargestMemory  int64
	SmallestCPU    int64
	SmallestMemory int64
}

func GetMemoryCpuNeededForEcsServices

func GetMemoryCpuNeededForEcsServices(awsSess *session.Session, ecsServices []*ecs.Service) ResourceSizes

Jump to

Keyboard shortcuts

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