core

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2022 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GracefulDrainPrefix         = "pod-graceful-drain"
	WaitLabelKey                = GracefulDrainPrefix + "/wait"
	DeleteAtAnnotationKey       = GracefulDrainPrefix + "/deleteAt"
	OriginalLabelsAnnotationKey = GracefulDrainPrefix + "/originalLabels"
)
View Source
const (
	// Prefix for TargetHealth pod condition type.
	TargetHealthPodConditionTypePrefix = "target-health.elbv2.k8s.aws"
)

Variables

This section is empty.

Functions

func DidPodHaveServicesTargetTypeIP

func DidPodHaveServicesTargetTypeIP(ctx context.Context, client client.Client, pod *corev1.Pod) (bool, error)

func IsPodInDrainingNode

func IsPodInDrainingNode(ctx context.Context, client client.Client, pod *corev1.Pod) (bool, error)

func IsPodReady

func IsPodReady(pod *corev1.Pod) bool

Types

type AdmissionResponse

type AdmissionResponse struct {
	Allow  bool
	Reason string
}

func (AdmissionResponse) GetAdmissionResponse

func (r AdmissionResponse) GetAdmissionResponse() admission.Response

type DelayedTask

type DelayedTask interface {
	GetId() DelayedTaskId
	GetDuration() time.Duration
	RunWait(ctx context.Context) error
	RunAsync()
}

type DelayedTaskId

type DelayedTaskId int64

type Delayer

type Delayer interface {
	NewTask(duration time.Duration, task func(context.Context, bool) error) DelayedTask
	Stop(drain time.Duration, cleanup time.Duration)
}

func NewDelayer

func NewDelayer(logger logr.Logger) Delayer

type EvictionResponse

type EvictionResponse struct {
	Operations []jsonpatch.Operation
}

func NewEvictionResponse

func NewEvictionResponse(eviction *policyv1.Eviction) (EvictionResponse, error)

func (EvictionResponse) GetAdmissionResponse

func (r EvictionResponse) GetAdmissionResponse() admission.Response

type InterceptedAdmissionResponse

type InterceptedAdmissionResponse interface {
	GetAdmissionResponse() admission.Response
}

type Interceptor

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

func NewInterceptor

func NewInterceptor(drain *PodGracefulDrain, k8sClient client.Client) Interceptor

func (*Interceptor) InterceptPodDeletion

func (i *Interceptor) InterceptPodDeletion(ctx context.Context, req *admission.Request, pod *corev1.Pod) (InterceptedAdmissionResponse, error)

func (*Interceptor) InterceptPodEviction

func (i *Interceptor) InterceptPodEviction(ctx context.Context, req *admission.Request, eviction *policyv1.Eviction) (InterceptedAdmissionResponse, error)

type PodDeletionDelayInfo

type PodDeletionDelayInfo struct {
	Isolated    bool
	Wait        bool
	DeleteAtUTC time.Time
}

func GetPodDeletionDelayInfo

func GetPodDeletionDelayInfo(pod *corev1.Pod) (PodDeletionDelayInfo, error)

func (*PodDeletionDelayInfo) GetRemainingTime

func (i *PodDeletionDelayInfo) GetRemainingTime(now time.Time) time.Duration

type PodGracefulDrain

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

func NewPodGracefulDrain

func NewPodGracefulDrain(k8sClient client.Client, logger logr.Logger, config *PodGracefulDrainConfig) PodGracefulDrain

func (*PodGracefulDrain) DelayPodDeletion

func (d *PodGracefulDrain) DelayPodDeletion(ctx context.Context, pod *corev1.Pod) (InterceptedAdmissionResponse, error)

func (*PodGracefulDrain) DelayPodEviction

func (d *PodGracefulDrain) DelayPodEviction(ctx context.Context, eviction *policyv1.Eviction) (bool, error)

func (*PodGracefulDrain) Start

func (d *PodGracefulDrain) Start(ctx context.Context) error

type PodGracefulDrainConfig

type PodGracefulDrainConfig struct {
	DeleteAfter     time.Duration
	NoDenyAdmission bool
	IgnoreError     bool
}

func (*PodGracefulDrainConfig) BindFlags

func (c *PodGracefulDrainConfig) BindFlags(fs *flag.FlagSet)

func (*PodGracefulDrainConfig) Validate

func (c *PodGracefulDrainConfig) Validate() error

type PodMutator

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

func NewPodMutator

func NewPodMutator(client client.Client, pod *corev1.Pod) *PodMutator

func (*PodMutator) DisableWaitLabelAndDelete

func (m *PodMutator) DisableWaitLabelAndDelete(ctx context.Context) error

func (*PodMutator) Isolate

func (m *PodMutator) Isolate(ctx context.Context, deleteAt time.Time) error

func (*PodMutator) WithLogger

func (m *PodMutator) WithLogger(logger logr.Logger) *PodMutator

Jump to

Keyboard shortcuts

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