diff --git a/pkg/karmadactl/join.go b/pkg/karmadactl/join.go index 9a540790d..bddeb55cb 100644 --- a/pkg/karmadactl/join.go +++ b/pkg/karmadactl/join.go @@ -160,11 +160,6 @@ func JoinCluster(controlPlaneRestConfig, clusterConfig *rest.Config, opts Comman klog.V(1).Infof("joining cluster config. endpoint: %s", clusterConfig.Host) - // ensure namespace where the cluster object be stored exists in control plane. - if _, err = util.EnsureNamespaceExist(controlPlaneKubeClient, opts.ClusterNamespace, opts.DryRun); err != nil { - return err - } - registerOption := util.ClusterRegisterOption{ ClusterNamespace: opts.ClusterNamespace, ClusterName: opts.ClusterName, diff --git a/pkg/util/credential.go b/pkg/util/credential.go index bad114a64..7659c5749 100644 --- a/pkg/util/credential.go +++ b/pkg/util/credential.go @@ -98,6 +98,11 @@ func ObtainCredentialsFromMemberCluster(clusterKubeClient kubeclient.Interface, // RegisterClusterInControllerPlane represents register cluster in controller plane func RegisterClusterInControllerPlane(opts ClusterRegisterOption, controlPlaneKubeClient kubeclient.Interface, generateClusterInControllerPlane generateClusterInControllerPlaneFunc) error { + // ensure namespace where the cluster object be stored exists in control plane. + if _, err := EnsureNamespaceExist(controlPlaneKubeClient, opts.ClusterNamespace, opts.DryRun); err != nil { + return err + } + impersonatorSecret := &corev1.Secret{} secret := &corev1.Secret{} var err error