kube_events_manager

package
v1.4.15-fix-logrus-dou... Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: Apache-2.0 Imports: 32 Imported by: 10

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
)

Variables

This section is empty.

Functions

func FormatFieldSelector

func FormatFieldSelector(selector *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) *kubeEventsManager

NewKubeEventsManager returns an implementation of KubeEventsManager.

func NewMonitor

func NewMonitor(ctx context.Context, client *klient.Client, mstor *metric_storage.MetricStorage, config *MonitorConfig, eventCb func(KubeEvent)) *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) 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)

type KubeEventsManager

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

	Ch() chan KubeEvent
	PauseHandleEvents()
}

type Monitor

type Monitor interface {
	CreateInformers() error
	Start(context.Context)
	Stop()
	PauseHandleEvents()
	Snapshot() []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              []WatchEventType
	ApiVersion              string
	Kind                    string
	NameSelector            *NameSelector
	NamespaceSelector       *NamespaceSelector
	LabelSelector           *metav1.LabelSelector
	FieldSelector           *FieldSelector
	JqFilter                string
	LogEntry                *log.Entry
	Mode                    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 []WatchEventType) *MonitorConfig

func (*MonitorConfig) WithFieldSelector

func (c *MonitorConfig) WithFieldSelector(fieldSel *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 KubeEventMode)

func (*MonitorConfig) WithNameSelector

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

WithNameSelector copies input NameSelector into monitor.NameSelector

func (*MonitorConfig) WithNamespaceSelector

func (c *MonitorConfig) WithNamespaceSelector(nsSel *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