Documentation ¶
Index ¶
- Constants
- func CalculateUsage(clusterInfo *structs.ClusterCapacity)
- func Deregister(node string, nodeRegistry *structs.NodeRegistry) (err error)
- func DescribeAWSRegion() (region string, err error)
- func DescribeScalingGroup(asgName string, svc *autoscaling.AutoScaling) (asg *autoscaling.DescribeAutoScalingGroupsOutput, err error)
- func DetachInstance(asgName, instanceID string, svc *autoscaling.AutoScaling) (err error)
- func GetMostRecentInstance(autoscalingGroup, region string) (node string, err error)
- func MaxAllowedClusterUtilization(capacity *structs.ClusterCapacity, nodeFaultTolerance int, scaleIn bool) (maxAllowedUtilization int)
- func NewAWSAsgService(region string) (Session *autoscaling.AutoScaling)
- func NewConsulClient(addr, token string) (structs.ConsulClient, error)
- func NewNomadClient(addr string) (structs.NomadClient, error)
- func NodeRegistryUpdated(nodeRegistry *structs.NodeRegistry) (updated bool)
- func ProcessNodeConfig(node *nomad.Node) (pool *structs.WorkerPool, err error)
- func Register(node *nomad.Node, workerPool *structs.WorkerPool, ...) (err error)
- func RemoveJobScalingPolicy(jobName string, scaling *structs.JobScalingPolicies)
- func ScaleInCluster(asgName, instanceIP string, svc *autoscaling.AutoScaling) error
- func ScaleOutCluster(asgName string, nodeCount int, svc *autoscaling.AutoScaling) error
- func TerminateInstance(instanceID, region string) error
- func TranslateIptoID(ip, region string) (id string)
Constants ¶
const ( ScalingMetricNone = "None" // All supported allocation resources are unutilized. ScalingMetricDisk = "Disk" ScalingMetricMemory = "Memory" ScalingMetricProcessor = "CPU" )
Scaling metric types indicate the most-utilized resource across the cluster. When evaluating scaling decisions, the most-utilized resource will be prioritized.
const ( ScalingDirectionOut = "Out" ScalingDirectionIn = "In" ScalingDirectionNone = "None" )
Scaling direction types indicate the allowed scaling actions.
const ( StatePending = "pending" StateRunning = "running" StateDead = "dead" )
Set of possible states for a job.
Variables ¶
This section is empty.
Functions ¶
func CalculateUsage ¶
func CalculateUsage(clusterInfo *structs.ClusterCapacity)
CalculateUsage computes the percentage of overall worker pool capacity consumed and computes the amount of that capacity consumed by each node.
func Deregister ¶ added in v1.0.0
func Deregister(node string, nodeRegistry *structs.NodeRegistry) (err error)
Deregister is responsible for removing a node from a worker pool record. If after node deregistration, a worker pool has no remaining nodes, the worker pool is removed from the node registry.
func DescribeAWSRegion ¶
DescribeAWSRegion uses the EC2 InstanceMetaData endpoint to discover the AWS region in which the instance is running.
func DescribeScalingGroup ¶
func DescribeScalingGroup(asgName string, svc *autoscaling.AutoScaling) (asg *autoscaling.DescribeAutoScalingGroupsOutput, err error)
DescribeScalingGroup returns the AWS ASG information of the specified ASG.
func DetachInstance ¶
func DetachInstance(asgName, instanceID string, svc *autoscaling.AutoScaling) (err error)
DetachInstance will detach a specified instance from a specified ASG and decrements the desired count of the ASG.
func GetMostRecentInstance ¶
GetMostRecentInstance identifies the most recently launched instance in a specified autoscaling group.
func MaxAllowedClusterUtilization ¶
func MaxAllowedClusterUtilization(capacity *structs.ClusterCapacity, nodeFaultTolerance int, scaleIn bool) (maxAllowedUtilization int)
MaxAllowedClusterUtilization calculates the maximum allowed cluster utilization after taking into consideration node fault-tolerance and scaling overhead.
func NewAWSAsgService ¶
func NewAWSAsgService(region string) (Session *autoscaling.AutoScaling)
NewAWSAsgService creates a new AWS API Session and ASG service connection for use across all calls as required.
func NewConsulClient ¶
func NewConsulClient(addr, token string) (structs.ConsulClient, error)
NewConsulClient is used to construct a new Consul client using the default configuration and supporting the ability to specify a Consul API address endpoint in the form of address:port.
func NewNomadClient ¶
func NewNomadClient(addr string) (structs.NomadClient, error)
NewNomadClient is used to create a new client to interact with Nomad. The client implements the NomadClient interface.
func NodeRegistryUpdated ¶ added in v1.0.0
func NodeRegistryUpdated(nodeRegistry *structs.NodeRegistry) (updated bool)
NodeRegistryUpdated determines if the node registry has been updated and manages updating the node hash.
func ProcessNodeConfig ¶ added in v1.0.0
func ProcessNodeConfig(node *nomad.Node) (pool *structs.WorkerPool, err error)
ProcessNodeConfig retrieves detailed information about a node and processes configuration details. If the meta configuration parameters required for scaling and identification of the associated worker pool are successfully processed, they are returned.
func Register ¶ added in v1.0.0
func Register(node *nomad.Node, workerPool *structs.WorkerPool, nodeRegistry *structs.NodeRegistry) (err error)
Register is responsible for registering a newly discovered worker pool or registering a node with an previously discovered worker pool.
func RemoveJobScalingPolicy ¶ added in v1.0.0
func RemoveJobScalingPolicy(jobName string, scaling *structs.JobScalingPolicies)
RemoveJobScalingPolicy deletes the job entry within the the policies map.
func ScaleInCluster ¶
func ScaleInCluster(asgName, instanceIP string, svc *autoscaling.AutoScaling) error
ScaleInCluster scales the cluster size by 1 by using the DetachInstances call to target an instance to remove from the ASG.
func ScaleOutCluster ¶
func ScaleOutCluster(asgName string, nodeCount int, svc *autoscaling.AutoScaling) error
ScaleOutCluster scales the Nomad worker pool by 1 instance, using the current configuration as the basis for undertaking the work.
func TerminateInstance ¶
TerminateInstance will terminate the supplied EC2 instance and confirm successful termination by polling the instance state until the terminated status is reached.
func TranslateIptoID ¶
TranslateIptoID translates the IP address of a node to the EC2 instance ID.
Types ¶
This section is empty.