-
Notifications
You must be signed in to change notification settings - Fork 686
Description
Context
We are using flux to deploy Kustomizations and HelmReleases to remote clusters by specifying a KubeConfig. Since the remote clusters are deployed using Cluster API, we use the cluster-admin Kubeconfig secret created by CAPI to do so.
With spec.serviceAccountName we're able to impersonate ServiceAccounts in the remote cluster as long as the SA resides in a namespace with the same name as the namespace of the Kustomization/HelmRelease on the local cluster.
In our case, the ServiceAccount exists in a different namespace on the remote cluster than the Kust/HR on the local cluster. Therefore we need to specify the namespace.
I assume only allowing to specify a name, but not a namespace, was done due to security considerations, which I totally agree with when impersonating on the local cluster. We could create a custom Kubeconfig with the SA credentials, but that would be quite a lot of effort.
Request
Allow specifying a ServiceAccount namespace for Kustomizations and HelmReleases.
Things to consider:
- maybe allow using
spec.targetNamespaceby setting a property - only allow it when a custom Kubeconfig is specified, since that allows circumventing any restrictions anyway
- add a flag to controllers to enable this feature
- allow to specify the full SA name (
system:serviceaccount:<namespace>:<name>) to avoid a new property