tinycodinglm / sys /sys-0027.jsonl
winapiadmin's picture
Upload folder using huggingface_hub (part 19)
034ba67 verified
|
Raw History Blame
1.3 kB
opencode trace
System You are an expert software engineer.

You are an expert software engineer.

User

How do Kubernetes informers and watches work?

Assistant

Informers maintain a local cache of API server resources via watches.

Architecture:

  • SharedInformerFactory creates typed informers per resource
  • Each informer starts a long-running watch to the API server
  • Events (Add/Update/Delete) populate a Thread-Safe Store
  • Listers read from local cache (no API calls)
  • HasSynced() returns true when initial list is complete

Pattern:

  1. factory.Core().V1().Pods() -> SharedInformer
  2. informer.Informer().AddEventHandler(ResourceEventHandlerFuncs{...})
  3. informer.Lister().Pods(ns).Get(name) -- reads from cache
  4. WaitForCacheSync before processing

Tombstone handling: When a delete event is missed, the informer receives a DeletedFinalStateUnknown tombstone containing the last known object. Controllers must type-assert through this.

Custom indexers: Controllers can register index functions for efficient lookups (e.g., by controller UID).