Validated Patterns

Having a store (edge) cluster join the datacenter (hub)

Allow ACM to deploy the store application to a subset of clusters

A store (“ATLANTA”) is installed on the hub cluster by default. This feature is interesting if you want to see how ACM can manage a remote cluster to install the same application on a different cluster.

The way we apply this is through the managedClusterGroups block in values-hub.yaml:

  managedClusterGroups:
    raleigh:
      name: store-raleigh
      helmOverrides:
      # Values must be strings!
      - name: clusterGroup.isHubCluster
        value: "false"
      clusterSelector:
        matchLabels:
          clusterGroup: store-raleigh
        matchExpressions:
        - key: vendor
          operator: In
          values:
            - OpenShift

Any cluster joined with the label clusterGroup=store-raleigh is assigned the policies that deploy the store app to them.

Attaching a managed cluster (edge) to the management hub

The use of this pattern depends on having at least one running Red Hat OpenShift cluster.

When you install the retail GitOps pattern, a hub cluster is setup. The hub cluster serves as the central point for managing and deploying applications across multiple clusters.

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.

Add a managedClusterGroup for each cluster or group of clusters that you want to manage by following this procedure.

Procedure
  1. Switch to your locally created feature branch by running the following command:

    $ git checkout my-branch main
  2. In the value-hub.yaml file, a managedClusterGroup raleigh already exists as shown in this yaml extract:

    managedClusterGroups:
        raleigh:
          name: store-raleigh
          helmOverrides:
          # Values must be strings!
          - name: clusterGroup.isHubCluster
            value: "false"
          clusterSelector:
            matchLabels:
              clusterGroup: store-raleigh
            matchExpressions:
            - key: vendor
              operator: In
              values:
                - OpenShift

    The YAML file segment defines the raleigh managed cluster group, which deploys clusterGroup applications on clusters labeled with clusterGroup=store-raleigh. The clusterSelector ensures that only clusters with the clusterGroup=store-raleigh label and the vendor=OpenShift label are included in this group. Specific subscriptions, Operators, applications, and projects for this clusterGroup are managed through the values-store-raleigh.yaml file..

  3. To add a new managedClusterGroup, add a new entry to the managedClusterGroups block in the values-hub.yaml file as follows:

    charlotte:
        name: store-charlotte
        helmOverrides:
          - name: clusterGroup.isHubCluster
            value: "false"
        clusterSelector:
          matchLabels:
            clusterGroup: store-charlotte
          matchExpressions:
            - key: vendor
              operator: In
              values:
                - OpenShift

    The charlotte cluster group is managed separately, using its own values-store-charlotte.yaml file.

  4. Make a copy of the values-store-raleigh.yaml file and name it values-store-charlotte.yaml. Update the file with the appropriate values for the charlotte cluster group.

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

    • To create an OpenShift cluster, go to the Red Hat Hybrid Cloud console.

    • Select OpenShift -> Red Hat OpenShift Container Platform -> Create 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 the web console associated with your deployed hub cluster, click local-cluster. Select All Clusters. The RHACM web console is displayed.

  2. In the Managing clusters just got easier window, click Import an existing cluster.

    1. Enter the cluster name (you can get this from the login token string for example https://api.<cluster-name>.<domain>:6443)

    2. You can leave the Cluster set blank.

    3. In the Additional labels dialog box enter the key=value as clusterGroup=group-one.

    4. Choose KubeConfig as the "Import mode".

    5. In the KubeConfig window paste your KubeConfig content. Click Next.

  3. You can skip the Automation screen. Click Next.

  4. Review the summary details and click Import.

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 --token=<retrieved-token> --server=https://api.<your-cluster>.<domain>:6443

    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 list all managed clusters, run the following command:

    $ oc get managedcluster.cluster.open-cluster-management.io

    This will display a list of managed clusters registered in ACM, including their names and statuses.

  2. Once you identify the target cluster for example YOURCLUSTER, label it with the desired key-value pair to associate it with a group or category. To apply the label, run the following command:

    $ oc label managedcluster.cluster.open-cluster-management.io/YOURCLUSTER site=managed-cluster
Verification
  1. Confirm that the label was applied by running the following command:

    $ oc get managedcluster.cluster.open-cluster-management.io/YOURCLUSTER --show-labels

    This will display the labels associated with the cluster, verifying that the new label has been successfully added..

  2. Optional: If you’re grouping clusters under a clusterGroup for example factory, devel, or prod, add the clusterGroup label also by running the following command:

    $ oc label managedcluster.cluster.open-cluster-management.io/YOURCLUSTER clusterGroup=<group-name>

    Replace <group-name> with the appropriate value, such as factory.

Verification

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

Store is joined

You’re done

That is it! Go to your store (edge) OpenShift console and check for the open-cluster-management-agent pod being launched. Be patient, it will take a while for the ACM agent and agent-addons to launch. After that, the operator OpenShift GitOps will run. When it is finished coming up launch the OpenShift GitOps (ArgoCD) console from the top right of the OpenShift console.