Skip to content

Commit 10dad79

Browse files
committed
Improve ServiceAccount impersonation docs
Signed-off-by: Matheus Pimenta <[email protected]>
1 parent 1104edc commit 10dad79

File tree

1 file changed

+35
-12
lines changed

1 file changed

+35
-12
lines changed

docs/spec/v2/helmreleases.md

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -945,18 +945,6 @@ To make a HelmRelease react immediately to changes in the referenced Secret
945945
or ConfigMap see [this](#reacting-immediately-to-configuration-dependencies)
946946
section.
947947

948-
When both `.spec.kubeConfig` and
949-
[`.spec.serviceAccountName`](#service-account-reference) are specified,
950-
the controller will impersonate the ServiceAccount on the target cluster,
951-
i.e. a ServiceAccount with name `.spec.serviceAccountName` must exist in
952-
the target cluster inside a namespace with the same name as the namespace
953-
of the HelmRelease. For example, if the HelmRelease is in the namespace
954-
`apps` of the cluster where Flux is running, then the ServiceAccount
955-
must be in the `apps` namespace of the target remote cluster, and have the
956-
name `.spec.serviceAccountName`. In other words, the namespace of the
957-
HelmRelease must exist both in the cluster where Flux is running
958-
and in the target remote cluster where Flux will apply resources.
959-
960948
The Helm storage is stored on the remote cluster in a namespace that equals to
961949
the namespace of the HelmRelease, or the [configured storage namespace](#storage-namespace).
962950
The release itself is made in a namespace that equals to the namespace of the
@@ -965,6 +953,41 @@ namespaces are expected to exist, with the exception that the target namespace
965953
can be created on demand by Helm when namespace creation is [configured during
966954
install](#install-configuration).
967955

956+
When both `.spec.kubeConfig` and
957+
[`.spec.serviceAccountName`](#service-account-reference) are specified,
958+
the controller will impersonate the ServiceAccount on the target cluster.
959+
The ServiceAccount must have the necessary RBAC permissions to perform
960+
the operations associated with the HelmRelease. This includes permissions
961+
on both the target and storage namespaces.
962+
963+
Example of RoleBinding in the target cluster granting the `admin` ClusterRole
964+
in a *namespaced* fashion (scoped to the `rbac-namespace` namespace):
965+
966+
```yaml
967+
apiVersion: rbac.authorization.k8s.io/v1
968+
kind: RoleBinding
969+
metadata:
970+
name: admin
971+
# This namespace SHOULD be the storage/target
972+
# namespace on the TARGET cluster.
973+
namespace: rbac-namespace
974+
roleRef:
975+
apiGroup: rbac.authorization.k8s.io
976+
kind: ClusterRole # Can be either Role or ClusterRole for RoleBinding.
977+
name: admin
978+
subjects:
979+
- apiGroup: rbac.authorization.k8s.io
980+
kind: ServiceAccount
981+
name: apps-sa
982+
# This namespace MUST match the HelmRelease namespace
983+
# on the SOURCE cluster.
984+
namespace: apps
985+
```
986+
987+
If the storage and target namespaces are different, the RoleBinding
988+
above must be created in both namespaces. You can also create
989+
ClusterRoleBindings if needed (they can only bind ClusterRoles).
990+
968991
Other references to Kubernetes resources in the HelmRelease, like
969992
[values references](#values-references), are expected to exist on
970993
the cluster where Flux is running.

0 commit comments

Comments
 (0)