The clusterroletemplatebinding need the management cluster name which is generated in the source code of Rancher.
The lookup will directly fetch the management cluster name.
The if condition is to skip the creation on the first deployment of the App (rke2 cluster template) as the management cluster name and namespace are not created yet by Rancher.
Also adding $member.roleTemplateName to the name of ClusterRoleTemplateBinding to allow assignments of multiples roles to the same user.
The clusterroletemplatebinding need the management cluster name which is generated in the source code of Rancher. The lookup will directly fetch the management cluster name.
The if condition is to skip the creation on the first deployment of the App (rke2 cluster template) as the management cluster name and namespace are not created yet by Rancher.
Also adding $member.roleTemplateName to the name of ClusterRoleTemplateBinding to allow assignments of multiples roles to the same user.