kudobuilder / kudo

Kubernetes Universal Declarative Operator (KUDO)
https://kudo.dev
Apache License 2.0
1.17k stars 103 forks source link

Prevent deletion of certain resources when uninstalling an instance #1785

Open bearpaws opened 3 years ago

bearpaws commented 3 years ago

What would you like to be added:

For certain resources created by an operator during instance installation, provide a way to optionally retain those resources when the instance is uninstalled.

During re-installation of an instance with the same name, KUDO should detect that the resource already exists and not overwrite it.

This could, for example, be controlled via an annotation on the resource:

kind: Secret
metadata:
  annotations:
    "kudo.dev/deletion-policy": "retain"

Why is this needed:

For example, an operator may install a database and generate a random Secret that contains the credentials for the database. The database is persisted on a PVC. When the instance is uninstalled, KUDO will not delete the PVC but will delete the Secret. If attempting to reuse the retained PVC, the credentials are lost.