diff --git a/Makefile b/Makefile index 3faa19bba..3110cd0f9 100644 --- a/Makefile +++ b/Makefile @@ -166,7 +166,7 @@ apply-spoke-cr: bootstrap-secret | $(KUBECTL) apply -f - apply-spoke-cr-hosted: bootstrap-secret-hosted external-managed-secret - $(KUSTOMIZE) build deploy/klusterlet/config/samples | $(SED_CMD) -e "s,mode: Default,mode: Detached," -e "s,quay.io/open-cluster-management/registration,$(REGISTRATION_IMAGE)," -e "s,quay.io/open-cluster-management/work,$(WORK_IMAGE)," -e "s,cluster1,$(MANAGED_CLUSTER_NAME)," | $(KUBECTL) apply -f - + $(KUSTOMIZE) build deploy/klusterlet/config/samples | $(SED_CMD) -e "s,mode: Default,mode: Hosted," -e "s,quay.io/open-cluster-management/registration,$(REGISTRATION_IMAGE)," -e "s,quay.io/open-cluster-management/work,$(WORK_IMAGE)," -e "s,cluster1,$(MANAGED_CLUSTER_NAME)," | $(KUBECTL) apply -f - clean-hub-cr: $(KUBECTL) delete managedcluster --all --ignore-not-found diff --git a/pkg/helpers/helpers.go b/pkg/helpers/helpers.go index f95a1f7e2..f0dbdceba 100644 --- a/pkg/helpers/helpers.go +++ b/pkg/helpers/helpers.go @@ -613,7 +613,7 @@ func LoadClientConfigFromSecret(secret *corev1.Secret) (*rest.Config, error) { func DetermineReplica(ctx context.Context, kubeClient kubernetes.Interface, mode operatorapiv1.InstallMode, kubeVersion *version.Version) int32 { // For hosted mode, there may be many cluster-manager/klusterlet running on the management cluster, // set the replica to 1 to reduce the footprint of the management cluster. - if mode == operatorapiv1.InstallModeDetached || mode == operatorapiv1.InstallModeHosted { + if mode == operatorapiv1.InstallModeHosted { return singleReplica } @@ -774,7 +774,7 @@ func KlusterletNamespace(klusterlet *operatorapiv1.Klusterlet) string { // AgentNamespace returns the namespace to deploy the agents. // It is on the managed cluster in the Default mode, and on the management cluster in the Hosted mode. func AgentNamespace(klusterlet *operatorapiv1.Klusterlet) string { - if klusterlet.Spec.DeployOption.Mode == operatorapiv1.InstallModeDetached || klusterlet.Spec.DeployOption.Mode == operatorapiv1.InstallModeHosted { + if klusterlet.Spec.DeployOption.Mode == operatorapiv1.InstallModeHosted { return klusterlet.GetName() } diff --git a/pkg/helpers/helpers_test.go b/pkg/helpers/helpers_test.go index 2b1089802..e5dd68703 100644 --- a/pkg/helpers/helpers_test.go +++ b/pkg/helpers/helpers_test.go @@ -1613,7 +1613,7 @@ func TestGetHubKubeconfig(t *testing.T) { expectedErr: false, }, { - name: "detach mode no secret", + name: "hosted mode no secret", mode: operatorapiv1.InstallModeHosted, secret: []runtime.Object{}, namespace: "test", @@ -1621,7 +1621,7 @@ func TestGetHubKubeconfig(t *testing.T) { expectedErr: true, }, { - name: "detach mode", + name: "hosted mode", mode: operatorapiv1.InstallModeHosted, secret: []runtime.Object{newKubeConfigSecret("test", ExternalHubKubeConfig, newKubeConfig("testhost", "tls.crt", "tls.key"), []byte("--- TRUNCATED ---"), []byte("--- REDACTED ---"))}, namespace: "test", diff --git a/pkg/operators/klusterlet/controllers/klusterletcontroller/klusterlet_cleanup_controller.go b/pkg/operators/klusterlet/controllers/klusterletcontroller/klusterlet_cleanup_controller.go index 4ad110f69..b51e1f267 100644 --- a/pkg/operators/klusterlet/controllers/klusterletcontroller/klusterlet_cleanup_controller.go +++ b/pkg/operators/klusterlet/controllers/klusterletcontroller/klusterlet_cleanup_controller.go @@ -98,11 +98,6 @@ func (n *klusterletCleanupController) sync(ctx context.Context, controllerContex klusterlet = klusterlet.DeepCopy() installMode := klusterlet.Spec.DeployOption.Mode - // TODO: remove this when detached mode is not used in klusterlet - if installMode == operatorapiv1.InstallModeDetached { - installMode = operatorapiv1.InstallModeHosted - } - if klusterlet.DeletionTimestamp.IsZero() { if !hasFinalizer(klusterlet, klusterletFinalizer) { return n.addFinalizer(ctx, klusterlet, klusterletFinalizer) diff --git a/pkg/operators/klusterlet/controllers/klusterletcontroller/klusterlet_controller.go b/pkg/operators/klusterlet/controllers/klusterletcontroller/klusterlet_controller.go index dbfe21bed..360548283 100644 --- a/pkg/operators/klusterlet/controllers/klusterletcontroller/klusterlet_controller.go +++ b/pkg/operators/klusterlet/controllers/klusterletcontroller/klusterlet_controller.go @@ -259,11 +259,6 @@ func (n *klusterletController) sync(ctx context.Context, controllerContext facto } } - // TODO: remove this when detached mode is not used in klusterlet - if config.InstallMode == operatorapiv1.InstallModeDetached { - config.InstallMode = operatorapiv1.InstallModeHosted - } - if config.InstallMode == operatorapiv1.InstallModeHosted { managedClusterClients, err = n.buildManagedClusterClientsHostedMode(ctx, n.kubeClient, config.AgentNamespace, config.ExternalManagedKubeConfigSecret) diff --git a/pkg/operators/klusterlet/controllers/klusterletcontroller/klusterlet_controller_test.go b/pkg/operators/klusterlet/controllers/klusterletcontroller/klusterlet_controller_test.go index 83de44b31..a98e1db34 100644 --- a/pkg/operators/klusterlet/controllers/klusterletcontroller/klusterlet_controller_test.go +++ b/pkg/operators/klusterlet/controllers/klusterletcontroller/klusterlet_controller_test.go @@ -407,7 +407,7 @@ func assertWorkDeployment(t *testing.T, actions []clienttesting.Action, verb, cl "--hub-kubeconfig=/spoke/hub-kubeconfig/kubeconfig", } - if mode == operatorapiv1.InstallModeDetached || mode == operatorapiv1.InstallModeHosted { + if mode == operatorapiv1.InstallModeHosted { expectArgs = append(expectArgs, "--spoke-kubeconfig=/spoke/config/kubeconfig") } diff --git a/test/e2e/addon_test.go b/test/e2e/addon_test.go index 92508f149..a9c7df11d 100644 --- a/test/e2e/addon_test.go +++ b/test/e2e/addon_test.go @@ -65,48 +65,6 @@ var _ = Describe("Manage the managed cluster addons", func() { }, t.EventuallyTimeout*5, t.EventuallyInterval*5).Should(Succeed()) }) - // TODO: remove this after the detached mode is not used in klusterlet - It("Create one managed cluster addon and make sure it is available in Detached mode", func() { - var err error - By(fmt.Sprintf("create klusterlet %v with managed cluster name %v", klusterletName, clusterName)) - _, err = t.CreateKlusterlet(klusterletName, clusterName, agentNamespace, operatorapiv1.InstallModeDetached) - Expect(err).ToNot(HaveOccurred()) - - By(fmt.Sprintf("waiting for the managed cluster %v to be created", clusterName)) - Eventually(func() error { - _, err = t.GetCreatedManagedCluster(clusterName) - return err - }, t.EventuallyTimeout*5, t.EventuallyInterval*5).Should(Succeed()) - - By(fmt.Sprintf("approve the created managed cluster %v", clusterName)) - Eventually(func() error { - return t.ApproveCSR(clusterName) - }, t.EventuallyTimeout, t.EventuallyInterval).Should(Succeed()) - - By(fmt.Sprintf("accept the created managed cluster %v", clusterName)) - Eventually(func() error { - return t.AcceptsClient(clusterName) - }, t.EventuallyTimeout, t.EventuallyInterval).Should(Succeed()) - - By(fmt.Sprintf("waiting for the managed cluster %v to be ready", clusterName)) - Eventually(func() error { - return t.CheckManagedClusterStatus(clusterName) - }, t.EventuallyTimeout*5, t.EventuallyInterval*5).Should(Succeed()) - - By(fmt.Sprintf("create the addon %v on the managed cluster namespace %v", addOnName, clusterName)) - err = t.CreateManagedClusterAddOn(clusterName, addOnName) - Expect(err).ToNot(HaveOccurred()) - - By(fmt.Sprintf("create the addon lease %v on addon install namespace %v", addOnName, addOnName)) - err = t.CreateManagedClusterAddOnLease(addOnName, addOnName) - Expect(err).ToNot(HaveOccurred()) - - By(fmt.Sprintf("wait the addon %v available condition to be true", addOnName)) - Eventually(func() error { - return t.CheckManagedClusterAddOnStatus(clusterName, addOnName) - }, t.EventuallyTimeout*5, t.EventuallyInterval*5).Should(Succeed()) - }) - It("Create one managed cluster addon and make sure it is available in Hosted mode", func() { var err error By(fmt.Sprintf("create klusterlet %v with managed cluster name %v", klusterletName, clusterName)) diff --git a/test/e2e/common.go b/test/e2e/common.go index 81b8b1260..965bf6245 100644 --- a/test/e2e/common.go +++ b/test/e2e/common.go @@ -207,7 +207,7 @@ func (t *Tester) CreateKlusterlet(name, clusterName, klusterletNamespace string, } } - if mode == operatorapiv1.InstallModeDetached || mode == operatorapiv1.InstallModeHosted { + if mode == operatorapiv1.InstallModeHosted { // create external-managed-kubeconfig, will use the same cluster to simulate the Hosted mode. secret.Namespace = agentNamespace secret.Name = helpers.ExternalManagedKubeConfig diff --git a/test/e2e/klusterlet_test.go b/test/e2e/klusterlet_test.go index 217783f54..119b718fc 100644 --- a/test/e2e/klusterlet_test.go +++ b/test/e2e/klusterlet_test.go @@ -151,46 +151,6 @@ var _ = Describe("Create klusterlet CR", func() { }, t.EventuallyTimeout*5, t.EventuallyInterval*5).Should(Succeed()) }) - // TODO: remove this after the detached mode is not used in klusterlet - It("Create klusterlet CR in Detached mode", func() { - By(fmt.Sprintf("create klusterlet %v with managed cluster name %v", klusterletName, clusterName)) - _, err := t.CreateKlusterlet(klusterletName, clusterName, klusterletNamespace, operatorapiv1.InstallModeDetached) - Expect(err).ToNot(HaveOccurred()) - - By(fmt.Sprintf("waiting for the managed cluster %v to be created", clusterName)) - Eventually(func() error { - _, err := t.GetCreatedManagedCluster(clusterName) - return err - }, t.EventuallyTimeout*5, t.EventuallyInterval*5).Should(Succeed()) - - By(fmt.Sprintf("check klusterlet %s status", klusterletName)) - Eventually(func() error { - err := t.checkKlusterletStatus(klusterletName, "HubConnectionDegraded", "BootstrapSecretFunctional,HubKubeConfigSecretMissing", metav1.ConditionTrue) - return err - }, t.EventuallyTimeout*5, t.EventuallyInterval*5).Should(Succeed()) - - By(fmt.Sprintf("approve the created managed cluster %v", clusterName)) - Eventually(func() error { - return t.ApproveCSR(clusterName) - }, t.EventuallyTimeout, t.EventuallyInterval).Should(Succeed()) - - By(fmt.Sprintf("accept the created managed cluster %v", clusterName)) - Eventually(func() error { - return t.AcceptsClient(clusterName) - }, t.EventuallyTimeout, t.EventuallyInterval).Should(Succeed()) - - By(fmt.Sprintf("waiting for the managed cluster %v to be ready", clusterName)) - Eventually(func() error { - return t.CheckManagedClusterStatus(clusterName) - }, t.EventuallyTimeout*5, t.EventuallyInterval*5).Should(Succeed()) - - By(fmt.Sprintf("check klusterlet %s status", klusterletName)) - Eventually(func() error { - err := t.checkKlusterletStatus(klusterletName, "HubConnectionDegraded", "HubConnectionFunctional", metav1.ConditionFalse) - return err - }, t.EventuallyTimeout*5, t.EventuallyInterval*5).Should(Succeed()) - }) - It("Create klusterlet CR in Hosted mode", func() { By(fmt.Sprintf("create klusterlet %v with managed cluster name %v", klusterletName, clusterName)) _, err := t.CreateKlusterlet(klusterletName, clusterName, klusterletNamespace, operatorapiv1.InstallModeHosted) diff --git a/test/e2e/work_test.go b/test/e2e/work_test.go index 680494bcf..757b41ba1 100644 --- a/test/e2e/work_test.go +++ b/test/e2e/work_test.go @@ -78,55 +78,6 @@ var _ = Describe("Create klusterlet and then create a configmap by manifestwork" }, t.EventuallyTimeout*5, t.EventuallyInterval*5).Should(BeTrue()) }) - // TODO: remove this after the detached mode is not used in klusterlet - It("Create configmap using manifestwork and then delete klusterlet in Detached mode", func() { - var err error - By(fmt.Sprintf("create klusterlet %v with managed cluster name %v", klusterletName, clusterName)) - _, err = t.CreateKlusterlet(klusterletName, clusterName, agentNamespace, operatorapiv1.InstallModeDetached) - Expect(err).ToNot(HaveOccurred()) - - By(fmt.Sprintf("waiting for the managed cluster %v to be created", clusterName)) - Eventually(func() error { - _, err = t.GetCreatedManagedCluster(clusterName) - return err - }, t.EventuallyTimeout*5, t.EventuallyInterval*5).Should(Succeed()) - - By(fmt.Sprintf("approve the created managed cluster %v", clusterName)) - Eventually(func() error { - return t.ApproveCSR(clusterName) - }, t.EventuallyTimeout, t.EventuallyInterval).Should(Succeed()) - - By(fmt.Sprintf("accept the created managed cluster %v", clusterName)) - Eventually(func() error { - return t.AcceptsClient(clusterName) - }, t.EventuallyTimeout, t.EventuallyInterval).Should(Succeed()) - - By(fmt.Sprintf("waiting for the managed cluster %v to be ready", clusterName)) - Eventually(func() error { - return t.CheckManagedClusterStatus(clusterName) - }, t.EventuallyTimeout*5, t.EventuallyInterval*5).Should(Succeed()) - - By(fmt.Sprintf("create configmap %v/%v using manifestwork %v/%v", configMapNamespace, - configMapName, clusterName, workName)) - _, err = t.CreateWorkOfConfigMap(workName, clusterName, configMapName, configMapNamespace) - Expect(err).ToNot(HaveOccurred()) - - By(fmt.Sprintf("waiting for configmap %v/%v to be created", configMapNamespace, configMapName)) - Eventually(func() error { - _, err := t.KubeClient.CoreV1().ConfigMaps(configMapNamespace). - Get(context.TODO(), configMapName, metav1.GetOptions{}) - return err - }, t.EventuallyTimeout*5, t.EventuallyInterval*5).Should(Succeed()) - - By(fmt.Sprintf("delete manifestwork %v/%v", clusterName, workName)) - err = t.WorkClient.WorkV1().ManifestWorks(clusterName).Delete(context.Background(), workName, metav1.DeleteOptions{}) - Expect(err).ToNot(HaveOccurred()) - Eventually(func() bool { - _, err := t.WorkClient.WorkV1().ManifestWorks(clusterName).Get(context.Background(), workName, metav1.GetOptions{}) - return errors.IsNotFound(err) - }, t.EventuallyTimeout*5, t.EventuallyInterval*5).Should(BeTrue()) - }) - It("Create configmap using manifestwork and then delete klusterlet in Hosted mode", func() { var err error By(fmt.Sprintf("create klusterlet %v with managed cluster name %v", klusterletName, clusterName))