drain

package
v0.53.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package drain is used to drain nodes

Package drain is used to drain nodes

Package drain is used to drain nodes

Package drain is used to drain nodes

Index

Constants

View Source
const (
	// EvictionKind is the kind used for eviction
	EvictionKind = "Eviction"
	// EvictionSubresource is the kind used for evicting pods
	EvictionSubresource = "pods/eviction"

	// DefaultMachineDrainTimeout is the default value for MachineDrainTimeout
	DefaultMachineDrainTimeout = 2 * time.Hour

	// PodsWithoutPVDrainGracePeriod defines the grace period to wait for the pods without PV during machine drain.
	// This is in addition to the maximum terminationGracePeriod amount the pods.
	PodsWithoutPVDrainGracePeriod = 3 * time.Minute

	// Interval is the default Poll interval
	Interval = time.Second * 5

	// PodEvictionRetryInterval is the interval in which to retry eviction for pods
	PodEvictionRetryInterval = time.Second * 20

	// GetPvDetailsRetryInterval is the interval in which to retry getting PV details
	GetPvDetailsRetryInterval = time.Second * 5
	// GetPvDetailsMaxRetries is the number of max retries to get PV details
	GetPvDetailsMaxRetries = 3
	// VolumeDetachPollInterval is the interval in which to recheck if the volume is detached from the node
	VolumeDetachPollInterval = time.Second * 5
)

Variables

View Source
var (
	// DefaultMaxEvictRetries is the default value for MaxEvictRetries
	DefaultMaxEvictRetries = int32(DefaultMachineDrainTimeout.Seconds() / PodEvictionRetryInterval.Seconds())
)

Functions

func SupportEviction

func SupportEviction(clientset kubernetes.Interface) (string, error)

SupportEviction uses Discovery API to find out if the server support eviction subresource If support, it will return its groupVersion; Otherwise, it will return ""

Types

type Options

type Options struct {
	DeleteLocalData bool
	Driver          driver.Driver

	ErrOut                       io.Writer
	ForceDeletePods              bool
	GracePeriodSeconds           int
	IgnorePodsWithoutControllers bool
	IgnoreDaemonsets             bool
	MaxEvictRetries              int32
	PvDetachTimeout              time.Duration
	PvReattachTimeout            time.Duration

	Out io.Writer

	Timeout time.Duration
	// contains filtered or unexported fields
}

Options are configurable options while draining a node before deletion

func NewDrainOptions

func NewDrainOptions(
	client kubernetes.Interface,
	kubernetesVersion *semver.Version,
	timeout time.Duration,
	maxEvictRetries int32,
	pvDetachTimeout time.Duration,
	pvReattachTimeout time.Duration,
	nodeName string,
	gracePeriodSeconds int,
	forceDeletePods bool,
	ignorePodsWithoutControllers bool,
	ignoreDaemonsets bool,
	deleteLocalData bool,
	out io.Writer,
	errOut io.Writer,
	driver driver.Driver,
	pvcLister corelisters.PersistentVolumeClaimLister,
	pvLister corelisters.PersistentVolumeLister,
	pdbV1beta1Lister policyv1beta1listers.PodDisruptionBudgetLister,
	pdbV1Lister policyv1listers.PodDisruptionBudgetLister,
	nodeLister corelisters.NodeLister,
	volumeAttachmentHandler *VolumeAttachmentHandler,
) *Options

NewDrainOptions creates a new DrainOptions struct and returns a pointer to it

func (*Options) RunCordonOrUncordon

func (o *Options) RunCordonOrUncordon(ctx context.Context, desired bool) error

RunCordonOrUncordon runs either Cordon or Uncordon. The desired value for "Unschedulable" is passed as the first arg.

func (*Options) RunDrain

func (o *Options) RunDrain(ctx context.Context) error

RunDrain runs the 'drain' command

type PodVolumeInfo added in v0.40.0

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

PodVolumeInfo is the struct used to hold the PersistentVolumeID and volumeID for all the PVs attached to the pod

type VolumeAttachmentHandler added in v0.40.0

type VolumeAttachmentHandler struct {
	sync.Mutex
	// contains filtered or unexported fields
}

VolumeAttachmentHandler is an handler used to distribute incoming VolumeAttachment requests to all listening workers

func NewVolumeAttachmentHandler added in v0.40.0

func NewVolumeAttachmentHandler() *VolumeAttachmentHandler

NewVolumeAttachmentHandler returns a new VolumeAttachmentHandler

func (*VolumeAttachmentHandler) AddVolumeAttachment added in v0.40.0

func (v *VolumeAttachmentHandler) AddVolumeAttachment(obj interface{})

AddVolumeAttachment is the event handler for VolumeAttachment add

func (*VolumeAttachmentHandler) AddWorker added in v0.40.0

func (v *VolumeAttachmentHandler) AddWorker() chan *storagev1.VolumeAttachment

AddWorker is the method used to add a new worker

func (*VolumeAttachmentHandler) DeleteWorker added in v0.40.0

func (v *VolumeAttachmentHandler) DeleteWorker(desiredWorker chan *storagev1.VolumeAttachment)

DeleteWorker is the method used to delete an existing worker

func (*VolumeAttachmentHandler) UpdateVolumeAttachment added in v0.40.0

func (v *VolumeAttachmentHandler) UpdateVolumeAttachment(oldObj, newObj interface{})

UpdateVolumeAttachment is the event handler for VolumeAttachment update

Jump to

Keyboard shortcuts

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