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 ¶
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.
const ( // DefaultEventsBufferBytes bounds a replica's events buffer. DefaultEventsBufferBytes = 64 << 20 // DefaultEventsMaxBackoff bounds the wait between events stream // reconnects. DefaultEventsMaxBackoff = 10 * time.Second )
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.
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
// ProxyPods selects the proxies' pods, for ClusterState (default:
// Traefik's default labels).
ProxyPods labels.Selector
// 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 ¶
NeedLeaderElection implements manager.LeaderElectionRunnable.
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 (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).
Poll, Refused, MinBackoff, MaxBackoff time.Duration
// contains filtered or unexported fields
}
Forwarder sends the security events 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 only while the control plane accepts events; otherwise, as in Standalone mode, the engines' logs are the record.
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) NeedLeaderElection ¶
NeedLeaderElection implements manager.LeaderElectionRunnable: every replica forwards its own engines' events.