sigs.k8s.io/cluster-api@v1.7.1/docs/book/src/reference/owner_references.md (about) 1 # Owner References 2 3 4 Cluster API uses [Kubernetes owner references](https://kubernetes.io/docs/concepts/overview/working-with-objects/owners-dependents/) to track relationships between objects. These references are used for Kubernetes garbage collection, which is the basis of Cluster deletion in CAPI. They are also used places where the ownership hierarchy is important, for example when using `clusterctl move`. 5 6 CAPI uses owner references in an opinionated way. The following guidelines should be considered: 7 1. Objects should always be created with an owner reference to prevent leaking objects. Initial ownerReferences can be replaced later where another object is a more appropriate owner. 8 2. Owner references should be re-reconciled if they are lost for an object. This is required as some tools - e.g. velero - may delete owner references on objects. 9 3. Owner references should be kept to the most recent apiVersion. 10 - This ensures garbage collection still works after an old apiVersion is no longer served. 11 4. Owner references should not be added unless required. 12 - Multiple owner references on a single object should be exceptional. 13 14 15 16 17 ## Owner reference relationships in Cluster API 18 19 The below tables map out the a reference for ownership relationships for the objects in a Cluster API cluster. The tables are identical for classy and non-classy clusters. 20 21 22 Providers may implement their own ownership relationships which may or may not map directly to the below tables. 23 These owner references are almost all tested in an [end-to-end test](https://github.com/kubernetes-sigs/cluster-api/blob/caaa74482b51fae777334cd7a29595da1c06481e/test/e2e/quick_start_test.go#L31). Lack of testing is noted where this is not the case. CAPI Providers can take advantage of the e2e test framework to ensure their owner references are predictable, documented and stable. 24 25 Kubernetes core types 26 27 | type | Owner | Controller | Note | 28 |-----------|---------------------|------------|--------------------------------------------| 29 | Secret | KubeadmControlPlane | yes | For cluster certificates | 30 | Secret | KubeadmConfig | yes | For bootstrap secrets | 31 | Secret | ClusterResourceSet | no | When referenced by CRS. Not tested in e2e. | 32 | ConfigMap | ClusterResourceSet | no | When referenced by CRS | 33 34 ## Core types 35 36 | type | Owner | Controller | Note | 37 |---------------------|---------------------|------------|----------------------------| 38 | ExtensionConfig | None | | | 39 | ClusterClass | None | | | 40 | Cluster | None | | | 41 | MachineDeployments | Cluster | no | | 42 | MachineSet | MachineDeployment | yes | | 43 | Machine | MachineSet | yes | When created by MachineSet | 44 | Machine | KubeadmControlPlane | yes | When created by KCP | 45 | MachineHealthChecks | Cluster | no | | 46 47 48 49 ## Experimental types 50 | type | Owner | Controller | Note | 51 |----------------------------|--------------------|------------|--------------------------| 52 | ClusterResourcesSet | None | | | 53 | ClusterResourcesSetBinding | ClusterResourceSet | no | May have many CRS owners | 54 | MachinePool | Cluster | no | | 55 56 57 ## KubeadmControlPlane types 58 | type | Owner | Controller | Note | 59 |-----------------------------|--------------|------------|------| 60 | KubeadmControlPlane | Cluster | yes | | 61 | KubeadmControlPlaneTemplate | ClusterClass | no | | 62 63 64 ## Kubeadm bootstrap types 65 | type | Owner | Controller | Note | 66 |-----------------------|--------------|------------|-------------------------------------------------| 67 | KubeadmConfig | Machine | yes | When created for Machine | 68 | KubeadmConfig | MachinePool | yes | When created for MachinePool | 69 | KubeadmConfigTemplate | Cluster | no | When referenced in MachineDeployment spec | 70 | KubeadmConfigTemplate | ClusterClass | no | When referenced in ClusterClass | 71 72 ## Infrastructure provider types 73 | type | Owner | Controller | Note | 74 |-------------------------------|--------------|------------|---------------------------------------------| 75 | InfrastructureMachine | Machine | yes | | 76 | InfrastructureMachineTemplate | Cluster | no | When created by cluster topology controller | 77 | InfrastructureMachineTemplate | ClusterClass | no | When referenced in a ClusterClass | 78 | InfrastructureCluster | Cluster | yes | | 79 | InfrastructureClusterTemplate | ClusterClass | no | | 80 | InfrastructureMachinePool | MachinePool | yes | | 81 82