kubernetes: k8s.io/kubernetes/pkg/kubelet/pleg Index | Files

package pleg

import "k8s.io/kubernetes/pkg/kubelet/pleg"

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

Index

Package Files

doc.go generic.go pleg.go

type GenericPLEG Uses

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 Uses

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

func (*GenericPLEG) Start Uses

func (g *GenericPLEG) Start()

Start spawns a goroutine to relist periodically.

func (*GenericPLEG) Watch Uses

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

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

type PodLifeCycleEventType Uses

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

type PodLifecycleEvent Uses

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 Uses

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

func NewGenericPLEG Uses

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

Package pleg imports 11 packages (graph) and is imported by 69 packages. Updated 2018-08-01. Refresh now. Tools for package owners.