An owner reference is metadata that identifies the object responsible for managing another object. The managed object is the dependent. For example, a Pod can identify a ReplicaSet as its owner. section 14.1.3
Owner references determine lifecycle and control relationships:
- Kubernetes can store multiple owners, although most objects have one. section 14.1.3
- The garbage collector deletes a dependent when its owner is deleted; with multiple owners, all owners must be gone. section 14.1.3
- The controller field marks which owner actively controls the object. A controlled Pod should be managed through its controller rather than directly. section 14.1.3
- Changing a Pod's labels so it no longer matches a ReplicaSet selector removes the ReplicaSet reference and leaves the Pod unmanaged. section 14.3.3
- Deleting a ReplicaSet with --cascade=orphan preserves its Pods and removes the ReplicaSet from their ownerReferences. section 14.4.2
Inspecting a Pod's owner
Run `kubectl get po kiada-001 -o yaml` and inspect `metadata.ownerReferences`. The entry identifies `kind: ReplicaSet`, `name: kiada`, and `controller: true`, showing that the ReplicaSet controls the Pod.
Controller types differ in which object owns Pods directly. ReplicaSets own their Pods, while StatefulSets and DaemonSets also own their Pods directly; Deployments add a ReplicaSet between themselves and their Pods. section 16.1.4 section 17.1.2
$ kubectl get po kiada-001 -o yaml
apiVersion: v1
kind: Pod
metadata:
labels:
app: kiada
rel: stable
name: kiada-001
namespace: kiada
ownerReferences: #1
- apiVersion: apps/v1 #1
blockOwnerDeletion: true #1
controller: true #1
kind: ReplicaSet #1
name: kiada #1
uid: 8e19d9b3-bbf1-4830-b0b4-da81dd0e6e22 #1
resourceVersion: "527511" #1
uid: d87afa5c-297d-4ccb-bb0a-9eb48670673f
spec:
...
Inspect the complete ownerReferences entry, including the API version, owner kind, owner name, controller flag, and deletion behavior. section 14.1.3
