Skip to content

Commit

Permalink
https://issues.redhat.com/browse/ACM-16062
Browse files Browse the repository at this point in the history
  • Loading branch information
oafischer authored Dec 5, 2024
1 parent 90ae227 commit 142ea63
Showing 1 changed file with 87 additions and 15 deletions.
102 changes: 87 additions & 15 deletions clusters/cluster_lifecycle/import_ocp.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -179,36 +179,108 @@ oc get infraenv -n managed-cluster some-other-infraenv -ojson | jq ".status.<url

If your {ocp-short} managed cluster was installed by the {ai}, you can move the managed cluster and its resources from one hub cluster to another hub cluster.

You can manage a cluster from a new hub cluster by saving a copy of the original resources, applying them to the new hub cluster, and deleting the original resources. You can then scale down or scale up your managed cluster from the new hub cluster.

*Important:* You can only scale down imported {ocp-short} managed clusters if they were installed by the {ai}.

You can import the following resources and continue to manage your cluster with them:

- `Agent`
- `AgentClassification`
- `AgentClusterInstall`
- `BareMetalHost`
- `ClusterDeployment`
- `InfraEnv`
- `NMStateConfig`
.Managed cluster resource table
|===
| Resource | Optional or required | Description

You can manage a cluster from a new hub cluster by creating a copy of the original resources and applying them to the new hub cluster. You can then scale down or scale up your managed cluster from the new hub cluster.
| `Agent`
| Required
|

*Important:* You can only scale down imported {ocp-short} managed clusters if they were installed by the {ai}.
| `AgentClassification`
| Optional
| Required if you want to classify Agents with a filter query.

| `AgentClusterInstall`
| Required
|

| `BareMetalHost`
| Optional
| Required if you are using the `baremetal` platform.

| `ClusterDeployment`
| Required
|

Import your cluster resources by creating a copy of your resources on your target hub cluster. See the following example to learn how to create a copy of the `Agent` resource and apply similar steps to your other resources:
| `InfraEnv`
| Required
|

. Get the `Agent` resource from your source hub cluster by running the following command. Replace values where needed:
| `NMStateConfig`
| Optional
| Required if you want to apply your network configuration on the hosts.

| `ManagedCluster`
| Required
|

| `Secret`
| Required
| The `admin-kubeconfig` secret is required. The `bmc-secret` secret is only required if you are using `BareMetalHosts`.
|===

[#save-apply-cluster-resources]
=== Saving and applying managed cluster resources

To save a copy of your managed cluster resources and apply them to a new hub cluster, complete the following steps:

. Get your resources from your source hub cluster by running the following command. Replace values where needed:

+
[source,bash]
----
oc –kubeconfig <source_hub_kubeconfig> -n <managed_cluster_name> get agent <cluster_provisioning_namespace> -oyaml > agent.yaml
oc –kubeconfig <source_hub_kubeconfig> -n <managed_cluster_name> get <resource_name> <cluster_provisioning_namespace> -oyaml > <resource_name>.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 `<resource_name>` with the name of the resource.

. Remove the `ownerReferences` property from the following resources by running the following commands:
+
.. `AgentClusterInstall`
+
[source,bash]
----
oc –kubeconfig <target_hub_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 <target_hub_kubeconfig> delete ManagedCluster <cluster_name>
----

. 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 `<resource_name>.yaml` with `.` if you want to apply all the resources as a group instead of individually.
+
[source,bash]
----
oc –kubeconfig <target_hub_kubeconfig> apply -f <resource_name>.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].

0 comments on commit 142ea63

Please sign in to comment.