drain

package
v0.8.4-rc.4 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2020 License: Apache-2.0 Imports: 18 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

View Source
var DefaultIgnoredDaemonSets = []metav1.ObjectMeta{
	{
		Namespace: "kube-system",
		Name:      "aws-node",
	},
	{
		Namespace: "kube-system",
		Name:      "kube-proxy",
	},
	{
		Name: "node-exporter",
	},
	{
		Name: "prom-node-exporter",
	},
	{
		Name: "weave-scope",
	},
	{
		Name: "weave-scope-agent",
	},
	{
		Name: "weave-net",
	},
}

DefaultIgnoredDaemonSets represents the default daemonsets ignored by WKS, when draining a node.

View Source
var DefaultTimeOut = 1 * time.Minute

DefaultTimeOut is the default duration Drain will wait for pods to be evicted before erroring. This value will be used if Params.TimeOut is not provided.

Functions

func Drain

func Drain(node *corev1.Node, clientSet kubernetes.Interface, params Params) error

Drain drains the provided node.

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()

type Params

type Params struct {
	Force               bool
	DeleteLocalData     bool
	IgnoreAllDaemonSets bool
	IgnoreDaemonSets    []metav1.ObjectMeta
	TimeOut             time.Duration
}

Params groups required inputs to drain a Kubernetes node.

Jump to

Keyboard shortcuts

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