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
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
:
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.
Switch to your locally created feature branch by running the following command:
$ git checkout my-branch main
In the
value-hub.yaml
file, amanagedClusterGroup
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 deploysclusterGroup
applications on clusters labeled withclusterGroup=store-raleigh
. The clusterSelector ensures that only clusters with theclusterGroup=store-raleigh
label and thevendor=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..To add a new
managedClusterGroup
, add a new entry to themanagedClusterGroups
block in thevalues-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 ownvalues-store-charlotte.yaml
file.Make a copy of the
values-store-raleigh.yaml
file and name itvalues-store-charlotte.yaml
. Update the file with the appropriate values for thecharlotte
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
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.
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.
In the Managing clusters just got easier window, click Import an existing cluster.
Enter the cluster name (you can get this from the login token string for example https://api.<cluster-name>.<domain>:6443)
You can leave the Cluster set blank.
In the Additional labels dialog box enter the
key=value
asclusterGroup=group-one
.Choose KubeConfig as the "Import mode".
In the KubeConfig window paste your KubeConfig content. Click Next.
You can skip the Automation screen. Click Next.
Review the summary details and click Import.
Optional: Deploying a managed cluster by using cm-cli
tool
An OpenShift cluster
To create an OpenShift cluster, go to the Red Hat Hybrid Cloud console.
Select Services -> Containers -> Create cluster.
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:
$ oc login --token=<retrieved-token> --server=https://api.<your-cluster>.<domain>:6443
or
$ export KUBECONFIG=~/<path_to_kubeconfig>
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
An OpenShift cluster
To create an OpenShift cluster, go to the Red Hat Hybrid Cloud console.
Select Services → Containers → Create cluster.
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.
Login to the managed cluster with either of the following methods:
oc login
or
export KUBECONFIG=~/<path_to_kubeconfig>
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>
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.
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.
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
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..
Optional: If you’re grouping clusters under a clusterGroup for example
factory
,devel
, orprod
, 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 asfactory
.
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 |
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.