Documentation ¶
Index ¶
- Constants
- func FilterNodes(n []*api.NodeListStub, idFn func(*api.NodeListStub) bool) ([]*api.NodeListStub, error)
- type ClusterNodeIDLookupFunc
- type ClusterScaleInNodeIDStrategy
- type ClusterScaleUtils
- func (c *ClusterScaleUtils) DrainNodes(ctx context.Context, cfg map[string]string, nodes []NodeResourceID) error
- func (c *ClusterScaleUtils) IdentifyScaleInNodes(cfg map[string]string, num int) ([]*api.NodeListStub, error)
- func (c *ClusterScaleUtils) IdentifyScaleInRemoteIDs(nodes []*api.NodeListStub) ([]NodeResourceID, error)
- func (c *ClusterScaleUtils) IsPoolReady(cfg map[string]string) (bool, error)
- func (c *ClusterScaleUtils) RunPostScaleInTasks(_ context.Context, cfg map[string]string, ids []NodeResourceID) error
- func (c *ClusterScaleUtils) RunPostScaleInTasksOnFailure(nodes []NodeResourceID) error
- func (c *ClusterScaleUtils) RunPreScaleInTasks(ctx context.Context, cfg map[string]string, num int) ([]NodeResourceID, error)
- func (c *ClusterScaleUtils) RunPreScaleInTasksWithRemoteCheck(ctx context.Context, cfg map[string]string, remoteIDs []string, num int) ([]NodeResourceID, error)
- func (c *ClusterScaleUtils) SelectScaleInNodes(nodes []*api.NodeListStub, cfg map[string]string, num int) ([]*api.NodeListStub, error)
- type IdentifierKey
- type NodeID
- type NodeIDStrategy
- type NodeResourceID
- type PoolIdentifier
- type RemoteProvider
- type ScaleIn
- type ScaleInReq
Constants ¶
const ( // Deprecated. Please use defaultNodeDrainDeadline. // // DefaultDrainDeadline is the drainSpec deadline used if one is not // specified by an operator. DefaultDrainDeadline = 15 * time.Minute // Deprecated. Please use defaultNodeIgnoreSystemJobs. DefaultIgnoreSystemJobs = false )
Variables ¶
This section is empty.
Functions ¶
func FilterNodes ¶ added in v0.3.0
func FilterNodes(n []*api.NodeListStub, idFn func(*api.NodeListStub) bool) ([]*api.NodeListStub, error)
FilterNodes returns a filtered list of nodes which are active in the cluster and where they pass the match performed by the idFn. In the event that nodes are found within the pool in an unstable state, and thus indicating there is change occurring; an error will be returned.
Types ¶
type ClusterNodeIDLookupFunc ¶ added in v0.3.0
ClusterNodeIDLookupFunc is the callback function signature used to identify a nodes remote ID from the api.Node object. This allows the function to be defined by external plugins.
type ClusterScaleInNodeIDStrategy ¶ added in v0.3.0
type ClusterScaleInNodeIDStrategy string
ClusterScaleInNodeIDStrategy identifies the method in which nodes are selected from the node pool for removal during scale in actions.
const ( // NewestCreateIndexClusterScaleInNodeIDStrategy uses the Nomad // Nodes().List() output in the order it is presented. This means we do not // need additional sorting and thus it is fastest. In an environment that // uses bin-packing this may also be preferable as nodes with older create // indexes are expected to be most packed. NewestCreateIndexClusterScaleInNodeIDStrategy ClusterScaleInNodeIDStrategy = "newest_create_index" )
type ClusterScaleUtils ¶ added in v0.3.0
type ClusterScaleUtils struct { // ClusterNodeIDLookupFunc is the callback function used to translate a // Nomad nodes ID to the remote resource ID used by the target platform. ClusterNodeIDLookupFunc ClusterNodeIDLookupFunc // contains filtered or unexported fields }
ClusterScaleUtils provides common functionality when performing horizontal cluster scaling evaluations and actions.
func NewClusterScaleUtils ¶ added in v0.3.0
NewClusterScaleUtils instantiates a new ClusterScaleUtils object for use.
func (*ClusterScaleUtils) DrainNodes ¶ added in v0.3.1
func (c *ClusterScaleUtils) DrainNodes(ctx context.Context, cfg map[string]string, nodes []NodeResourceID) error
DrainNodes iterates the provided nodeID list and performs a drain on each one. Each node drain is monitored and events logged until the context is closed or all drains reach a terminal state.
func (*ClusterScaleUtils) IdentifyScaleInNodes ¶ added in v0.3.1
func (c *ClusterScaleUtils) IdentifyScaleInNodes(cfg map[string]string, num int) ([]*api.NodeListStub, error)
func (*ClusterScaleUtils) IdentifyScaleInRemoteIDs ¶ added in v0.3.1
func (c *ClusterScaleUtils) IdentifyScaleInRemoteIDs(nodes []*api.NodeListStub) ([]NodeResourceID, error)
func (*ClusterScaleUtils) IsPoolReady ¶ added in v0.3.0
func (c *ClusterScaleUtils) IsPoolReady(cfg map[string]string) (bool, error)
IsPoolReady provides a method for understanding whether the node pool is in a state that allows it to be safely scaled. This should be used by target plugins when providing their status response. A non-nil error indicates there was a problem performing the check.
func (*ClusterScaleUtils) RunPostScaleInTasks ¶ added in v0.3.0
func (c *ClusterScaleUtils) RunPostScaleInTasks(_ context.Context, cfg map[string]string, ids []NodeResourceID) error
RunPostScaleInTasks triggers any tasks which should occur after the nodes have been terminated within the remote provider.
The context is currently ignored on purpose, pending investigation into plugging this into the Nomad API query meta.
func (*ClusterScaleUtils) RunPostScaleInTasksOnFailure ¶ added in v0.3.1
func (c *ClusterScaleUtils) RunPostScaleInTasksOnFailure(nodes []NodeResourceID) error
RunPostScaleInTasksOnFailure is a utility that runs tasks on nodes which were unable to be successfully terminated. The current tasks are:
- modify node eligibility to true
func (*ClusterScaleUtils) RunPreScaleInTasks ¶ added in v0.3.0
func (c *ClusterScaleUtils) RunPreScaleInTasks(ctx context.Context, cfg map[string]string, num int) ([]NodeResourceID, error)
RunPreScaleInTasks triggers all the tasks, including node identification and draining, required before terminating the nodes in the remote provider. COMPAT(0.4)
func (*ClusterScaleUtils) RunPreScaleInTasksWithRemoteCheck ¶ added in v0.3.4
func (c *ClusterScaleUtils) RunPreScaleInTasksWithRemoteCheck(ctx context.Context, cfg map[string]string, remoteIDs []string, num int) ([]NodeResourceID, error)
RunPreScaleInTasksWithRemoteCheck triggers all the tasks, including node identification, filtering by remote ID, and draining, required before terminating the nodes in the remote provider.
func (*ClusterScaleUtils) SelectScaleInNodes ¶ added in v0.3.4
func (c *ClusterScaleUtils) SelectScaleInNodes(nodes []*api.NodeListStub, cfg map[string]string, num int) ([]*api.NodeListStub, error)
type IdentifierKey ¶
type IdentifierKey string
Deprecated. Please use nodepool.ClusterNodePoolIdentifier.
IdentifierKey is the identifier to group nodes into a pool of resource and thus forms the scalable object.
const IdentifierKeyClass IdentifierKey = "class"
IdentifierKeyClass uses the Node.Class field to identify nodes into pools of resource. This is the default.
type NodeID ¶
type NodeID struct {
NomadID, RemoteID string
}
Deprecated. Please use NodeResourceID.
NodeID provides a mapping between the Nomad ID of a node and its remote infrastructure provider specific ID.
type NodeIDStrategy ¶
type NodeIDStrategy string
Deprecated. Please use ClusterScaleInNodeIDStrategy.
NodeIDStrategy is the strategy used to identify nodes for removal as part of scaling in.
const IDStrategyNewestCreateIndex NodeIDStrategy = "newest_create_index"
IDStrategyNewestCreateIndex uses the Nomad Nodes().List() output in the order it is presented. This means we do not need additional sorting and thus it is fastest. In an environment that uses bin-packing this may also be preferable as nodes with older create indexes are expected to be most packed.
type NodeResourceID ¶ added in v0.3.0
type NodeResourceID struct { // NomadNodeID is the ID as seen within the Nomad api.Node object. NomadNodeID string // RemoteResourceID is the remote resource ID of the server/instance such // as the AWS EC2 instance ID. RemoteResourceID string }
NodeResourceID maps a Nomad node ID to a remote resource ID.
type PoolIdentifier ¶
type PoolIdentifier struct { IdentifierKey IdentifierKey Value string }
Deprecated. Please use nodepool.ClusterNodePoolIdentifier.
PoolIdentifier is the information used to identify nodes into pools of resources. This then forms our scalable unit.
func (*PoolIdentifier) IdentifyNodes ¶
func (p *PoolIdentifier) IdentifyNodes(n []*api.NodeListStub) ([]*api.NodeListStub, error)
IdentifyNodes filters the supplied node list based on the PoolIdentifier params.
func (*PoolIdentifier) Validate ¶ added in v0.3.0
func (p *PoolIdentifier) Validate() error
Validate is used to check the validation of the PoolIdentifier object.
type RemoteProvider ¶
type RemoteProvider string
Deprecated. Pleas use ClusterNodeIDLookupFunc.
RemoteProvider is infrastructure provider which hosts and therefore manages the Nomad client instances. This is used to understand how to translate the Nomad NodeID to an ID that the provider understands.
const RemoteProviderAWSInstanceID RemoteProvider = "aws_instance_id"
RemoteProviderAWSInstanceID is the Amazon Web Services remote provider for EC2 instances. This provider will use the node attribute as defined by nodeAttrAWSInstanceID to perform ID translation.
const RemoteProviderAzureInstanceID RemoteProvider = "azure_instance_id"
RemoteProviderAzureInstanceID is the Azure remote provider for VM instances. This provider will use the node attribute as defined by nodeAttrAzureInstanceID to perform ID translation.
const RemoteProviderGCEInstanceID RemoteProvider = "gce_instance_id"
type ScaleIn ¶
type ScaleIn struct {
// contains filtered or unexported fields
}
Deprecated. Please use ClusterScaleUtils.
func NewScaleInUtils ¶
Deprecated. Please use NewClusterScaleUtils.
NewScaleInUtils returns a new ScaleIn implementation which provides helper functions for performing scaling in operations.
func (*ScaleIn) Ready ¶ added in v0.3.0
func (si *ScaleIn) Ready(id PoolIdentifier) (bool, error)
Ready provides a method for understanding whether the node pool is in a state that allows it to be safely scaled. This should be used by target plugins when providing their status response. A non-nil error indicates there was a problem performing the check.
func (*ScaleIn) RunPostScaleInTasks ¶
RunPostScaleInTasks runs any tasks that need to occur after a remote node provider has completed its work. It handles any users configuration so that the plugin does not need to perform this work.
func (*ScaleIn) RunPreScaleInTasks ¶
RunPreScaleInTasks helps tie together all the tasks required prior to scaling in Nomad nodes, and thus terminating the server in the remote provider.
type ScaleInReq ¶
type ScaleInReq struct { // Num is the number of nodes we should select and prepare for termination. Num int // DrainDeadline is the deadline used within the DrainSpec when performing // Nomad Node drain. DrainDeadline time.Duration IgnoreSystemJobs bool PoolIdentifier *PoolIdentifier RemoteProvider RemoteProvider NodeIDStrategy NodeIDStrategy }
Deprecated. Please use NewClusterScaleUtils.
ScaleInReq represents an individual cluster scaling request and encompasses all the information needed to perform the pre-termination tasks.