The olm-book mentions about dependency resolution during install time, can you please also describe how uninstall/cleanup works.
Does the OLM keep reference counter of dependent operators when its a shared dependency ? How to cleanup the dependent operators and when to do this?
olm-book : https://operator-framework.github.io/olm-book/docs/operator-dependencies-and-requirements.html
I can explain on how
operator-sdk cleanup
command works while uninstalling an operator bundle/packagemanifest managed by OLM.The first step of the process is to identify and remove the subscription so that we stop any upgrades or further installs. Followed by this, we get the ClusterServiceVersion for the particular operator which is to be uninstalled from the subscription itself. When OLM creates resources it adds owner references/owner label to every namespaced/cluster scoped resource specified in the CSV. Hence, when a CSV is deleted the OLM garbage collector identifies the dependent resources through the owner references and deletes them.
If you want to cleanup the operator manually, I would suggest to just remove the ClusterServiceVersion referenced in installplan and leave it to the OLM and Kubebuilder GC to delete the resources.