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

Allow setting a default service account for impersonation #2340

Closed
2 tasks done
Tracked by #2308
stefanprodan opened this issue Jan 25, 2022 · 4 comments
Closed
2 tasks done
Tracked by #2308

Allow setting a default service account for impersonation #2340

stefanprodan opened this issue Jan 25, 2022 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@stefanprodan
Copy link
Member

stefanprodan commented Jan 25, 2022

Given that RFC-0003 needs more debating, I propose we add an optional flag --default-service-account to kustomize-controller and helm-controller so that cluster admins can setup Flux on multi-tenant clusters without having to enforce tenant impersonation using an admission controller.

When the flag is set to a value that's not empty string, all Kustomizations and HelmReleases which don't have spec.serviceAccountName specified, they will use the service account name provided by --default-service-account in the namespace of the object.

When --default-service-account is not set, Flux will behave the same as before, where it uses the cluster-admin role binding to reconcile resource.

Components:

  • kustomize-controller
  • helm-controller
@makkes
Copy link
Member

makkes commented Jan 28, 2022

I like this enhancement very much as it simplifies deploying Flux in multi-tenant scenarios a lot by not having to deploy Gatekeeper or Kyverno along with it.

@stefanprodan
Copy link
Member Author

All done!

@lictw
Copy link

lictw commented Oct 27, 2022

Maybe add a ability to force SA inheritance by child KS? Suppose I want to implement a restricted SA for single tenant, not cluster-wide, what should I do? Now tenant can create child KS object without parent SA and do what they want.

@stefanprodan
Copy link
Member Author

@lictw you could create a policy for Kyverno to enforce the SA only to some namespaces:

apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
  name: flux-multi-tenancy
spec:
  validationFailureAction: enforce
  rules:
    - name: serviceAccountName
      exclude:
        resources:
          namespaces:
            - flux-system
      match:
        resources:
          kinds:
            - Kustomization
            - HelmRelease
      validate:
        message: ".spec.serviceAccountName is required"
        pattern:
          spec:
            serviceAccountName: "?*"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants