DopplerHQ / kubernetes-operator

Apache License 2.0
44 stars 18 forks source link

Allow reconciliation of dopplersecret resources with refs in same namespace #46

Closed nmanoogian closed 1 year ago

nmanoogian commented 1 year ago

This PR updates the reconciliation behavior introduced in v1.2.0 to accommodate multi-tenancy use cases.

Before v1.2.0, the operator could reconcile a DopplerSecret in any namespace with references to secrets in any other namespaces. This posed a security risk because a user with access to a single namespace in the cluster could use the operator to read secrets from Doppler using token secrets that they couldn't read themselves.

In v1.2.0, the behavior was changed so that a DopplerSecret couldn't be reconciled unless it was in the same namespace as the operator itself (i.e. doppler-operator-system). This worked to address the security issue but made things significantly harder for teams with multi-tenant use cases.

This PR (which will likely ship in v1.3.0) updates the behavior again. DopplerSecrets in the operator's namespace behave as they did in v1.2.0, in that they can reference secrets in their own or any other namespaces. Additionally, the operator will reconcile DopplerSecrets in other namespaces if all references are in the same namespace as the DopplerSecret itself. For example, a DopplerSecret in the app1 namespace can reference token secrets and managed secrets in app1 only.

Reminder: As a convenience, the namespace may be omitted from secret references in the DopplerSecret resource and the operator will use the DopplerSecret's namespace as the default. This behavior has been in place before v1.2.0 and has not changed.

Closes ENG-5089 Closes #45 Closes #31 Closes #28

Thanks to all issue submitters for weighing in on this! If you feel that this behavior change won't work for your use cases, please let me know in your original issue and we can brainstorm.

nmanoogian commented 1 year ago

Force push fixes incorrect logging order and flips around token/managed ordering (no-op) for consistency with other parts of the codebase