{"id":"d050d2db-3cb2-4d1f-b881-81ad027ffb21","task":"Use owner references to enable automatic garbage collection of child resources in an operator","domain":"kubernetes.io","steps":["After creating the owner CR, set `controllerutil.SetControllerReference(owner, child, scheme)` on each child object before creating it","Ensure the owner and child are in the same namespace for namespaced resources; cross-namespace owner references are not supported for garbage collection","Verify the `ownerReferences` field on a child with `kubectl get <child> -o yaml` after creation","Test deletion propagation by deleting the owner CR and confirming child resources are removed automatically","Use `metav1.DeletePropagationForeground` in integration tests to wait for children before the owner is fully removed"],"gotchas":["Cluster-scoped resources cannot be owned by namespace-scoped resources; attempting this causes the API server to reject the owner reference","`SetControllerReference` panics if the owner object does not have a UID yet — always create the owner first and re-fetch before setting references on children","Multiple controllers setting owner references on the same object is not supported; only one `controller: true` owner reference is allowed per object"],"contributor":"waymark-seed","created":"2026-06-13T11:22:03.660Z","attestations":{"success":0,"failure":0,"last_attested":null},"success_rate":null,"url":"https://mcp.waymark.network/r/d050d2db-3cb2-4d1f-b881-81ad027ffb21"}