controlplane

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 56 Imported by: 0 modules, 0 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

Overview

Package controlplane connects the operator to the optional control plane (0002 §3.4, §5.3, §7.5; api/controlplane/v1). In GitOps and Managed mode the leader enrolls the cluster with a one-time token, keeps its client certificate in a Secret, renews it over the primary stream, sends the cluster's state (ClusterState) on change, in Managed mode writes the control plane's policy snapshots as CRDs, and reports ControlPlaneConnected on the InkwallConfig. Standalone runs none of it. Enforcement never depends on it.

Index

Constants

View Source
const (
	ReasonConnected            = "Connected"
	ReasonInvalidEndpoint      = "InvalidEndpoint"
	ReasonTokenSecretMissing   = "EnrollmentTokenMissing"
	ReasonTokenSecretElsewhere = "EnrollmentTokenNotInOperatorNamespace"
	ReasonTokenRejected        = "EnrollmentTokenRejected"
	ReasonEnrollFailed         = "EnrollFailed"
	ReasonCertificateRejected  = "CertificateRejected"
	ReasonCertificateExpired   = "CertificateExpired"
	ReasonClusterDisabled      = "ClusterDisabled"
	ReasonUnreachable          = "Unreachable"
)

Reasons of the ControlPlaneConnected condition.

View Source
const (
	// DefaultEventsBufferBytes bounds a replica's events buffer.
	DefaultEventsBufferBytes = 64 << 20
	// DefaultEventsMaxBackoff bounds the wait between events stream
	// reconnects.
	DefaultEventsMaxBackoff = 10 * time.Second
)
View Source
const DefaultStatsInterval = 10 * time.Second

DefaultStatsInterval is how often a replica sends the request counts that changed.

View Source
const IdentitySecret = "inkwall-control-plane-identity" // #nosec G101 -- the Secret's name, not a credential

IdentitySecret holds the cluster's client certificate and key, in the operator's namespace: every replica reads it (their events streams use it), the leader writes it.

View Source
const TokenKey = "token" // #nosec G101 -- a data key, not a credential

TokenKey is the key of the enrollment token in its Secret.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connector

type Connector struct {
	Client client.Client
	// APIReader reads the kube-system Namespace (its UID identifies the
	// cluster), which the manager doesn't cache, and what a policy snapshot
	// changes, as it is now.
	APIReader client.Reader
	// Namespace is the operator's: the identity Secret is there, and so must
	// the enrollment token be.
	Namespace       string
	Replica         string
	OperatorVersion string
	// KubernetesVersion returns the API server's version, for Hello.
	KubernetesVersion func() string
	// CAFile trusts the control plane's server certificate; empty: the
	// system roots.
	CAFile string

	// Pods select each integration's proxy pods, for ClusterState (nil:
	// the defaults), and Disabled are the integrations the operator may
	// not wire, by name, with why.
	Pods     *integrations.Selectors
	Disabled map[string]string
	// EngineStale is how old a replica's engine report may be before
	// ClusterState leaves it out (default 30 s).
	EngineStale time.Duration

	// Poll is how often an idle connector looks again (default 5 s);
	// MinBackoff and MaxBackoff bound reconnects (default 1 s and 1 min).
	Poll, MinBackoff, MaxBackoff time.Duration
	// StatePoll is how often the leader looks for a change to send
	// (default 5 s); StateResend, how often it sends ClusterState even
	// unchanged (default 5 min).
	StatePoll, StateResend time.Duration
	// ApplyBackoff paces the retries of a policy snapshot write that
	// failed after its dry run passed (default: about 15 s in all).
	ApplyBackoff wait.Backoff
	// contains filtered or unexported fields
}

Connector keeps the cluster connected to the control plane. It runs on the leader.

func (*Connector) NeedLeaderElection

func (*Connector) NeedLeaderElection() bool

NeedLeaderElection implements manager.LeaderElectionRunnable.

func (*Connector) Start

func (c *Connector) Start(ctx context.Context) error

Start implements manager.Runnable.

type Forwarder

type Forwarder struct {
	Client          client.Client
	Namespace       string
	Replica         string
	OperatorVersion string
	CAFile          string
	// Dir holds the buffer ("" keeps it in memory: lost on restart);
	// MaxBytes bounds it (default DefaultEventsBufferBytes).
	Dir      string
	MaxBytes int64

	// Poll is how often an idle forwarder looks again (default 5 s);
	// Refused, how long it waits after the control plane said it doesn't
	// accept events, or keeps a stream that carries only request counts
	// before asking again (default 1 min); MinBackoff and MaxBackoff bound
	// reconnects (default 1 s and 10 s: lower than the leader's, so the
	// buffer drains soon after an outage); StatsInterval, how often the
	// request counts that changed are sent (default DefaultStatsInterval).
	Poll, Refused, MinBackoff, MaxBackoff, StatsInterval time.Duration

	// HasPolicy reports whether the bundle this replica serves has a policy
	// (distribution.Store.HasPolicy). Past a limit, the request counts of
	// the others are forgotten; nil forgets them all. Set before AddStats.
	HasPolicy func(id string) bool
	// contains filtered or unexported fields
}

Forwarder sends the security events and request counts of the engines connected to this replica to the control plane, on the replica's own events stream (0002 §5.3). It runs on every replica, with the cluster's certificate, which the leader keeps in the identity Secret. It buffers events only while the control plane accepts them; otherwise, as in Standalone mode, the engines' logs are the record. Request counts are sent only to a control plane that accepts them.

func (*Forwarder) Add

func (f *Forwarder) Add(b *eventsv1.EventBatch)

Add takes a batch from an engine (distribution.Server.Events). It never blocks the engine's stream.

func (*Forwarder) AddStats added in v0.3.0

func (f *Forwarder) AddStats(deltas []*eventsv1.PolicyStats)

AddStats takes what engines counted per policy since their previous reports (distribution.Server.Stats).

func (*Forwarder) NeedLeaderElection

func (*Forwarder) NeedLeaderElection() bool

NeedLeaderElection implements manager.LeaderElectionRunnable: every replica forwards its own engines' events.

func (*Forwarder) Start

func (f *Forwarder) Start(ctx context.Context) error

Start implements manager.Runnable.

Jump to

Keyboard shortcuts

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