kubeeventsmanager

package
v1.15.1 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: Apache-2.0 Imports: 35 Imported by: 5 modules, 10 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ResyncPeriodMedian            = time.Duration(3) * time.Hour
	ResyncPeriodSpread            = time.Duration(2) * time.Hour
	ResyncPeriodGranularity       = time.Duration(5) * time.Minute
	ResyncPeriodJitterGranularity = time.Duration(15) * time.Second
)
View Source
const (
	FactoryShutdownTimeout = 30 * time.Second
)
View Source
const (
	NamespaceInformerShutdownTimeout = 30 * time.Second
)

Variables

This section is empty.

Functions

func FormatFieldSelector

func FormatFieldSelector(selector *kemtypes.FieldSelector) (string, error)

func FormatLabelSelector

func FormatLabelSelector(selector *metav1.LabelSelector) (string, error)

func IsExpiredError added in v1.1.2

func IsExpiredError(err error) bool

IsExpiredError is a private method from k8s.io/client-go/tools/cache.

func NewKubeEventsManager

func NewKubeEventsManager(ctx context.Context, client *klient.Client, logger *log.Logger) *kubeEventsManager

NewKubeEventsManager returns an implementation of KubeEventsManager.

func NewMonitor

func NewMonitor(ctx context.Context, client *klient.Client, mstor metricsstorage.Storage, config *MonitorConfig, eventCb func(kemtypes.KubeEvent), logger *log.Logger) *monitor

func NewNamespaceInformer

func NewNamespaceInformer(ctx context.Context, client *klient.Client, monitor *MonitorConfig) *namespaceInformer

Types

type CachedObjectsInfo added in v1.0.8

type CachedObjectsInfo struct {
	Count    uint64 `json:"count"`
	Added    uint64 `json:"added"`
	Deleted  uint64 `json:"deleted"`
	Modified uint64 `json:"modified"`
	Cleaned  uint64 `json:"cleaned"`
}

CachedObjectsInfo stores counters of operations over resources in Monitors and Informers.

type Factory added in v1.0.12

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

type FactoryIndex added in v1.0.12

type FactoryIndex struct {
	GVR           schema.GroupVersionResource
	Namespace     string
	FieldSelector string
	LabelSelector string
}

type FactoryStore added in v1.0.12

type FactoryStore struct {
	// contains filtered or unexported fields
}
var (
	DefaultFactoryStore *FactoryStore
	DefaultSyncTime     = 100 * time.Millisecond
)

func NewFactoryStore added in v1.0.12

func NewFactoryStore() *FactoryStore

func (*FactoryStore) Reset added in v1.7.0

func (c *FactoryStore) Reset()

func (*FactoryStore) Start added in v1.0.12

func (c *FactoryStore) Start(ctx context.Context, informerId string, client dynamic.Interface, index FactoryIndex, handler cache.ResourceEventHandler, errorHandler *WatchErrorHandler) error

func (*FactoryStore) Stop added in v1.0.12

func (c *FactoryStore) Stop(informerId string, index FactoryIndex)

func (*FactoryStore) WaitStopped added in v1.13.0

func (c *FactoryStore) WaitStopped(index FactoryIndex)

WaitStopped blocks until there is no factory for the index or timeout

type KubeEventsManager

type KubeEventsManager interface {
	WithMetricStorage(mstor metricsstorage.Storage)
	MetricStorage() metricsstorage.Storage
	AddMonitor(monitorConfig *MonitorConfig) error
	HasMonitor(monitorID string) bool
	GetMonitor(monitorID string) Monitor
	StartMonitor(monitorID string)
	StopMonitor(monitorID string) error

	Ch() chan kemtypes.KubeEvent
	Stop()
	Wait()
}

type Monitor

type Monitor interface {
	CreateInformers() error
	Start(context.Context)
	Stop()
	Wait()
	Snapshot() []kemtypes.ObjectAndFilterResult
	EnableKubeEventCb()
	GetConfig() *MonitorConfig
	SnapshotOperations() (total *CachedObjectsInfo, last *CachedObjectsInfo)
}

type MonitorConfig

type MonitorConfig struct {
	Metadata struct {
		MonitorId    string
		DebugName    string
		LogLabels    map[string]string
		MetricLabels map[string]string
	}
	EventTypes              []kemtypes.WatchEventType
	ApiVersion              string
	Kind                    string
	NameSelector            *kemtypes.NameSelector
	NamespaceSelector       *kemtypes.NamespaceSelector
	LabelSelector           *metav1.LabelSelector
	FieldSelector           *kemtypes.FieldSelector
	JqFilter                string
	Logger                  *log.Logger
	Mode                    kemtypes.KubeEventMode
	KeepFullObjectsInMemory bool
	FilterFunc              func(*unstructured.Unstructured) (interface{}, error)
}

MonitorConfig is a config that suits the latest version of OnKubernetesEventConfig.

func (*MonitorConfig) WithEventTypes

func (c *MonitorConfig) WithEventTypes(types []kemtypes.WatchEventType) *MonitorConfig

func (*MonitorConfig) WithFieldSelector

func (c *MonitorConfig) WithFieldSelector(fieldSel *kemtypes.FieldSelector)

WithFieldSelector copies input FieldSelector into monitor.FieldSelector

func (*MonitorConfig) WithLabelSelector

func (c *MonitorConfig) WithLabelSelector(labelSel *metav1.LabelSelector)

WithLabelSelector copies input LabelSelector into monitor.LabelSelector

func (*MonitorConfig) WithMode

func (c *MonitorConfig) WithMode(mode kemtypes.KubeEventMode)

func (*MonitorConfig) WithNameSelector

func (c *MonitorConfig) WithNameSelector(nSel *kemtypes.NameSelector)

WithNameSelector copies input NameSelector into monitor.NameSelector

func (*MonitorConfig) WithNamespaceSelector

func (c *MonitorConfig) WithNamespaceSelector(nsSel *kemtypes.NamespaceSelector)

WithNamespaceSelector copies input NamespaceSelector into monitor.NamespaceSelector

type WatchErrorHandler added in v1.1.2

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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