Documentation
¶
Index ¶
- Constants
- func NewPodWatcher(client kubernetes.Interface, nodeName string, ...) *podWatcher
- type DaemonPlacement
- type ExpectedSourceNodes
- type RuntimePolicyMgr
- type ServiceChangeNotifier
- type StatusWriter
- func (s *StatusWriter) Flush(ctx context.Context) error
- func (s *StatusWriter) MarkAllDirty()
- func (s *StatusWriter) RecordCondition(policyUID, policyName string, cond metav1.Condition)
- func (s *StatusWriter) RecordSourceStatus(source string, state runtimeevent.SourceState, reason string)
- func (s *StatusWriter) Run(ctx context.Context) error
- func (s *StatusWriter) RuntimePolicyEvent(res *compiler.EvaluationResult, eventType string) error
- func (s *StatusWriter) SetExpectedSourceNodes(f func() ExpectedSourceNodes)
Constants ¶
const DefaultStatusFlushInterval = 30 * time.Second
DefaultStatusFlushInterval is the flush cadence used by the daemon.
Variables ¶
This section is empty.
Functions ¶
func NewPodWatcher ¶
func NewPodWatcher(client kubernetes.Interface, nodeName string, eventHandlers []events.PodEventHandler, nsHandlers []events.NamespaceEventHandler) *podWatcher
Types ¶
type DaemonPlacement ¶ added in v0.1.3
type DaemonPlacement struct {
// contains filtered or unexported fields
}
func NewDaemonPlacement ¶ added in v0.1.3
func NewDaemonPlacement(client kubernetes.Interface, namespace, name string, nodes cache.SharedIndexInformer, onChange func()) (*DaemonPlacement, error)
func (*DaemonPlacement) Run ¶ added in v0.1.3
func (p *DaemonPlacement) Run(ctx context.Context) error
func (*DaemonPlacement) Snapshot ¶ added in v0.1.3
func (p *DaemonPlacement) Snapshot() ExpectedSourceNodes
type ExpectedSourceNodes ¶ added in v0.1.3
ExpectedSourceNodes describes the DaemonSet nodes that should publish event source status. A non-synced or incomplete inventory cannot prove a source is available everywhere.
type RuntimePolicyMgr ¶
type RuntimePolicyMgr struct {
// contains filtered or unexported fields
}
func NewRuntimePolicyMgr ¶
func NewRuntimePolicyMgr(cfg *rest.Config, eventHandlers []events.RuntimePolicyEventHandler, client v1alpha1client.Interface, rpCompiler compiler.Compiler, resolver ServiceChangeNotifier, status runtimeevent.PolicyStatusRecorder) (*RuntimePolicyMgr, error)
func (*RuntimePolicyMgr) HasSynced ¶
func (m *RuntimePolicyMgr) HasSynced() bool
expose HasSynced so we can wait till sync is complete from main before starting the pod sync
type ServiceChangeNotifier ¶
type ServiceChangeNotifier interface {
AddChangeHandler(h func(namespace, name string))
}
ServiceChangeNotifier reports that the addresses behind a Service may have changed. It is satisfied by *services.Resolver.
type StatusWriter ¶
type StatusWriter struct {
// contains filtered or unexported fields
}
StatusWriter turns the RuntimePolicy event stream into this node's shard of each policy's status. Every daemon in the DaemonSet writes the same cluster-scoped object, so a node only ever replaces its own entry in status.nodes.
func NewStatusWriter ¶
func NewStatusWriter(client v1alpha1client.Interface, nodeName string, interval time.Duration, log logr.Logger, nodeGone func(name string) bool, onConditionChanged func(policyUID, policyName string, cond metav1.Condition)) *StatusWriter
NewStatusWriter builds a StatusWriter for this node. A non-positive interval falls back to DefaultStatusFlushInterval. A nil onConditionChanged disables the change callback.
func (*StatusWriter) Flush ¶
func (s *StatusWriter) Flush(ctx context.Context) error
Flush writes every dirty policy's shard. It is exported so the daemon (and tests) can force a write without waiting for the interval.
func (*StatusWriter) MarkAllDirty ¶ added in v0.1.3
func (s *StatusWriter) MarkAllDirty()
MarkAllDirty makes the next flush recompute every policy's aggregate status.
func (*StatusWriter) RecordCondition ¶
func (s *StatusWriter) RecordCondition(policyUID, policyName string, cond metav1.Condition)
RecordCondition stores a condition to be merged into the policy's status on the next flush. Re-recording an identical condition is a no-op so a manager that reports the same condition on every event does not cause API churn.
func (*StatusWriter) RecordSourceStatus ¶ added in v0.1.3
func (s *StatusWriter) RecordSourceStatus(source string, state runtimeevent.SourceState, reason string)
RecordSourceStatus records a daemon-wide source lifecycle transition. The source state is projected into relevant policy shards during flush.
func (*StatusWriter) Run ¶
func (s *StatusWriter) Run(ctx context.Context) error
Run flushes dirty policy statuses every interval, and once more when ctx is cancelled so the last observation is not lost on shutdown.
func (*StatusWriter) RuntimePolicyEvent ¶
func (s *StatusWriter) RuntimePolicyEvent(res *compiler.EvaluationResult, eventType string) error
RuntimePolicyEvent caches the policy's identity and mode.
func (*StatusWriter) SetExpectedSourceNodes ¶ added in v0.1.3
func (s *StatusWriter) SetExpectedSourceNodes(f func() ExpectedSourceNodes)
SetExpectedSourceNodes installs the DaemonSet membership view used to aggregate event source status. It marks every policy dirty because placement changes can alter a cluster condition without a policy event.