Skip to content

Commit 5606c35

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

File tree

1 file changed

+29
-12
lines changed

1 file changed

+29
-12
lines changed

docs/spec/v2/helmreleases.md

Lines changed: 29 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,35 @@ 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 on the target cluster granting *namespaced* `admin`:
964+
965+
```yaml
966+
apiVersion: rbac.authorization.k8s.io/v1
967+
kind: RoleBinding
968+
metadata:
969+
name: apps-sa-binding
970+
namespace: apps # This namespace SHOULD be the target/storage namespace on the target cluster.
971+
roleRef:
972+
apiGroup: rbac.authorization.k8s.io
973+
kind: ClusterRole
974+
name: admin
975+
subjects:
976+
- apiGroup: rbac.authorization.k8s.io
977+
kind: ServiceAccount
978+
name: apps-sa
979+
namespace: apps # This namespace MUST match the HelmRelease namespace on the source cluster.
980+
```
981+
982+
If the target and storage namespaces are different, the RoleBinding
983+
above must be created in both namespaces.
984+
968985
Other references to Kubernetes resources in the HelmRelease, like
969986
[values references](#values-references), are expected to exist on
970987
the cluster where Flux is running.

0 commit comments

Comments
 (0)