chaoskube

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2018 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetupLogging

func SetupLogging(debug bool, logFormat string, logFields string) log.FieldLogger

Types

type ChaosAction

type ChaosAction interface {
	// Imbue chaos in the given victim
	ApplyChaos(victim v1.Pod) error
	// Name of this action, ideally a verb - like "terminate pod"
	Name() string
}

func NewDeletePodAction

func NewDeletePodAction(client kubernetes.Interface) ChaosAction

func NewDryRunAction

func NewDryRunAction() ChaosAction

func NewExecAction

func NewExecAction(client restclient.Interface, config *restclient.Config, containerName string, command []string) ChaosAction

type Chaoskube

type Chaoskube struct {
	// a kubernetes client object
	Client kubernetes.Interface
	// a label selector which restricts the pods to choose from
	Labels labels.Selector
	// an annotation selector which restricts the pods to choose from
	Annotations labels.Selector
	// a namespace selector which restricts the pods to choose from
	Namespaces labels.Selector
	// a list of weekdays when termination is suspended
	ExcludedWeekdays []time.Weekday
	// a list of time periods of a day when termination is suspended
	ExcludedTimesOfDay []util.TimePeriod
	// a list of days of a year when termination is suspended
	ExcludedDaysOfYear []time.Time
	// the timezone to apply when detecting the current weekday
	Timezone *time.Location
	// minimum age of pods to consider
	MinimumAge time.Duration
	// an instance of logrus.StdLogger to write log messages to
	Logger log.FieldLogger
	// action taken against victim pods
	Action ChaosAction
	// a function to retrieve the current time
	Now func() time.Time
}

Chaoskube represents an instance of chaoskube

func New

func New(client kubernetes.Interface, labels, annotations, namespaces labels.Selector, excludedWeekdays []time.Weekday, excludedTimesOfDay []util.TimePeriod, excludedDaysOfYear []time.Time, timezone *time.Location, minimumAge time.Duration, logger log.FieldLogger, action ChaosAction) *Chaoskube

New returns a new instance of Chaoskube. It expects: * a Kubernetes client to connect to a Kubernetes API * label, annotation and/or namespace selectors to reduce the amount of possible target pods * a list of weekdays, times of day and/or days of a year when chaos mode is disabled * a time zone to apply to the aforementioned time-based filters * a logger implementing logrus.FieldLogger to send log output to * what specific action to use to imbue chaos on victim pods

func (*Chaoskube) ApplyChaos

func (c *Chaoskube) ApplyChaos(victim v1.Pod) error

ApplyChaos deletes the given pod. It will not delete the pod if dry-run mode is enabled.

func (*Chaoskube) Candidates

func (c *Chaoskube) Candidates() ([]v1.Pod, error)

Candidates returns the list of pods that are available for termination. It returns all pods that match the configured label, annotation and namespace selectors.

func (*Chaoskube) Run

func (c *Chaoskube) Run(ctx context.Context, next <-chan time.Time)

Run continuously picks and terminates a victim pod at a given interval described by channel next. It returns when the given context is canceled.

func (*Chaoskube) TerminateVictim

func (c *Chaoskube) TerminateVictim() error

TerminateVictim picks and deletes a victim. It respects the configured excluded weekdays, times of day and days of a year filters.

func (*Chaoskube) Victim

func (c *Chaoskube) Victim() (v1.Pod, error)

Victim returns a random pod from the list of Candidates. It returns an error if there are no candidates to choose from.

Jump to

Keyboard shortcuts

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