Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Watch Secret permission introduced by PR #963 breaks dynamic low-privilege multi-tenant set-ups #1064

Closed
armingerten opened this issue Dec 2, 2022 · 18 comments

Comments

@armingerten
Copy link
Contributor

Which component

controller

Describe the bug

Due to the implementation of #963 , versions of the sealed secrets controller >= v0.19.0 are no longer installable in dynamic low-privilege multi-tenant environments. The properties of the environment are:

  • multi-tenant: Namespaces are isolated "per tenant"
  • low-privilege: The sealed secret controller must only access resources of kind Secret in specific namespaces; No ClusterRoleBinding can be used.
  • dynamic: Namespaces are added/removed in a high frequency.

The implementation of #568 already allows watching only specific namespaces. However, this static list must be adapted whenever a namespace is added / removed.

Possible solutions

Dynamically create Secret for namespaces that contain SealedSecret resources

Whenever the sealed secret controller picks up a new SealedSecret resource, it creates a watch for Secret resources within the same namespace, unless a watch already exists. Whenever a SealedSecret resource is deleted, the watch for Secret resources within the same namespace is removed, if it was the last SealedSecret in the same namespace.

Watch Namespaces for specific labels to include

Instead of maintaining a static list of namespaces when deploying the controller, the controller could watch namespace resources for a specific label (e.g. sealed-secrets: enabled). If the label is present, the controller creates watches for Secret (and SealedSecret?) resources.

Feature flag for #963

Another option could be a feature flag to disable the behavior introduced by #963 .

@armingerten armingerten added the triage Issues/PRs that need to be reviewed label Dec 2, 2022
@armingerten
Copy link
Contributor Author

This issue also relates to #233 .

@agarcia-oss agarcia-oss added bug and removed triage Issues/PRs that need to be reviewed labels Dec 13, 2022
@alemorcuq
Copy link
Collaborator

alemorcuq commented Dec 15, 2022

Hi, @armingerten.

Thanks for reporting this. Just to confirm I understand the issue here, you are using a single Sealed Secrets controller that watches for Sealed Secrets in all namespaces. However, this controller should not have access to the secrets in all namespaces but just in the ones that have Sealed Secrets. Is that right?

I understand the problem arises when adding new namespaces. The controller can see the Sealed Secrets in these new namespaces but not the Secrets, as you don't want to give the controller permission to see the Secrets in all namespaces (which makes total sense). Did I get that right?

Also, thanks for the proposed solutions. I think I'm leaning more towards (1), as (2) would disrupt the way users use Sealed Secrets (having to add a new label) and (3) is a bit ugly.

@armingerten
Copy link
Contributor Author

Thanks for reporting this. Just to confirm I understand the issue here, you are using a single Sealed Secrets controller that watches for Sealed Secrets in all namespaces. However, this controller should not have access to the secrets in all namespaces but just in the ones that have Sealed Secrets. Is that right?

Correct. I am using one Sealed Secrets controller for most namespaces. Some namespaces (i.e. namespaces containing critical infrastructure components) are not considered for Sealed Secrets.

I understand the problem arises when adding new namespaces. The controller can see the Sealed Secrets in these new namespaces but not the Secrets, as you don't want to give the controller permission to see the Secrets in all namespaces (which makes total sense). Did I get that right?

Exactly.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 5, 2023

This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.

@github-actions github-actions bot added the Stale label Jan 5, 2023
@tewfik-ghariani
Copy link
Contributor

#Do_not_close

@github-actions github-actions bot removed the Stale label Jan 6, 2023
@github-actions
Copy link
Contributor

This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.

@github-actions github-actions bot added the Stale label Jan 22, 2023
@armingerten
Copy link
Contributor Author

/bump

@alemorcuq
Copy link
Collaborator

We don't want to add the complexity in #1081 to the controller, so we will be working on a different solution to this problem.

@josvazg
Copy link
Collaborator

josvazg commented Jan 23, 2023

We will open a couple of separate issues due to this:

@github-actions
Copy link
Contributor

github-actions bot commented Feb 8, 2023

This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.

@github-actions github-actions bot added the Stale label Feb 8, 2023
@tewfik-ghariani
Copy link
Contributor

#Not_stale

@github-actions github-actions bot removed the Stale label Feb 9, 2023
@github-actions
Copy link
Contributor

This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2023

Due to the lack of activity in the last 7 days since it was marked as "stale", we proceed to close this Issue. Do not hesitate to reopen it later if necessary.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 5, 2023
@tewfik-ghariani
Copy link
Contributor

#Not_Stale

@josvazg
Copy link
Collaborator

josvazg commented Mar 6, 2023

@tewfik-ghariani @armingerten with #1118 merged we expect your use case can be covered by setting the new Helm chart value skipRecreate to false.

Please, let us know how it goes or if you have any concerns.

@tewfik-ghariani
Copy link
Contributor

@josvazg Thank you so much for working on that!

@alemorcuq
Copy link
Collaborator

Hi, @tewfik-ghariani, @armingerten. A new version was released including a flag to disable secret recreation. Thanks for your patience.

@tewfik-ghariani
Copy link
Contributor

Hi @alemorcuq , thank you so much for the follow-up!

Unfortunately, I have encountered an bug after enabling it. I created a new issue for it: #1151

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants