node

package
v1.22.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// UncordonAfterRebootLabelVal is a k8s label value that can added to an action label to uncordon a node
	UncordonAfterRebootLabelVal = "UncordonAfterReboot"
	// ActionLabelKey is a k8s label key that can be added to the k8s node NTH is running on
	ActionLabelKey = "aws-node-termination-handler/action"
	// ActionLabelTimeKey is a k8s label key whose value is the secs since the epoch when an action label is added
	ActionLabelTimeKey = "aws-node-termination-handler/action-time"
	// EventIDLabelKey is a k8s label key whose value is the drainable event id
	EventIDLabelKey = "aws-node-termination-handler/event-id"
	// Apply this label to enable the ServiceNodeExclusion feature gate for excluding nodes from load balancers
	ExcludeFromLoadBalancersLabelKey = "node.kubernetes.io/exclude-from-external-load-balancers"
	// The value associated with this label is irrelevant for enabling the feature gate
	// By defining a unique value it is possible to check if the label was applied by us before removing it
	ExcludeFromLoadBalancersLabelValue = "aws-node-termination-handler"
)
View Source
const (
	// SpotInterruptionTaint is a taint used to make spot instance unschedulable
	SpotInterruptionTaint = "aws-node-termination-handler/spot-itn"
	// ScheduledMaintenanceTaint is a taint used to make spot instance unschedulable
	ScheduledMaintenanceTaint = "aws-node-termination-handler/scheduled-maintenance"
	// ASGLifecycleTerminationTaint is a taint used to make instances about to be shutdown by ASG unschedulable
	ASGLifecycleTerminationTaint = "aws-node-termination-handler/asg-lifecycle-termination"
	// RebalanceRecommendationTaint is a taint used to make spot instance unschedulable
	RebalanceRecommendationTaint = "aws-node-termination-handler/rebalance-recommendation"
)
View Source
const (
	// PodEvictReason is the event reason emitted for Pod evictions during node drain
	PodEvictReason = "PodEviction"
	// PodEvictMsg is the event message emitted for Pod evictions during node drain
	PodEvictMsgFmt = "Pod evicted due to node drain (node %s)"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

type Node struct {
	// contains filtered or unexported fields
}

Node represents a kubernetes node with functions to manipulate its state via the kubernetes api server

func New

func New(nthConfig config.Config, clientset *kubernetes.Clientset) (*Node, error)

New will construct a node struct to perform various node function through the kubernetes api server

func NewWithValues added in v1.3.0

func NewWithValues(nthConfig config.Config, drainHelper *drain.Helper, uptime uptime.UptimeFuncType) (*Node, error)

NewWithValues will construct a node struct with a drain helper and an uptime function

func (Node) Cordon added in v1.4.0

func (n Node) Cordon(nodeName string, reason string) error

Cordon will add a NoSchedule on the node

func (Node) CordonAndDrain added in v1.4.0

func (n Node) CordonAndDrain(nodeName string, reason string, recorder recorderInterface) error

CordonAndDrain will cordon the node and evict pods based on the config

func (Node) FetchPodNameList added in v1.12.2

func (n Node) FetchPodNameList(nodeName string) ([]string, error)

FetchPodNameList fetches list of all the pods names running on given nodeName

func (Node) GetEventID

func (n Node) GetEventID(nodeName string) (string, error)

GetEventID will retrieve the event ID value from the node label

func (Node) GetNodeLabels added in v1.12.2

func (n Node) GetNodeLabels(nodeName string) (map[string]string, error)

GetNodeLabels will fetch node labels for a given nodeName

func (Node) GetNodeNameFromProviderID added in v1.16.2

func (n Node) GetNodeNameFromProviderID(providerId string) (string, error)

func (Node) IsLabeledWithAction

func (n Node) IsLabeledWithAction(nodeName string) (bool, error)

IsLabeledWithAction will return true if the current node is labeled with NTH action labels

func (Node) IsUnschedulable

func (n Node) IsUnschedulable(nodeName string) (bool, error)

IsUnschedulable checks if the node is marked as unschedulable

func (Node) LogPods added in v1.8.0

func (n Node) LogPods(podList []string, nodeName string) error

LogPods logs all the pod names on a node

func (Node) MarkForUncordonAfterReboot

func (n Node) MarkForUncordonAfterReboot(nodeName string) error

MarkForUncordonAfterReboot adds labels to the kubernetes node which NTH will read upon reboot

func (Node) MarkWithEventID

func (n Node) MarkWithEventID(nodeName string, eventID string) error

MarkWithEventID will add the drain event ID to the node to be properly ignored after a system restart event

func (Node) MaybeMarkForExclusionFromLoadBalancers added in v1.16.0

func (n Node) MaybeMarkForExclusionFromLoadBalancers(nodeName string) error

MaybeMarkForExclusionFromLoadBalancers will activate the ServiceNodeExclusion feature flag to indicate that the node should be removed from load balancers

func (Node) RemoveNTHLabels

func (n Node) RemoveNTHLabels(nodeName string) error

RemoveNTHLabels will remove all the custom NTH labels added to the node

func (Node) RemoveNTHTaints added in v1.5.0

func (n Node) RemoveNTHTaints(nodeName string) error

RemoveNTHTaints removes NTH-specific taints from a node

func (Node) TaintASGLifecycleTermination added in v1.9.0

func (n Node) TaintASGLifecycleTermination(nodeName string, eventID string) error

TaintASGLifecycleTermination adds the spot termination notice taint onto a node

func (Node) TaintRebalanceRecommendation added in v1.10.0

func (n Node) TaintRebalanceRecommendation(nodeName string, eventID string) error

TaintRebalanceRecommendation adds the rebalance recommendation notice taint onto a node

func (Node) TaintScheduledMaintenance added in v1.5.0

func (n Node) TaintScheduledMaintenance(nodeName string, eventID string) error

TaintScheduledMaintenance adds the scheduled maintenance taint onto a node

func (Node) TaintSpotItn added in v1.5.0

func (n Node) TaintSpotItn(nodeName string, eventID string) error

TaintSpotItn adds the spot termination notice taint onto a node

func (Node) Uncordon

func (n Node) Uncordon(nodeName string) error

Uncordon will remove the NoSchedule on the node

func (Node) UncordonIfRebooted

func (n Node) UncordonIfRebooted(nodeName string) error

UncordonIfRebooted will check for node labels to trigger an uncordon because of a system-reboot scheduled event

Jump to

Keyboard shortcuts

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