chaoskube: Index | Files

package chaoskube

import ""


Package Files


type Chaoskube Uses

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 namespace label selector which restricts the namespaces to choose from
    NamespaceLabels labels.Selector
    // a regular expression for pod names to include
    IncludedPodNames *regexp.Regexp
    // a regular expression for pod names to exclude
    ExcludedPodNames *regexp.Regexp
    // 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
    // a terminator that termiantes victim pods
    Terminator terminator.Terminator
    // dry run will not allow any pod terminations
    DryRun bool
    // grace period to terminate the pods
    GracePeriod time.Duration
    // event recorder allows to publish events to Kubernetes
    EventRecorder record.EventRecorder
    // a function to retrieve the current time
    Now func() time.Time

    MaxKill int
    // chaos events notifier
    Notifier notifier.Notifier

Chaoskube represents an instance of chaoskube

func New Uses

func New(client kubernetes.Interface, labels, annotations, namespaces, namespaceLabels labels.Selector, includedPodNames, excludedPodNames *regexp.Regexp, excludedWeekdays []time.Weekday, excludedTimesOfDay []util.TimePeriod, excludedDaysOfYear []time.Time, timezone *time.Location, minimumAge time.Duration, logger log.FieldLogger, dryRun bool, terminator terminator.Terminator, maxKill int, notifier notifier.Notifier) *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 terminator to use to imbue chaos on victim pods * whether to enable/disable dry-run mode

func (*Chaoskube) Candidates Uses

func (c *Chaoskube) Candidates(ctx context.Context) ([]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) DeletePod Uses

func (c *Chaoskube) DeletePod(ctx context.Context, victim v1.Pod) error

DeletePod deletes the given pod with the selected terminator. It will not delete the pod if dry-run mode is enabled.

func (*Chaoskube) Run Uses

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) TerminateVictims Uses

func (c *Chaoskube) TerminateVictims(ctx context.Context) error

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

func (*Chaoskube) Victims Uses

func (c *Chaoskube) Victims(ctx context.Context) ([]v1.Pod, error)

Victims returns up to N pods as configured by MaxKill flag

Package chaoskube imports 21 packages (graph) and is imported by 5 packages. Updated 2020-07-07. Refresh now. Tools for package owners.