Thursday, August 1, 2019

Kubernetes has an interesting behavior due to its garbage collector. Resources has object references and the collector collects object where they once had an owner and now they don't. These objects are deleted automatically. When the dependents are deleted automatically, it is called cascading deletion. There are two types of cascading deletion- These are foreground and background.
If the object is deleted without deleting its dependents automatically, the dependents are said to be orphaned.
Every dependent object has a metadata field named ownerReferences that points to the owning object. However, sometimes Kubernetes sets the ownerReferences value automatically This is true for objects created or adopted by the ReplicationController, ReplicaSet, StatefulSet, DaemonSet, Deployment, Job and CronJob.
The ownerReference field can be dumped with the metadata when we use the kubectl command to display the resource. Manual override of the ownerReference is risky because it does not change and if improperly specified the objects may be orphaned.
Cross-namespace owner references are not allowed by design. Moreover the owner and the dependents have to be in the same or smaller scope. For example, namespace scoped dependents can only specify owners in the same namespace not owners in different namespace. They can however specify owners that are cluster scoped. Cluster-scoped dependents can only specify cluster scoped owners but not namespace scoped owners
When the object is deleted, and its dependents are deleted, the deletion is cascading. The foreground cascading deletion and the background cascading deletion differ in the delay for the deletion. The foreground deletion will put the root object in the 'deletion in progress' state whereas the background object will delete the owner object immediately. The dependent objects are deleted subsequently while it is the reverse in foreground.
The deletion policy is specified by setting the propagationPolicy field on the deleteOptions. The values specified can be one of orphan, foreground or background. When deleting deployments we must use propagationPolicy:Foreground to delete not only the ReplicaSets created but also their pods.
#codingexercise
#codingexercise
int getToDo(List<Task> tasks) {
int count = 0;
For (Task task :tasks) {
If (task.Completed == false) {
count += 1;
}
}
Return count;

No comments:

Post a Comment