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

[RFC] Multi-Tenant Workload Identity #5209

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

matheuscscp
Copy link
Member

@matheuscscp matheuscscp commented Feb 23, 2025

In this RFC we aim to add support for multi-tenant workload identity in Flux, i.e. the ability to specify at the object-level which set of cloud provider permissions must be used for interacting with the respective cloud provider on behalf of the reconciliation of the object. In this process, credentials must be obtained automatically, i.e. this feature must not involve the use of secrets. This would be useful in a number of Flux APIs that need to interact with cloud providers, including all controllers except helm-controller.

Preview: https://github.com/fluxcd/flux2/blob/rfc-multi-tenant-workload-identity/rfcs/0010-multi-tenant-workload-identity/README.md

Umbrella issue for implementation: #5022

@matheuscscp matheuscscp added the area/rfc Feature request proposals in the RFC format label Feb 23, 2025
@matheuscscp matheuscscp force-pushed the rfc-multi-tenant-workload-identity branch 2 times, most recently from b795adf to 3034741 Compare February 23, 2025 04:33
@stefanprodan stefanprodan changed the title [RFC-0010] Multi-Tenant Workload Identity [RFC] Multi-Tenant Workload Identity Feb 23, 2025
@stefanprodan stefanprodan marked this pull request as draft February 23, 2025 10:39
@matheuscscp matheuscscp force-pushed the rfc-multi-tenant-workload-identity branch 15 times, most recently from 5a5f4ac to 614bbc8 Compare March 1, 2025 17:03
@matheuscscp matheuscscp force-pushed the rfc-multi-tenant-workload-identity branch 10 times, most recently from f505036 to 3e9b36a Compare March 8, 2025 01:36
@matheuscscp matheuscscp force-pushed the rfc-multi-tenant-workload-identity branch from af55097 to ac8a8de Compare April 7, 2025 09:11
@matheuscscp
Copy link
Member Author

matheuscscp commented Apr 7, 2025

I'm now addressing the offline comments I got during KubeCon EU 2025.

From @stealthybox:

An alternative to using service account tokens would be using a token whose subject string encodes a direct reference to the respective Flux resource, this way a resource would be its own identity. This is more secure than having a configuration knob to define another resource (a service account in this case) as the object identity, as it prevents another object in the same namespace from abusing the same service account/cloud permissions.

From @hiddeco:

We should move the interfaces in interfaces.go to multiple files with names matching the interface names themselves.

From @stefanprodan:

To avoid introducing kustomizations.spec.decryption.key.serviceAccountName for disambiguating single-tenant and multi-tenant workload identity we should instead introduce a binary flag in the controllers to switch to and enforce multi-tenant workload identity, e.g. --require-service-account-for-provider-auth

@matheuscscp
Copy link
Member Author

@stealthybox @hiddeco @stefanprodan Comments from KubeCon addressed, please feel free to do another pass/approve.

@matheuscscp matheuscscp force-pushed the rfc-multi-tenant-workload-identity branch from 6de8de0 to c76ea14 Compare April 7, 2025 17:34
Copy link
Member

@pjbgf pjbgf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@matheuscscp matheuscscp force-pushed the rfc-multi-tenant-workload-identity branch 4 times, most recently from 64e29f8 to 0f4cf9f Compare April 11, 2025 02:17
Copy link
Member

@hiddeco hiddeco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
@matheuscscp matheuscscp force-pushed the rfc-multi-tenant-workload-identity branch from 0f4cf9f to d0a69fe Compare April 12, 2025 13:41
Comment on lines +586 to +588
is authenticating with the Kubernetes API when applying resources. If
we used the same field for both purposes users would be forced to use
multi-tenancy for both cloud and Kubernetes API interactions.
Copy link
Member Author

@matheuscscp matheuscscp Apr 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Putting it like this, it actually doesn't sound like a bad idea after all. Why would you want to use multi-tenancy for Kubernetes RBAC but not for cloud? Or the opposite? It's hard for me to imagine a decent use case where multi-tenancy should apply only to one of those two. That said, users currently using multi-tenancy for RBAC would suddenly be forced to use it also for cloud if we used the same field for both things, and that would be a really bad breaking change.

With all of this in mind, if there is no justifiable use case of multi-tenancy only for RBAC or only for cloud, I propose we use the existing spec.serviceAccountName and existing --default-service-account, and introduce also a feature gate to avoid the breaking change, e.g. UseServiceAccountForDecryption. This feature gate can start opt-in and then change to opt-out later.

But I'm not so much hell bent on this idea, if we can find arguments or use cases of multi-tenancy only for RBAC or only for cloud I'm totally fine with giving up on this (the existing use cases of people using multi-tenancy for RBAC do not count, my point is that they should be using multi-tenancy for cloud as well if it was supported)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm but people could be using different cloud identities for decryption through secrets and not be using multi-tenant RBAC... Would that justify multi-tenancy for cloud but not for RBAC? 🤔 🤔 🤔

Comment on lines +590 to +597
In the `Bucket` API we have previously introduced the optional field `spec.sts`.
This field has configuration for interacting with the STS service of the cloud
provider, most specifically the `spec.sts.endpoint` field. In the specific case
of the `Bucket` API, there's also the field `spec.sts.provider`, which allows
using other STS configurations relavant only to the `generic` bucket provider,
whose underlying implementation uses the MinIO SDK (the AWS S3-compatible object
storage server). The same does not apply to the other Flux APIs, so we propose
introducing only a single optional field `spec.stsEndpoint` instead.
Copy link
Member Author

@matheuscscp matheuscscp Apr 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stefanprodan I changed this part, please review. I think spec.stsEndpoint is better for the other APIs, spec.sts makes sense only for Bucket

Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
…tial

Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/rfc Feature request proposals in the RFC format
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants