prune

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CustomStrategy maximum age of a resource that is desired, Duration
	CustomStrategy Strategy = "Custom"
	// MaxAgeStrategy maximum age of a resource that is desired, Duration
	MaxAgeStrategy Strategy = "MaxAge"
	// MaxCountStrategy maximum number of a resource that is desired, int
	MaxCountStrategy Strategy = "MaxCount"
	// JobKind equates to a Kube Job resource kind
	JobKind string = "Job"
	// PodKind equates to a Kube Pod resource kind
	PodKind string = "Pod"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Clientset      kubernetes.Interface      // kube client used by pruning
	LabelSelector  string                    //selector resources to prune
	DryRun         bool                      //true only performs a check, not removals
	Resources      []schema.GroupVersionKind //pods, jobs are supported
	Namespaces     []string                  //empty means all namespaces
	Strategy       StrategyConfig            //strategy for pruning, either age or max
	CustomStrategy StrategyFunc              //custom strategy
	PreDeleteHook  PreDelete                 //called before resource is deleteds
	// contains filtered or unexported fields
}

Config defines a pruning configuration and ultimately determines what will get pruned

func (Config) Execute

func (config Config) Execute(ctx context.Context) error

Execute causes the pruning work to be executed based on its configuration

type PreDelete

type PreDelete func(cfg Config, something ResourceInfo) error

PreDelete function is called before a resource is pruned

type ResourceInfo

type ResourceInfo struct {
	Name      string
	GVK       schema.GroupVersionKind
	Namespace string
	StartTime time.Time
}

ResourceInfo describes the Kube resources that we are about to consider when pruning resources

type ResourceStatus

type ResourceStatus string

ResourceStatus describes the Kubernetes resource status we are evaluating

type Strategy

type Strategy string

Strategy describes the pruning strategy we want to employ

type StrategyConfig

type StrategyConfig struct {
	Mode            Strategy
	MaxAgeSetting   string
	MaxCountSetting int
	CustomSettings  map[string]interface{}
}

StrategyConfig holds settings unique to each pruning mode

type StrategyFunc

type StrategyFunc func(cfg Config, resources []ResourceInfo) ([]ResourceInfo, error)

StrategyFunc function allows a means to specify custom prune strategies

Jump to

Keyboard shortcuts

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