pleg

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2016 License: Apache-2.0 Imports: 10 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 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 situtations. 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)

func (*GenericPLEG) Start

func (g *GenericPLEG) Start()

Start spawns a goroutine to relist periodically.

func (*GenericPLEG) Watch

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

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

type PodLifeCycleEventType

type PodLifeCycleEventType string
const (
	ContainerStarted PodLifeCycleEventType = "ContainerStarted"
	ContainerDied    PodLifeCycleEventType = "ContainerDied"
	// 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"
	// Do not use the events below because they are disabled in GenericPLEG.
	ContainerRemoved PodLifeCycleEventType = "ContainerRemoved"
	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)
}

func NewGenericPLEG

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

Jump to

Keyboard shortcuts

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