How kalexmills/krt-lite works
Project type and purpose
• This is a Go library (not a full-stack app) for building Kubernetes controllers using a dependency-graph–based event propagation model.
• It provides primitives for handling Kubernetes (and other) events, modeling intermediate state, and wiring up “syncer” nodes that react to state changes.
File structure
• Top-level Go files (core.go, informer.go, fetch.go, syncer.go, index.go) define the core engine and interfaces.
• Sub-packages/folders implement supporting data structures and patterns:
– bimap/ (state mapping)
– fifo/ (queue and ring buffer for event delivery)
– derived_collection.go, merged_collection.go, joined_collection.go, static_collection.go, scale.go (transformations on streams of events)
– singleton.go (singleton‐value collections)
• Tests and conformance_test.go ensure each piece conforms to the dependency‐graph contract.
Extract insights from README
• It’s a drop-in replacement for istio/krt core, minus Istio dependencies.
• Key concepts: dependency graph, intermediate state as events, multiple event sources.
Main components
a. Event Sources
– Kubernetes API informer (informer.go)
– Other external sources plugged via Fetcher interface (fetch.go)
b. Core Engine
– Graph builder / core (core.go)
– Syncer nodes (syncer.go)
c. State Management
– Index/cache (index.go)
– bimap (bimap/bimap.go)
– fifo queues (fifo/queue.go, fifo/ringbuf.go)
d. Collection Transformations
– StaticCollection, DerivedCollection, MergedCollection, JoinedCollection, Scale
e. Controller Output
– Syncer handlers push changes back to Kubernetes or external sinks
Relationships and data flows
• Syncers may in turn emit new events back into the graph (loop)
• Queues/bimaps sit alongside nodes as internal implementation details
Architectural patterns
• Reactive dependency graph (observer pattern)
• Functional‐style collection transformations (map, flatMap, merge, join, scale)
• Backpressure via FIFO/Ringbuffer
• Decoupling via interfaces (Fetcher, Syncer)
Technology and framework callouts
• Language: Go (Go modules, go test)
• CI: golang-ci, coverage badges, Makefile targets
• Components: use rounded rectangles for major subsystems (Engine, Index, Collections, Syncers)
– Blue for core engine packages
– Green for state/data structures (bimap, fifo)
– Orange for collection transformations
– Purple for external/event sources and sinks