Documentation ¶
Index ¶
- Constants
- Variables
- type Authenticator
- type DeregistrationError
- type Deregistrator
- type EventLevel
- type EventReason
- type LifecycleEvent
- func (e *LifecycleEvent) SetDeregisterCompleted(val bool)
- func (e *LifecycleEvent) SetDrainCompleted(val bool)
- func (e *LifecycleEvent) SetEventCompleted(val bool)
- func (e *LifecycleEvent) SetEventTimeStarted(t time.Time)
- func (e *LifecycleEvent) SetHeartbeatInterval(interval int64)
- func (e *LifecycleEvent) SetMessage(message *sqs.Message)
- func (e *LifecycleEvent) SetNodeDeleted(val bool)
- func (e *LifecycleEvent) SetQueueURL(url string)
- func (e *LifecycleEvent) SetReceiptHandle(receipt string)
- func (e *LifecycleEvent) SetReferencedNode(node v1.Node)
- type Manager
- func (mgr *Manager) AddEvent(event *LifecycleEvent)
- func (m *Manager) AddTargetByInstance(key interface{}, add *Target)
- func (mgr *Manager) CompleteEvent(event *LifecycleEvent)
- func (m *Manager) DeregisterTargets(targets []*Target, d *Deregistrator)
- func (mgr *Manager) EventInQueue(e *LifecycleEvent) bool
- func (mgr *Manager) FailEvent(err error, event *LifecycleEvent, abandon bool)
- func (m *Manager) GetTargetInstanceIds(key interface{}) []string
- func (m *Manager) GetTargetMapping(key interface{}) map[string]int64
- func (m *Manager) LoadTargets(key interface{}) []*Target
- func (m *Manager) NewTarget(targetId, instanceId string, port int64, targetType TargetType) *Target
- func (mgr *Manager) Process(event *LifecycleEvent)
- func (mgr *Manager) RejectEvent(err error, event *LifecycleEvent)
- func (mgr *Manager) RemoveFromQueue(event *LifecycleEvent)
- func (m *Manager) RemoveTargetByInstance(key interface{}, instanceID string)
- func (m *Manager) SetTargets(key interface{}, targets []*Target)
- func (mgr *Manager) Start()
- type ManagerContext
- type MetricsServer
- type ScanResult
- type Target
- type TargetType
- type Waiter
- type WaiterError
Constants ¶
const ( // EventLevelNormal is the level of a normal event EventLevelNormal = "Normal" // EventLevelWarning is the level of a warning event EventLevelWarning = "Warning" // EventReasonLifecycleHookReceived is the reason for a lifecycle received event EventReasonLifecycleHookReceived EventReason = "LifecycleHookReceived" // EventMessageLifecycleHookReceived is the message for a lifecycle received event EventMessageLifecycleHookReceived = "lifecycle hook for event %v was received, instance %v will begin processing" // EventReasonLifecycleHookProcessed is the reason for a lifecycle successful processing event EventReasonLifecycleHookProcessed EventReason = "LifecycleHookProcessed" //EventMessageLifecycleHookProcessed is the message for a lifecycle successful processing event EventMessageLifecycleHookProcessed = "lifecycle hook for event %v has completed processing, instance %v gracefully terminated after %vs" // EventReasonLifecycleHookFailed is the reason for a lifecycle failed event EventReasonLifecycleHookFailed EventReason = "LifecycleHookFailed" // EventMessageLifecycleHookFailed is the message for a lifecycle failed event EventMessageLifecycleHookFailed = "lifecycle hook for event %v has failed processing after %vs: %v" // EventReasonNodeDrainSucceeded is the reason for a successful drain event EventReasonNodeDrainSucceeded EventReason = "NodeDrainSucceeded" // EventMessageNodeDrainSucceeded is the message for a successful drain event EventMessageNodeDrainSucceeded = "node %v has been drained successfully as a response to a termination event" // EventReasonNodeDrainFailed is the reason for a failed drain event EventReasonNodeDrainFailed EventReason = "NodeDrainFailed" // EventMessageNodeDrainFailed is the message for a failed drain event EventMessageNodeDrainFailed = "node %v draining has failed: %v" // EventReasonNodeDeleteSucceeded is the reason for a successful node delete event EventReasonNodeDeleteSucceeded EventReason = "NodeDeleteSucceeded" // EventMessageNodeDeleteSucceeded is the message for a successful node delete event EventMessageNodeDeleteSucceeded = "node %v has been deleted successfully as a response to a termination event" // EventReasonNodeDeletenFailed is the reason for a failed node delete event EventReasonNodeDeleteFailed EventReason = "NodeDeleteFailed" // EventMessageNodeDeleteFailed is the message for a failed node delete event EventMessageNodeDeleteFailed = "node %v deletion has failed: %v" // EventReasonTargetDeregisterSucceeded is the reason for a successful target group deregister event EventReasonTargetDeregisterSucceeded EventReason = "TargetDeregisterSucceeded" // EventMessageTargetDeregisterSucceeded is the message for a successful target group deregister event EventMessageTargetDeregisterSucceeded = "target %v:%v has successfully deregistered from target group %v" // EventReasonTargetDeregisterFailed is the reason for a successful drain event EventReasonTargetDeregisterFailed EventReason = "TargetDeregisterFailed" // EventMessageTargetDeregisterFailed is the message for a successful drain event EventMessageTargetDeregisterFailed = "target %v has failed to deregistered from target group %v: %v" // EventReasonInstanceDeregisterSucceeded is the reason for a successful target group deregister event EventReasonInstanceDeregisterSucceeded EventReason = "InstanceDeregisterSucceeded" // EventMessageInstanceDeregisterSucceeded is the message for a successful target group deregister event EventMessageInstanceDeregisterSucceeded = "instance %v has successfully deregistered from classic-elb %v" // EventReasonInstanceDeregisterFailed is the reason for a successful classic elb deregister event EventReasonInstanceDeregisterFailed EventReason = "InstanceDeregisterFailed" // EventMessageInstanceDeregisterFailed is the message for a successful classic elb deregister event EventMessageInstanceDeregisterFailed = "instance %v has failed to deregister from classic-elb %v: %v" )
const ( ActiveGoroutinesMetric = "active_goroutines" TerminatingInstancesCountMetric = "terminating_instances_count" DrainingInstancesCountMetric = "draining_instances_count" DeregisteringInstancesCountMetric = "deregistering_instances_count" AverageDurationSecondsMetric = "average_duration_seconds" SuccessfulEventsTotalMetric = "successful_events_total" SuccessfulLBDeregisterTotalMetric = "successful_lb_deregister_total" SuccessfulNodeDrainTotalMetric = "successful_node_drain_total" SuccessfulNodeDeleteTotalMetric = "successful_node_delete_total" FailedEventsTotalMetric = "failed_events_total" FailedLBDeregisterTotalMetric = "failed_lb_deregister_total" FailedNodeDrainTotalMetric = "failed_node_drain_total" FailedNodeDeleteTotalMetric = "failed_node_delete_total" RejectedEventsTotalMetric = "rejected_events_total" )
Variables ¶
var ( // EventName is the default name for service events EventName = "lifecycle-manager.%v" // EventNamespace is the default namespace in which events will be published in EventNamespace = "default" // EventLevels is a map of event reasons and their event level EventLevels = map[EventReason]string{ EventReasonLifecycleHookReceived: EventLevelNormal, EventReasonLifecycleHookProcessed: EventLevelNormal, EventReasonLifecycleHookFailed: EventLevelWarning, EventReasonNodeDrainSucceeded: EventLevelNormal, EventReasonNodeDrainFailed: EventLevelWarning, EventReasonTargetDeregisterSucceeded: EventLevelNormal, EventReasonTargetDeregisterFailed: EventLevelWarning, EventReasonInstanceDeregisterSucceeded: EventLevelNormal, EventReasonInstanceDeregisterFailed: EventLevelWarning, } )
var ( // MetricsNamespace is the namespace of prometheus metrics MetricsNamespace = "lifecycle_manager" // MetricsPort is the port used to serve metrics MetricsPort = ":8080" // MetricsEndpoint is the endpoint to expose for metrics MetricsEndpoint = "/metrics" )
var ( // TerminationEventName is the event name of a terminating lifecycle hook TerminationEventName = "autoscaling:EC2_INSTANCE_TERMINATING" // ContinueAction is the name of the action in case we are successful in draining ContinueAction = "CONTINUE" // AbandonAction is the name of the action in case we are unsuccessful in draining AbandonAction = "ABANDON" // AlphaExcludeLabelKey is the alb-ingress-controller exclude label key AlphaExcludeLabelKey = "alpha.service-controller.kubernetes.io/exclude-balancer" // AlphaExcludeLabelValue is the alb-ingress-controller exclude label value AlphaExcludeLabelValue = "true" // ExcludeLabelKey is the ServiceNodeExclusion feature exclude label key ExcludeLabelKey = "node.kubernetes.io/exclude-from-external-load-balancers" // ExcludeLabelKey is the ServiceNodeExclusion feature exclude label value ExcludeLabelValue = "true" // InProgressAnnotationKey is the annotation key for setting the state of a node to in-progress InProgressAnnotationKey = "lifecycle-manager.keikoproj.io/in-progress" // QueueNameAnnotationKey is the annotation key for saving the queue name for a node QueueNameAnnotationKey = "lifecycle-manager.keikoproj.io/queue-name" // ThreadJitterRangeSeconds configures the jitter range in seconds 0 to N per handler goroutine ThreadJitterRangeSeconds = 30.0 // IterationJitterRangeSeconds configures the jitter range in seconds 0 to N per call iteration goroutine IterationJitterRangeSeconds = 1.5 // NodeAgeCacheTTL defines a node age in minutes for which all caches are flushed NodeAgeCacheTTL = 90 // WaiterMinDelay defines the minimum delay of the IEB waiter WaiterMinDelay time.Duration = 10 * time.Second // WaiterMaxDelay defines the maximum delay of the IEB waiter WaiterMaxDelay time.Duration = 90 * time.Second // WaiterMaxAttempts defines the maximum attempts of the IEB waiter WaiterMaxAttempts uint32 = 120 )
Functions ¶
This section is empty.
Types ¶
type Authenticator ¶
type Authenticator struct { ScalingGroupClient autoscalingiface.AutoScalingAPI SQSClient sqsiface.SQSAPI ELBv2Client elbv2iface.ELBV2API ELBClient elbiface.ELBAPI KubernetesClient kubernetes.Interface }
Authenticator holds clients for all required APIs
type DeregistrationError ¶
type DeregistrationError struct { Error error Target string Instances []string Type TargetType }
type Deregistrator ¶
type Deregistrator struct {
// contains filtered or unexported fields
}
func (*Deregistrator) AddClassicDeregistration ¶
func (d *Deregistrator) AddClassicDeregistration(val int)
func (*Deregistrator) AddTargetGroupDeregistration ¶
func (d *Deregistrator) AddTargetGroupDeregistration(val int)
type LifecycleEvent ¶
type LifecycleEvent struct { LifecycleHookName string `json:"LifecycleHookName"` AccountID string `json:"AccountId"` RequestID string `json:"RequestId"` LifecycleTransition string `json:"LifecycleTransition"` AutoScalingGroupName string `json:"AutoScalingGroupName"` EC2InstanceID string `json:"EC2InstanceId"` LifecycleActionToken string `json:"LifecycleActionToken"` // contains filtered or unexported fields }
func (*LifecycleEvent) SetDeregisterCompleted ¶
func (e *LifecycleEvent) SetDeregisterCompleted(val bool)
SetDeregisterCompleted is a setter method for status of the drain operation
func (*LifecycleEvent) SetDrainCompleted ¶
func (e *LifecycleEvent) SetDrainCompleted(val bool)
SetDrainCompleted is a setter method for status of the drain operation
func (*LifecycleEvent) SetEventCompleted ¶
func (e *LifecycleEvent) SetEventCompleted(val bool)
SetEventCompleted is a setter method for status of the drain operation
func (*LifecycleEvent) SetEventTimeStarted ¶
func (e *LifecycleEvent) SetEventTimeStarted(t time.Time)
SetEventTimeStarted is a setter method for the time an event started
func (*LifecycleEvent) SetHeartbeatInterval ¶
func (e *LifecycleEvent) SetHeartbeatInterval(interval int64)
SetHeartbeatInterval is a setter method for heartbeat interval of the event
func (*LifecycleEvent) SetMessage ¶
func (e *LifecycleEvent) SetMessage(message *sqs.Message)
SetMessage is a setter method for the sqs message body
func (*LifecycleEvent) SetNodeDeleted ¶
func (e *LifecycleEvent) SetNodeDeleted(val bool)
SetNodeDeleted is a setter method for status of the node deletion operation
func (*LifecycleEvent) SetQueueURL ¶
func (e *LifecycleEvent) SetQueueURL(url string)
SetQueueURL is a setter method for the url of the SQS queue
func (*LifecycleEvent) SetReceiptHandle ¶
func (e *LifecycleEvent) SetReceiptHandle(receipt string)
SetReceiptHandle is a setter method for the receipt handle of the event
func (*LifecycleEvent) SetReferencedNode ¶
func (e *LifecycleEvent) SetReferencedNode(node v1.Node)
SetReferencedNode is a setter method for the event referenced node
type Manager ¶
Manager is the main object for lifecycle-manager and holds the state
func New ¶
func New(auth Authenticator, ctx ManagerContext) *Manager
func (*Manager) AddEvent ¶
func (mgr *Manager) AddEvent(event *LifecycleEvent)
func (*Manager) AddTargetByInstance ¶
AddTargetByInstance adds a target by it's instance ID
func (*Manager) CompleteEvent ¶
func (mgr *Manager) CompleteEvent(event *LifecycleEvent)
func (*Manager) DeregisterTargets ¶
func (m *Manager) DeregisterTargets(targets []*Target, d *Deregistrator)
func (*Manager) EventInQueue ¶
func (mgr *Manager) EventInQueue(e *LifecycleEvent) bool
func (*Manager) FailEvent ¶
func (mgr *Manager) FailEvent(err error, event *LifecycleEvent, abandon bool)
func (*Manager) GetTargetInstanceIds ¶
GetTargetInstanceIds gets instance ids for a specific key
func (*Manager) GetTargetMapping ¶
GetTargetMapping gets instanceID>port mapping for a specific key
func (*Manager) LoadTargets ¶
LoadTargets loads a list of targets by key
func (*Manager) NewTarget ¶
func (m *Manager) NewTarget(targetId, instanceId string, port int64, targetType TargetType) *Target
func (*Manager) Process ¶
func (mgr *Manager) Process(event *LifecycleEvent)
Process processes a received event
func (*Manager) RejectEvent ¶
func (mgr *Manager) RejectEvent(err error, event *LifecycleEvent)
func (*Manager) RemoveFromQueue ¶
func (mgr *Manager) RemoveFromQueue(event *LifecycleEvent)
func (*Manager) RemoveTargetByInstance ¶
RemoveTargetByInstance removes a target by it's instance ID
func (*Manager) SetTargets ¶
SetTargets sets targets to a specific key
type ManagerContext ¶
type ManagerContext struct { CacheConfig *cache.Config KubectlLocalPath string QueueName string Region string DrainTimeoutUnknownSeconds int64 DrainTimeoutSeconds int64 DrainRetryIntervalSeconds int64 DrainRetryAttempts uint PollingIntervalSeconds int64 WithDeregister bool DeregisterTargetTypes []string MaxDrainConcurrency *semaphore.Weighted MaxTimeToProcessSeconds int64 }
ManagerContext contain the user input parameters on the current context
type MetricsServer ¶
type MetricsServer struct { Counters map[string]prometheus.Counter Gauges map[string]prometheus.Gauge }
func (*MetricsServer) AddCounter ¶
func (m *MetricsServer) AddCounter(idx string, value float64)
func (*MetricsServer) DecGauge ¶
func (m *MetricsServer) DecGauge(idx string)
func (*MetricsServer) IncGauge ¶
func (m *MetricsServer) IncGauge(idx string)
func (*MetricsServer) SetGauge ¶
func (m *MetricsServer) SetGauge(idx string, value float64)
func (*MetricsServer) Start ¶
func (m *MetricsServer) Start()
type ScanResult ¶
ScanResult contains a list of found load balancers and target groups
type Target ¶
type Target struct { Type TargetType TargetId string InstanceId string Port int64 }
Target defines a deregistration target
type TargetType ¶
type TargetType string
const ( // TargetTypeClassicELB defines a target type of classic elb TargetTypeClassicELB TargetType = "classic-elb" // TargetTypeTargetGroup defines a target type of target-group TargetTypeTargetGroup TargetType = "target-group" )
func (TargetType) String ¶
func (t TargetType) String() string
type Waiter ¶
func (*Waiter) DecClassicWaiter ¶
func (w *Waiter) DecClassicWaiter()
func (*Waiter) DecTargetGroupWaiter ¶
func (w *Waiter) DecTargetGroupWaiter()
func (*Waiter) IncClassicWaiter ¶
func (w *Waiter) IncClassicWaiter()
func (*Waiter) IncTargetGroupWaiter ¶
func (w *Waiter) IncTargetGroupWaiter()
type WaiterError ¶
type WaiterError struct { Error error Type TargetType }