controller

package
v0.0.0-...-2e9f0d3 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package controller deletes pods in a certain state

Index

Constants

This section is empty.

Variables

View Source
var DefaultReasons = []string{
	"CrashLoopBackOff",
	"Error",
}

DefaultReasons is the reaons to delete a pod. only used when containers in pod are in terminated of waiting state

Functions

This section is empty.

Types

type Controller

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

Controller is a struct to hold a lister, deleter, and options

func New

func New(lister PodLister, deleter PodDeleter, options ...Option) (*Controller, error)

New creates a new controller

func (*Controller) Loop

func (c *Controller) Loop() error

Loop will run the controller periodically until stopped

func (*Controller) Once

func (c *Controller) Once(ctx context.Context) error

Once will list all pods and delete those that are in certain states and are at least x seconds old.

func (*Controller) Stop

func (c *Controller) Stop()

Stop the loop

type Option

type Option func(*Controller) error

Option sets options when creating a new controller

func WithDryRun

func WithDryRun(dryrun bool) Option

WithDryRun returns an Option that sets the dryrun flag. When true, pods will not actually be deleted Used when creating a new Controller.

func WithGrace

func WithGrace(d time.Duration) Option

WithGrace returns an Option that sets the grace period for pod deletions. Pods that have been created less than this time period ago will not be considered for deletion. Used when creating a new Controller.

func WithInterval

func WithInterval(d time.Duration) Option

WithInterval returns an Option that sets the loop interval. Used when creating a new Controller.

func WithLogger

func WithLogger(l *zap.Logger) Option

WithLogger returns an Option that sets the logger. Used when creating a new Controller.

func WithNamespace

func WithNamespace(namespace string) Option

WithNamespace returns an Option that sets the namespace. Used when creating a new Controller.

func WithReasons

func WithReasons(reasons []string) Option

WithReasons returns an Option that sets the reasons to delete a pod. Default is CrashLoopBackOff Error

func WithSelector

func WithSelector(selector string) Option

WithSelector returns an Option that sets the label selector used to filter pods when listing them. Used when creating a new Controller.

type PodDeleter

type PodDeleter interface {
	DeletePod(namespace string, name string) error
}

PodDeleter deletes a pod

type PodLister

type PodLister interface {
	ListPods(namespace string, selector string) ([]v1.Pod, error)
}

PodLister gets a list of pods.

Jump to

Keyboard shortcuts

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