Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type InvalidSensorStateError ¶
type InvalidSensorStateError struct {
// contains filtered or unexported fields
}
InvalidSensorStateError is an error that is returned when the sensor state is not valid.
func (*InvalidSensorStateError) Error ¶
func (isse *InvalidSensorStateError) Error() string
Error implements error interface.
type Opts ¶
type Opts struct { KubeConfig *rest.Config SensorName string // contains filtered or unexported fields }
Opts holds options related to sensor configuration - KubConfig : kubernetes config - EventQueueOpts : event queue options. Refer eventqueue.EventQueueOpts - SensorName: name of the sensor
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
Runtime sets up the sensor runtime and manages it. TODO: Rework cancelFunc in rule collectors
func SetupNewSensorRuntime ¶
SetupNewSensorRuntime will setup the sensor and return a sensor runtime. SetupSensor will collect the required KubeConfig and initialize the sensor to be able to start.
func (*Runtime) StartSensorRuntime ¶
StartSensorRuntime will start the sensor and rule collectors. Rules will be automatically reloaded if any rules changes were detected. StartSensor will collect initial rules for the sensor. StartSensor will block until the sensor runtime is stopped using StopSensor method.
func (*Runtime) StopOnSignal ¶
func (sr *Runtime) StopOnSignal()
StopOnSignal is a helper around StopSensor method to stop the sensor and related listeners on SIGINT or SIGTERM signals. Utilizes the StopSensor method which will stop all components gracefully.
func (*Runtime) StopSensorRuntime ¶
func (sr *Runtime) StopSensorRuntime()
StopSensorRuntime stops sensor and rule collectors gracefully. StopSensor will drain the Queue to make sure collected events are processed and then it will stop the workers.
type Sensor ¶
type Sensor struct { *Opts Queue *eventqueue.EventQueue // contains filtered or unexported fields }
Sensor struct implements kubernetes informers to sense changes according to the rules defined. Responsible for managing all informers and event queue TODO: Add support for leader elect between a group of sensors with
the same name.
func New ¶
func New(sensorOpts *Opts, executor eventqueue.QueueExecutor) *Sensor
New creates a new default Sensor. Refer Sensor struct documentation for more information. SensorOpts is required.
func (*Sensor) GetSensorState ¶
GetSensorState returns the current state of the sensor.
func (*Sensor) ReloadRules ¶
ReloadRules will reload affected sensor rules without requiring a restart. Thread safe by using mutex. Finds out which of the rules are affected, and reloads only them. Newly added rules which are not present in the old rules will be added. Rules which are not present in the new rules will be removed. For the rules which were updated, old informer will stopped and a new one will be created with the new rule configuration. If the sensor is not in a Running state, rules will not be reloaded. ReloadRules assumes all rules are valid and are unique.
func (*Sensor) Start ¶
Start starts the sensor. It will start all informers which will register event handlers and filters based on the rules. Start assumes rules are valid and unique. Start is a blocking call, it will block until the sensor is stopped.
func (*Sensor) StartSensorAndWorkerPool ¶
StartSensorAndWorkerPool will start the sensor and the worker pool. Worker pool which is part of the eventqueue module will consume events from the queue.
type State ¶
type State int
State type depicts the state of the sensor.
const ( // INIT is the initial state of the sensor. INIT State = iota //STARTING is the state when the sensor is starting. STARTING //RUNNING is the state when the sensor is running. RUNNING //STOPPING is the state when the sensor is stopping. STOPPING //STOPPED is the state when the sensor is stopped. STOPPED )