drain

package
v0.55.1 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: Apache-2.0 Imports: 28 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,
	pdbLister policyv1listers.PodDisruptionBudgetLister,
	nodeLister corelisters.NodeLister,
	podLister corelisters.PodLister,
	volumeAttachmentHandler *VolumeAttachmentHandler,
	podSynced cache.InformerSynced,
) *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 holds a list of infos about PersistentVolumes referenced by a single pod.

func (PodVolumeInfo) PersistentVolumeNames added in v0.55.0

func (p PodVolumeInfo) PersistentVolumeNames() []string

PersistentVolumeNames returns the names of all PersistentVolumes used by the pod.

func (PodVolumeInfo) VolumeIDs added in v0.55.0

func (p PodVolumeInfo) VolumeIDs() []string

VolumeIDs returns the volume IDs/handles of all PersistentVolumes used by 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(_, newObj interface{})

UpdateVolumeAttachment is the event handler for VolumeAttachment update

type VolumeInfo added in v0.55.0

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

VolumeInfo holds relevant information about a PersistentVolume for tracking attachments.

Jump to

Keyboard shortcuts

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