Skip to content

How to handle CR and secret references set in a CR spec ? #1437

Closed as not planned
@derlin

Description

@derlin

TL;DR: how to support a one-to-many relationship between primary to secondary resource, in which the secondary resource doesn't know which primary resources depends on it ?

Take the https://external-secrets.io operator as an example, which fetches secrets from a secret manager (e.g. Hashicorp Vault) and creates Secret.

An ExternalSecret CR has a secretStoreRef in the spec, which references (with namespace and name) a (Cluster)SecretStore CR. The latter in turn has a reference (secretRef) to a Secret that holds the auth information to the secret manager.
When reconciling an ExternalSecret, we thus need to pull a SecretStore and a Secret. However, those two are not really managed, in the sense that they are not reconciled, just holding configuration information, and should never be created/updated/deleted by the operator.

I am trying to understand how to implement a similar mechanism with JOSDK. I tried using dependent resources, but the problem is, I cannot provide a SecondaryToPrimaryMapper as there is no way to know from a SecretStore which ExternalSecret may reference it. Same goes for Secret to SecretStore. Moreover, the SecretStore and Secret may be referenced by many ExternalSecret resources.

Does the SDK provide utilities for this use case, or do I need to manually do the lookup using the kubernetes client ? How would you implement this ?

related question: still using the external-secrets example, the ExternalSecret reconciler needs to generate a secret (implemented as a CRUDKubernetesDependentResource) and also to check some stuff in the vault. I thus need to access the SecretStore (and its related Secret) in both the reconciler's reconcile method, and in the dependent secret's desired method. I cannot find a way to share this SecretStore between the two. Is there a way to avoid fetching the config twice ? (I guess it is not a problem if the call is cached, but I struggle in understanding what is cached how. If I use the kubernetes client directly, I guess there is no caching, right ?

Let me know if something is unclear.

Metadata

Metadata

Assignees

Labels

lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions