crossplane-runtime icon indicating copy to clipboard operation
crossplane-runtime copied to clipboard

Consider supporting `connectionSecretDeletionPolicy`

Open hasheddan opened this issue 4 years ago • 7 comments

What problem are you facing?

Currently, managed resources support setting deletionPolicy in the spec to either Delete (default) or Orphan. This allows users to remove a managed resource from the Kubernetes API without it being deleted externally. However, when a managed resource is deleted with deletionPolicy: Orphan, its connection Secret is still cleaned up in the cluster. This makes sense in most cases (similar to how it usually makes sense to delete the infrastructure externally when the managed resource is deleted), but it does make it inconvenient to migrate resources from one cluster to another while preserving all connection details. Some external APIs only return full connection details when the resource is initially created, so later "importing" an existing external resource into the cluster will not provide the full connection information.

How could Crossplane help solve your problem?

Introducing a common connectionSecretDeletionPolicy (or nesting a deletionPolicy under writeConnectionSecretToRef / publishConnectionDetails) to all managed resources will make this behavior configurable. By default, the policy should be Delete, but some cases, such as those listed above would be candidates for using Orphan. I imagine this functionality will become even more useful once additional Secret "sinks" are supported, as described in https://github.com/crossplane/crossplane/issues/2366.

hasheddan avatar Jun 23 '21 12:06 hasheddan

Is there any chance we could get away with just lumping this in with the existing deletionPolicy: Orphan? i.e. Always leave and orphan the connection secret if the managed resource is orphaned?

negz avatar Jun 23 '21 19:06 negz

@negz possibly, if a user wanted the connection secret cleaned up after deletionPolicy: Orphan they could just manually delete it. We could always change that to be the default behavior and then add the additional field in the future, making the behavior such that secrets are orphaned by default if deletionPolicy: Orphan unless otherwise overridden by the future field.

hasheddan avatar Jun 23 '21 20:06 hasheddan

Definitely worth considering. I don't feel strongly here - just looking for places to keep our API a little simpler. I like the idea of being able to handle this simply (i.e. by orphaning secrets) now, while leaving an avenue over to control that behaviour in future.

negz avatar Jun 23 '21 20:06 negz

Reusing deletionPolicy makes sense to me too with the default of Delete.

muvaf avatar Nov 24 '21 10:11 muvaf

Some external APIs only return full connection details when the resource is initially created, so later "importing" an existing external resource into the cluster will not provide the full connection information.

Facing this issue with provider-sql here. When a resource such as a MySQL user or PostgreSQL role is deleted with deletionPolicy: Orphan and gets recreated, writeConnectionSecretToRef will generate an empty secret :(

It'd be really nice if deletionPolicy would be inherited/reused for the secret.

luis-alen avatar Apr 22 '22 11:04 luis-alen

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Aug 13 '22 07:08 stale[bot]

Crossplane does not currently have enough maintainers to address every issue and pull request. This issue has been automatically marked as stale because it has had no activity in the last 90 days. It will be closed in 14 days if no further activity occurs. Leaving a comment starting with /fresh will mark this issue as not stale.

github-actions[bot] avatar Sep 04 '24 01:09 github-actions[bot]