In Kubernetes, some objects are owners of other objects. Owners and dependents are a parent-child relationship present in Kubernetes. For example, a ReplicaSet is the owner of a set of Pods. These owned objects are dependents of their owner.
Ownership is distinct from the labels and selectors mechanism used by some resources. Consider a Service that generates EndpointSlice objects. Labels are used by the Service to allow the control plane to determine which EndpointSlice objects are associated with that Service. In addition to the labels, each EndpointSlice that is managed on behalf of a Service has an owner reference. Owner references allow different parts of Kubernetes to avoid interfering with objects over which they have no control.
Dependent objects have a metadata.ownerReferences field that references their owner object. The object name and a UID within the same namespace as the dependent object constitute a valid owner reference. This field is automatically set by Kubernetes for objects that are dependent on other objects, such as ReplicaSets, DaemonSets, Deployments, Jobs and CronJobs, and ReplicationControllers. You can also manually configure these relationships by changing the value of this field. However, you usually don't need to and can let Kubernetes manage the relationships automatically.
Dependent objects also have an ownerReferences.blockOwnerDeletion field that takes a Boolean value and controls whether specific dependents can block garbage collection from deleting their owner object. Kubernetes automatically sets this field to true if a controller sets the value of the metadata.ownerReferences field. You can also manually change the value of the blockOwnerDeletion field to control which dependents prevent garbage collection.
By design, cross-namespace owner references are not permitted. Namespaced dependents can specify cluster-scoped or namespaced owners.. The dependent must be in the same namespace as the namespaced owner. If it does not, the owner reference is considered absent, and the dependent is subject to deletion once all owners have been verified absent. When you delete the owner, you also delete the dependents.
Recommended Labels
Kubectl is not the only tool for managing Kubernetes objects. Dashboards, CLIs, and other tools are available to assist you, and you can use one or a combination of them.
Recommended labels are a set of labels that allow your tools to communicate with one another by describing items in a way that all tools can understand.
The recommended labels, in addition to supporting tooling, describe applications in a way that can be queried. In a production Kubernetes cluster with thousands of running objects, you must manage them efficiently. Kubernetes suggests using recommended labels to standardize the management of your objects.
You can learn more about the recommendations here.
This brings me to the end of this post.
Thank you for your time.
コメント