Import an Existing Cluster to ACM
Use this example procedure to bring an existing cluster under
ACM management. The existing cluster must be up and running.
We provide this example procedure purely for informational purposes. See Red Hat ACM documentation for the official procedure.
-
Log in to the hub cluster.
Ensure the kubeconfig of the hub cluster is stored in the default kubeconfig location (
~/.kube/config
). Then log in as follows:oc login
-
Save the cluster name to a variable you can use later on.
CLUSTER_NAME=mgmt-spoke2
-
Create the project.
oc new-project ${CLUSTER_NAME}
-
Create the namespace.
oc label namespace ${CLUSTER_NAME} cluster.open-cluster-management.io/managedCluster=${CLUSTER_NAME}
-
Create and apply a YAML file that describes the managed cluster.
-
Create the YAML file.
We'll call the YAML file managed-cluster.yaml.
whereapiVersion: cluster.open-cluster-management.io/v1 kind: ManagedCluster metadata: name: mgmt-spoke2 spec: hubAcceptsClient: true
mgmt-spoke2
is the cluster name. -
Apply the YAML.
oc apply -f managed-cluster.yaml
-
Create the YAML file.
-
Create and apply the klusterlet addon YAML file. The klusterlet is the agent
responsible for communications between the hub and managed clusters.
-
Create the YAML file.
We'll call the YAML file klusterlet-addon-config.yaml.
apiVersion: agent.open-cluster-management.io/v1 kind: KlusterletAddonConfig metadata: name: mgmt-spoke2 namespace: mgmt-spoke2 spec: clusterName: mgmt-spoke2 clusterNamespace: mgmt-spoke2 applicationManager: enabled: true certPolicyController: enabled: true clusterLabels: cloud: auto-detect vendor: auto-detect iamPolicyController: enabled: true policyController: enabled: true searchCollector: enabled: true version: 2.0.0
-
Apply the YAML.
oc apply -f klusterlet-addon-config.yaml
-
Create the YAML file.
-
View the secret automatically generated from the previous step.
The automatically-generated secret is called
${CLUSTER_NAME}-import
.oc get secret ${CLUSTER_NAME}-import
oc describe secret ${CLUSTER_NAME}-import
This secret contains the import.yaml that you will apply to the managed cluster to install klusterlet.
-
Save the klusterlet configuration to local files.
-
Retrieve the klusterlet CRD and save it to apply later on the managed
cluster.
oc get secret ${CLUSTER_NAME}-import -n ${CLUSTER_NAME} -o jsonpath={.data.crds\\.yaml} | base64 --decode > klusterlet-crd.yaml
-
Retrieve import.yaml and save it to apply it later on the
managed cluster.
oc get secret ${CLUSTER_NAME}-import -n ${CLUSTER_NAME} -o jsonpath={.data.import\\.yaml} | base64 --decode > import.yaml
-
Retrieve the klusterlet CRD and save it to apply later on the managed
cluster.
-
Import the klusterlet.
Run these commands from the managed cluster. One way to do this is to copy the kubeconfig of the managed cluster to the default kubeconfig location (
~/.kube/config
).-
kubectl apply -f klusterlet-crd.yaml
-
kubectl apply -f import.yaml
-
Check the pod status of the klusterlet.
kubectl get pod -n open-cluster-management-agent
-
-
Check the JOINED and AVAILABLE status for your imported cluster. Run this command from
the hub cluster.
kubectl get managedcluster -n ${CLUSTER_NAME}
Your imported cluster should indicate that it's joined and available.
-
Check the agent addon. Run this command from the hub cluster.
All pods should have a STATUS of Running.oc get pod -n open-cluster-management-agent-addon