drain

package
v0.0.0-...-4c17ca5 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EvictionKind represents the kind of evictions object
	EvictionKind = "Eviction"
	// EvictionSubresource represents the kind of evictions object as pod's subresource
	EvictionSubresource = "pods/eviction"
)

Variables

This section is empty.

Functions

func NodeGroup

func NodeGroup(clientSet kubernetes.Interface, ng *api.NodeGroup, waitTimeout time.Duration, undo bool) error

NodeGroup drains a nodegroup

Types

type CordonHelper

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

CordonHelper wraps functionality to cordon/uncordon nodes

func NewCordonHelper

func NewCordonHelper(node *corev1.Node, desired DesiredCordonStatus) *CordonHelper

NewCordonHelper returns a new CordonHelper

func NewCordonHelperFromRuntimeObject

func NewCordonHelperFromRuntimeObject(nodeObject runtime.Object, scheme *runtime.Scheme, gvk schema.GroupVersionKind, desired DesiredCordonStatus) (*CordonHelper, error)

NewCordonHelperFromRuntimeObject returns a new CordonHelper, or an error if given object is not a node or cannot be encoded as JSON

func (*CordonHelper) IsUpdateRequired

func (c *CordonHelper) IsUpdateRequired() bool

IsUpdateRequired returns true if c.node.Spec.Unschedulable matches desired state, or false when it is

func (*CordonHelper) PatchOrReplace

func (c *CordonHelper) PatchOrReplace(clientset kubernetes.Interface) (error, error)

PatchOrReplace uses given clientset to update the node status, either by patching or updating the given node object; it may return error if the object cannot be encoded as JSON, or if either patch or update calls fail; it will also return a second error whenever creating a patch has failed

type DesiredCordonStatus

type DesiredCordonStatus string
const (
	CordonNode   DesiredCordonStatus = "cordon"
	UncordonNode DesiredCordonStatus = "uncordon"
)

func (DesiredCordonStatus) String

func (n DesiredCordonStatus) String() string

type Helper

type Helper struct {
	Selector    string
	PodSelector string

	Client kubernetes.Interface

	Force  bool
	DryRun bool

	GracePeriodSeconds int
	Timeout            time.Duration

	IgnoreAllDaemonSets bool
	IgnoreDaemonSets    []metav1.ObjectMeta
	DeleteLocalData     bool

	UseEvictions bool
	// contains filtered or unexported fields
}

Helper contains the parameters to control the behaviour of drainer

func (*Helper) CanUseEvictions

func (d *Helper) CanUseEvictions() error

CanUseEvictions uses Discovery API to find out if evictions are supported

func (*Helper) DeletePod

func (d *Helper) DeletePod(pod corev1.Pod) error

DeletePod will delete the given pod, or return an error if it couldn't

func (*Helper) EvictOrDeletePod

func (d *Helper) EvictOrDeletePod(pod corev1.Pod) error

EvictOrDeletePod will evict pod if policy API is available, otherwise deletes it NOTE: CanUseEvictions must be called prior to this

func (*Helper) EvictPod

func (d *Helper) EvictPod(pod corev1.Pod) error

EvictPod will evict the give pod, or return an error if it couldn't NOTE: CanUseEvictions must be called prior to this

func (*Helper) GetPodsForDeletion

func (d *Helper) GetPodsForDeletion(nodeName string) (*podDeleteList, []error)

GetPodsForDeletion lists all pods on a given node, filters those using the default filters, and returns podDeleteList along with any errors. All pods that are ready to be deleted can be obtained with .Pods(), and string with all warning can be obtained with .Warnings()

Jump to

Keyboard shortcuts

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