From 142ea6308dd85fd7c44e226b3567dcb23ad4df64 Mon Sep 17 00:00:00 2001 From: Oliver Fischer <108426932+oafischer@users.noreply.github.com> Date: Thu, 5 Dec 2024 18:09:32 +0100 Subject: [PATCH] https://issues.redhat.com/browse/ACM-16062 --- clusters/cluster_lifecycle/import_ocp.adoc | 102 ++++++++++++++++++--- 1 file changed, 87 insertions(+), 15 deletions(-) diff --git a/clusters/cluster_lifecycle/import_ocp.adoc b/clusters/cluster_lifecycle/import_ocp.adoc index c791069b54..371762c712 100644 --- a/clusters/cluster_lifecycle/import_ocp.adoc +++ b/clusters/cluster_lifecycle/import_ocp.adoc @@ -179,36 +179,108 @@ oc get infraenv -n managed-cluster some-other-infraenv -ojson | jq ".status. -n get agent -oyaml > agent.yaml +oc –kubeconfig -n get -oyaml > .yaml ---- -. Apply your `Agent` resource on your target hub cluster by running the following command. Replace values where needed: +.. Repeat the command for every resource you want to import by replacing `` with the name of the resource. +. Remove the `ownerReferences` property from the following resources by running the following commands: ++ +.. `AgentClusterInstall` + [source,bash] ---- -oc –kubeconfig apply -f agent.yaml +yq --in-place -y 'del(.metadata.ownerReferences)' AgentClusterInstall.yaml ---- ++ +.. `Secret` (`admin-kubeconfig`) ++ +[source,bash] +---- +yq --in-place -y 'del(.metadata.ownerReferences)' AdminKubeconfigSecret.yaml +---- + +. Detach the managed cluster from the source hub cluster by running the following command. Replace values where needed: + ++ +[source,bash] +---- +oc –kubeconfig delete ManagedCluster +---- + +. Create a namespace on the target hub cluster for the managed cluster. Use a similar name as the source hub cluster. + +. Apply your stored resources on the target hub cluster individually by running the following command. Replace values where needed: ++ +*Note:* Replace `.yaml` with `.` if you want to apply all the resources as a group instead of individually. ++ +[source,bash] +---- +oc –kubeconfig apply -f .yaml +---- + +[#remove-cluster-source-hub] +=== Removing the managed cluster from the source hub cluster + +After importing your cluster resources, remove your managed cluster from the source hub cluster by completing the following steps: + +. Set the `spec.preserveOnDelete` parameter to `true` in the `ClusterDeployment` custom resource to prevent destroying the managed cluster. -After importing your cluster resources, delete your original cluster resources on your source hub cluster. +. Complete the steps in xref:../cluster_lifecycle/remove_managed_cluster.adoc#remove-managed-cluster[Removing a cluster from management].