-
Notifications
You must be signed in to change notification settings - Fork 692
Description
Part of: #5022
In multi-tenant clusters, users normally set the optional controller flag --default-service-account in kustomize-controller and helm-controller. This dictates that any Flux Kustomization and HelmRelease objects must either specify the field .spec.serviceAccountName or use the value of --default-service-account as the name of the ServiceAccount in the same namespace of the object that needs to be impersonated for the reconciliation.
After RFC-0010, Flux now supports .spec.serviceAccountName for most APIs and also .spec.decryption.serviceAccountName for Kustomization. For KubeConfig Workload Identity in the Kustomization and HelmRelease APIs, the ConfigMap pointed at by .spec.kubeConfig.configMapRef may specify the field .data.serviceAccountName. This creates three classes of ServiceAccount name fields that need to be locked down on multi-tenant clusters:
--default-service-accountmust be implemented across all Flux controllers, for enforcing multi-tenancy lockdown over.spec.serviceAccountNamefields. Only kustomize-controller and helm-controller currently implement this flag.--default-decryption-service-accountmust be implemented in kustomize-controller, for enforcing multi-tenancy lockdown over the.spec.decryption.serviceAccountNamefield of theKustomizationAPI.--default-kubeconfig-service-accountmust be implemented in both kustomize-controller and helm-controller, for enforcing multi-tenancy lockdown over the.data.serviceAccountNamefield in ConfigMaps pointed at by the.spec.kubeConfig.configMapReffield present in theKustomizationandHelmReleaseAPIs.
For the implementation we must define three constants in the auth package, one for each controller flag. The file can be controller_flags.go (we should rename feature_gate.go to feature_gates.go). The main.go of each controller must import and use the relevant constants accordingly.