pleg

package
v1.13.5-beta.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package pleg contains types and a generic implementation of the pod lifecycle event generator.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GenericPLEG

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

GenericPLEG is an extremely simple generic PLEG that relies solely on periodic listing to discover container changes. It should be used as temporary replacement for container runtimes do not support a proper event generator yet.

Note that GenericPLEG assumes that a container would not be created, terminated, and garbage collected within one relist period. If such an incident happens, GenenricPLEG would miss all events regarding this container. In the case of relisting failure, the window may become longer. Note that this assumption is not unique -- many kubelet internal components rely on terminated containers as tombstones for bookkeeping purposes. The garbage collector is implemented to work with such situations. However, to guarantee that kubelet can handle missing container events, it is recommended to set the relist period short and have an auxiliary, longer periodic sync in kubelet as the safety net.

func (*GenericPLEG) Healthy

func (g *GenericPLEG) Healthy() (bool, error)

Healthy check if PLEG work properly. relistThreshold is the maximum interval between two relist.

func (*GenericPLEG) Start

func (g *GenericPLEG) Start()

Start spawns a goroutine to relist periodically.

func (*GenericPLEG) Watch

func (g *GenericPLEG) Watch() chan *PodLifecycleEvent

Watch returns a channel from which the subscriber can receive PodLifecycleEvent events. TODO: support multiple subscribers.

type PodLifeCycleEventType

type PodLifeCycleEventType string

PodLifeCycleEventType define the event type of pod life cycle events.

const (
	// ContainerStarted - event type when the new state of container is running.
	ContainerStarted PodLifeCycleEventType = "ContainerStarted"
	// ContainerDied - event type when the new state of container is exited.
	ContainerDied PodLifeCycleEventType = "ContainerDied"
	// ContainerRemoved - event type when the old state of container is exited.
	ContainerRemoved PodLifeCycleEventType = "ContainerRemoved"
	// PodSync is used to trigger syncing of a pod when the observed change of
	// the state of the pod cannot be captured by any single event above.
	PodSync PodLifeCycleEventType = "PodSync"
	// ContainerChanged - event type when the new state of container is unknown.
	ContainerChanged PodLifeCycleEventType = "ContainerChanged"
)

type PodLifecycleEvent

type PodLifecycleEvent struct {
	// The pod ID.
	ID types.UID
	// The type of the event.
	Type PodLifeCycleEventType
	// The accompanied data which varies based on the event type.
	//   - ContainerStarted/ContainerStopped: the container name (string).
	//   - All other event types: unused.
	Data interface{}
}

PodLifecycleEvent is an event that reflects the change of the pod state.

type PodLifecycleEventGenerator

type PodLifecycleEventGenerator interface {
	Start()
	Watch() chan *PodLifecycleEvent
	Healthy() (bool, error)
}

PodLifecycleEventGenerator contains functions for generating pod life cycle events.

func NewGenericPLEG

func NewGenericPLEG(runtime kubecontainer.Runtime, channelCapacity int,
	relistPeriod time.Duration, cache kubecontainer.Cache, clock clock.Clock) PodLifecycleEventGenerator

NewGenericPLEG instantiates a new GenericPLEG object and return it.

Jump to

Keyboard shortcuts

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