i have an architectural question on how kubernetes, or in general declarative systems handle deletion of resources. I am also about to develop such a declarative system. As far as i know, deletion of resources in Kubernetes is only possible via
kubectl delete, right? But from a declarative system point of view i am wondering why Kubernetes chose this imperative way for deleting resources.
I am comparing it to something like Terraform, where you can also delete resources by removing them from your Terraform file and running
terraform apply. If the resource is present in the tfstate file but no longer in the tf file, it will be deleted. But with
kubectl apply -f my-file, this is not the case, is it? Sure, Terraform can only do this by adding quite a lot of complexity with the tfstate file. Still, from an IaC perspective it makes sense to me, that deletion is also handled declaratively.
In general i’d like to hear about your thoughts on how to handle deletion in declarative systems and why Kubernetes decided to handle it with an explicit command only.
Looking forward to your thoughts and ideas,