Documentation
¶
Overview ¶
Package agent runs the in-cluster continuous loop: collect → evaluate per target → ClusterReadiness CRD status (always) → push snapshot to the server on content change. The agent's local value never depends on server availability (spec §3).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var AgentVersion = "dev"
AgentVersion is stamped into CRD status and push envelopes. The CLI sets it from the build version; "dev" otherwise.
Functions ¶
func CleartextPushWarning ¶ added in v0.2.0
CleartextPushWarning says why pushing to serverURL with token is unsafe, or returns "": a bearer token sent over plain http:// to a host that is not loopback crosses the network in the clear, where anyone on the path can replay it — and the shared ingest token may push as any cluster.
func Run ¶
func Run(ctx context.Context, clients collect.Clients, dyn dynamic.Interface, apiext apiextensionsclient.Interface, k kb.KB, cfg Config) error
Run executes the continuous loop until ctx is canceled (returns nil — a cancel is a graceful stop, not an error). The first tick runs immediately; later ticks fire every Interval ±10% jitter, each under tickTimeout. Every tick logs one line and updates the metrics; tick errors are never fatal: the loop never dies on a tick error. With HealthAddr set, /healthz, /readyz and /metrics are served until Run returns.
Types ¶
type Config ¶
type Config struct {
Interval time.Duration // default 10m, min 1m
ServerURL string // optional; "" = CRD-only mode
ServerToken string // bearer for push
ClusterName string // human label sent to server; default = ClusterID
CRName string // default crd.DefaultName
TeamLabel string // default "team"
ForceSyncEvery time.Duration // default 1h: push even if hash unchanged
// Targets, when non-empty, are the source of truth for spec.targets:
// every tick reconciles the CR to them, overriding kubectl edits. Empty
// leaves spec.targets to whoever edits the CR. applyDefaults normalizes
// each to MAJOR.MINOR ("v1.38" → "1.38", "1.37.2" → "1.37").
Targets []string
// SkipCRDManagement leaves the CRD alone entirely (--manage-crd=false):
// no read, no schema upgrade. The default keeps it in step with the
// embedded manifest at startup.
SkipCRDManagement bool
// HealthAddr is where /healthz, /readyz and /metrics listen, e.g.
// ":8081"; "" serves none of them.
HealthAddr string
// Logger receives the startup line and one line per tick; nil uses
// slog.Default().
Logger *slog.Logger
}