cocoon-operator manages VM-backed pod lifecycles through two CRDs:
Both reconcilers are built on controller-runtime and consume the typed CRD shapes shipped from cocoon-common/apis/v1.
The binary entry point is main.go; the reconcilers themselves live in subpackages so each one is independently testable:
cocoon-operator/
├── main.go # manager wiring + flag parsing
├── cocoonset/ # CocoonSet reconciler, pod builders, status diff
├── hibernation/ # CocoonHibernation reconciler
└── snapshot/ # snapshot.Registry interface consumed by both reconcilers
┌──────────────────────────────────────────────────────────────────┐
│ cocoon-operator │
│ │
│ ┌────────────────────────┐ ┌─────────────────────────────┐ │
│ │ cocoonset.Reconciler │ │ hibernation.Reconciler │ │
│ │ - finalizer + GC │ │ - HibernateState patches │ │
│ │ - main → subs → tbs │ │ - registry manifest probe │ │
│ │ - patch /status │ │ - Conditions │ │
│ └────────┬───────────────┘ └────────────┬────────────────┘ │
│ │ │ │
│ ▼ ▼ │
│ ┌────────────────────┐ ┌──────────────────────┐ │
│ │ controller-runtime │ │ snapshot.Registry │ │
│ │ Manager │ │ (HTTP via │ │
│ │ - leader election │ │ registryclient) │ │
│ │ - metrics :8080 │ └──────────────────────┘ │
│ │ - probes :8081 │ │
│ └────────────────────┘ │
└──────────────────────────────────────────────────────────────────┘
See CocoonSet reconcile loop and CocoonHibernation reconcile loop for the two reconcilers in detail, and Observability for how failures surface as Events and metrics.