Validated Patterns

Attach a managed cluster (edge) to the management hub

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.

  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:

  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:

Ensure that you commit the changes and push them to GitHub so that GitOps can fetch your changes and apply them.

Deploying a managed cluster by using Red Hat Advanced Cluster Management

Prerequistes
  • An OpenShift cluster

  • Red Hat Advanced Cluster Management (RHACM) web console to join the managed cluster to the management hub

    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
  1. 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.

  2. On the Managed clusters tab, click Import cluster.

  3. 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.

Optional: Deploying a managed cluster by using cm-cli tool

Prerequistes
Procedure
  1. Obtain the KUBECONFIG file from the managed cluster.

  2. Open a shell prompt and login into the management hub cluster by using either of the following methods:

    oc login

    or

    export KUBECONFIG=~/<path_to_kubeconfig>
  3. Run the following command:

    cm attach cluster --cluster <cluster-name> --cluster-kubeconfig <path-to-path_to_kubeconfig>

Optional: Deploying a managed cluster by using the clusteradm tool

Prerequistes
Procedure
  1. 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:

    clusteradm get token

    The command generates a token and shows you the command to use on the managed cluster.

  2. Login to the managed cluster with either of the following methods:

    oc login

    or

    export KUBECONFIG=~/<path_to_kubeconfig>
  3. To request that the managed join the hub cluster, run the following command:

    clusteradm join --hub-token <token_from_clusteradm_get_token_command> <managed_cluster_name>
  4. Accept the join request on the hub cluster:

    clusteradm accept --clusters <managed_cluster_name>

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=<managed-cluster-group>, complete the following steps.

Procedure
  1. To find the new cluster, run the following command:

    oc get managedcluster.cluster.open-cluster-management.io
  2. To apply the label, run the following command:

    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.