--- title: Managed cluster sites weight: 20 aliases: /multicloud-gitops-amx/mcg-amx-managed-cluster/ --- include::modules/comm-attributes.adoc[] :toc: :imagesdir: /images :_content-type: ASSEMBLY //leaving this here on purpose to test H1 headings (with ID) in assemblies and it's impact of TOC [id="attach-managed-cluster"] == Attach a managed cluster (edge) to the management hub [id="understanding-acm-requirements-managed-cluster"] == Understanding Red Hat Advanced Cluster Management requirements By default, Red Hat Advanced Cluster Management (RHACM) manages the `clusterGroup` applications that are deployed on all clusters. In the `value-hub.yaml` file, add a `managedClusterCgroup` for each cluster or group of clusters that you want to manage as one. [source,yaml] ---- managedClusterGroups: - name: region-one helmOverrides: - name: clusterGroup.isHubCluster value: false clusterSelector: matchLabels: clusterGroup: region-one ---- The above YAML file segment deploys the `clusterGroup` applications on managed clusters with the label `clusterGroup=region-one`. Specific subscriptions and Operators, applications and projects for that `clusterGroup` are then managed in a `value-region-one.yaml` file. For example: [source,yaml] ---- namespaces: - config-demo projects: - config-demo applications: config-demo: name: config-demo namespace: config-demo project: config-demo path: charts/all/config-demo #Subscriptions can be added too - multicloud-gitops at present does not require subscriptions on its managed clusters #subscriptions: . # example-subscription # name: example-operator # namespace: example-namespace # channel: example-channel # csv: example-operator.v1.0.0 subscriptions: ---- [IMPORTANT] ==== Ensure that you commit the changes and push them to GitHub so that GitOps can fetch your changes and apply them. ==== [id="deploying-a-managed-cluster-using-rhacm"] == Deploying a managed cluster by using Red Hat Advanced Cluster Management .Prerequisites * An OpenShift cluster ** To create an OpenShift cluster, go to the https://console.redhat.com/[Red Hat Hybrid Cloud console]. ** Select *Services* -> *Containers* -> *Create cluster*. * Red Hat Advanced Cluster Management (RHACM) web console to join the managed cluster to the management hub + [NOTE] ==== After RHACM is installed, a message regarding a *Web console update is available*" might be displayed. Follow the instructions and click the *Refresh web console* link. ==== .Procedure . In the left navigation panel of web console, click *local-cluster*. Select *All Clusters*. The RHACM web console is displayed with *Cluster** on the left navigation panel. . On the *Managed clusters* tab, click *Import cluster*. . On the *Import an existing cluster* page, enter the cluster name and choose *KUBECONFIG* as the "import mode". Add the tag `clusterGroup=region-one`. Click *Import*. Now that RHACM is no longer deploying the managed cluster applications everywhere, you must indicate that the new cluster has the managed cluster role. [id="deploying-managed-cluster-using-cm-cli-tool"] == Optional: Deploying a managed cluster by using `cm-cli` tool .Prerequisites * An OpenShift cluster ** To create an OpenShift cluster, go to the https://console.redhat.com/[Red Hat Hybrid Cloud console]. ** Select *Services \-> Containers \-> Create cluster*. * https://github.com/open-cluster-management/cm-cli/#installation[The `cm-cli` tool] .Procedure . Obtain the `KUBECONFIG` file from the managed cluster. . Open a shell prompt and login into the management hub cluster by using either of the following methods: + [source,terminal] ---- oc login ---- or + [source,terminal] ---- export KUBECONFIG=~/ ---- . Run the following command: + [source,terminal] ---- cm attach cluster --cluster --cluster-kubeconfig ---- [role="_next-steps"] .Next steps * <> [id="deploying-managed-cluster-using-clusteradm-tool"] == Optional: Deploying a managed cluster by using the `clusteradm` tool .Prerequisites * An OpenShift cluster ** To create an OpenShift cluster, go to the https://console.redhat.com/[Red Hat Hybrid Cloud console]. ** Select *Services* -> *Containers* -> *Create cluster*. * https://github.com/open-cluster-management-io/clusteradm#install-the-clusteradm-command-line[The `clusteradm` tool] .Procedure . To deploy an edge cluster, you must to get the token from the management hub cluster. Run the following command on the existing management hub or datacenter cluster: + [source,terminal] ---- clusteradm get token ---- + The command generates a token and shows you the command to use on the managed cluster. . Login to the managed cluster with either of the following methods: + [source,terminal] ---- oc login ---- or + [source,terminal] ---- export KUBECONFIG=~/ ---- . To request that the managed join the hub cluster, run the following command: + [source,terminal] ---- clusteradm join --hub-token ---- . Accept the `join` request on the hub cluster: + [source,terminal] ---- clusteradm accept --clusters ---- [role="_next-steps"] .Next steps * <> [id="designate-cluster-as-a-managed-cluster-site"] == Designate the new cluster as a managed cluster site If you use the command line tools such as `clusteradm` or `cm-cli`, you must explicitly indicate that the imported cluster is part of a specific `clusterGroup`. Some examples of `clusterGroup` are `factory`, `devel`, or `prod`. To tag the cluster as `clusterGroup=`, complete the following steps. .Procedure . To find the new cluster, run the following command: + [source,terminal] ---- oc get managedcluster.cluster.open-cluster-management.io ---- . To apply the label, run the following command: + [source,terminal] ---- oc label managedcluster.cluster.open-cluster-management.io/YOURCLUSTER site=managed-cluster ---- == Verification Go to your managed cluster (edge) OpenShift console and check for the `open-cluster-management-agent` pod being launched. It might take a while for the RHACM agent and `agent-addons` to launch. After that, the OpenShift GitOps Operator is installed. On successful installation, launch the OpenShift GitOps (ArgoCD) console from the top right of the OpenShift console.