@@ -945,18 +945,6 @@ To make a HelmRelease react immediately to changes in the referenced Secret
945945or ConfigMap see [this](#reacting-immediately-to-configuration-dependencies)
946946section.
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-
960948The Helm storage is stored on the remote cluster in a namespace that equals to
961949the namespace of the HelmRelease, or the [configured storage namespace](#storage-namespace).
962950The 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
965953can be created on demand by Helm when namespace creation is [configured during
966954install](#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+
968991Other references to Kubernetes resources in the HelmRelease, like
969992[values references](#values-references), are expected to exist on
970993the cluster where Flux is running.
0 commit comments