Add support for custom collectors#3
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a full custom collector framework that allows short-lived Kubernetes Jobs to gather node or cluster-scoped data and expose it to Rego policies via
input.cluster.collectors.New subcommand:
kvirtbp collectDeploys collector Jobs against a live cluster and writes the results to a collector-data JSON file.
Changes to
kvirtbp scan--collector-data(repeatable) — injects pre-collected data intoinput.cluster.collectors--collector-bundle/--collector-config— run inline collectors during scan without a separate collect step--policy-bundlenow auto-detected from_meta.bundlePathsin the collector-data file when not explicitly provided (--no-auto-bundleto opt out)--policy-bundlepointing to a directory of bundles evaluates each sub-bundle and merges findingsCollector configuration
Collectors are declared in a bundle's
metadata.jsonunder acollectorsarray (CollectorConfig):scope: once— single cluster-wide Job, output atinput.cluster.collectors["name"]["_cluster"]scope: per-node— one Job per node, output keyed by node nametolerations— pod tolerations so collectors can schedule on tainted nodes (e.g. control-plane)privileged,hostPID,hostNetwork,envfor advanced collectorsBundle improvements
--bundleoncollectis now repeatable; configs merged across bundles--save-bundlepersists resolved (possibly remote) bundles locally; multiple bundles saved tobundle-0/,bundle-1/, …bundle.SubBundles()detects whether a directory is a single bundle or a container of multiple bundlesbundle.SaveDir()copies a resolved bundle for reuse without re-fetchingExample collectors
examples/collectors/node-infonode-infoexamples/collectors/hugepageshugepagesBoth include OPA unit tests (13 tests total, all passing).
Internal packages
internal/collector—Collectorinterface,JobCollector,CollectorConfig,CollectorResult/CollectorMeta(with_metaenvelope),MergeAllinternal/bundle—Resolve,SaveDir,SubBundlesinternal/cli/collect.go— newcollectsubcommanddocs/collectors.md— full schema and usage guide