-
Notifications
You must be signed in to change notification settings - Fork 65
Description
Problem
In a typical Kubernetes deployment (e.g., Falco Helm chart), falcoctl is often used in two phases:
- An init container runs
falcoctl artifact installto populate a shared volume with plugins/rules. - A sidecar container runs
falcoctl artifact followto keep them updated.
Currently, when the sidecar starts, it has no knowledge of what the init container has just installed. It treats the local state as "empty" or "unknown" and immediately queries the OCI registry (e.g., GHCR) to resolve tags and fetch manifests. This causes:
- Redundant network requests (Rate Limiting risks on GHCR).
- Unnecessary re-verification of artifacts that are already present.
Proposed Solution
Implement a "Write and Read" state mechanism to share context between commands via the filesystem.
1. Write State (artifact install)
Modify the install command to persist the digest of the installed artifact to a state file in the destination directory (e.g., alongside the plugin/rules files).
- Where:
install.go - Action: After a successful extraction, call
artifactstate.Write(destDir, ref, digest).
2. Read State (artifact follow)
Modify the follow command to check for this state file during initialization.
- Where:
follower.go - Action: In the
Newconstructor, attempt to read the persisted digest usingartifactstate.Read. - Logic: If a state is found, initialize the follower's
currentDigestwith it. This allows the follower to know immediately that the artifact is already at version X, potentially skipping the initial update check or download.
Benefits
- Traffic Reduction: Drastically reduces the number of requests to OCI registries during Pod startup/restart.
- Optimization: The sidecar becomes "aware" of the work done by the init container.