Need to specify sa namespace when create clusterrolebindings.
@@ -414,7 +414,7 @@ func createRBACSecret(hostClusterClientset, joiningClusterClientset client.Inter
glog.V(2).Info("Creating role binding for service account in joining cluster")
- _, err = createClusterRoleBinding(joiningClusterClientset, saName,
+ _, err = createClusterRoleBinding(joiningClusterClientset, saName, namespace,
joiningClusterName, dryRun)
if err != nil {
glog.V(2).Infof("Error creating role binding for service account in joining cluster: %v",
@@ -467,7 +467,7 @@ func createServiceAccount(clusterClientset client.Interface, namespace,
// createClusterRoleBinding creates an RBAC cluster role and binding that
// allows the service account identified by saName to access all resources in
// all namespaces in the cluster associated with clusterClientset.
-func createClusterRoleBinding(clusterClientset client.Interface, saName,
+func createClusterRoleBinding(clusterClientset client.Interface, saName, namespace,
joiningClusterName string, dryRun bool) (*rbacv1.ClusterRoleBinding, error) {
roleName := util.ClusterRoleName(saName)
@@ -500,6 +500,7 @@ func createClusterRoleBinding(clusterClientset client.Interface, saName,
{
Kind: rbacv1.ServiceAccountKind,
Name: saName,
+ Namespace: namespace,
},
},
RoleRef: rbacv1.RoleRef{
