$ git checkout my-branch main
Attach a managed cluster (edge) to the management hub
The use of this Multicloud GitOps pattern depends on having at least one running Red Hat OpenShift cluster.
When you install the multi-cloud 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:
In the
value-hub.yaml
file, add amanagedClusterGroup
for each cluster or group of clusters that you want to manage as one. An examplegroup-one
is provided.managedClusterGroups: exampleRegion: name: group-one acmlabels: - name: clusterGroup value: group-one helmOverrides: - name: clusterGroup.isHubCluster value: false
The above YAML file segment deploys the
clusterGroup
applications on managed clusters with the labelclusterGroup=group-one
. Specific subscriptions and Operators, applications and projects for thatclusterGroup
are then managed in avalue-group-one.yaml
file. The following is defined for theclusterGroup=group-one
.For example:
clusterGroup: name: group-one isHubCluster: false namespaces: - config-demo - hello-world - golang-external-secrets # The only subscription on spokes is gitops which gets managed by ACM # subscriptions: projects: - eso - config-demo - hello-world applications: golang-external-secrets: name: golang-external-secrets namespace: golang-external-secrets project: eso chart: golang-external-secrets chartVersion: 0.1.* config-demo: name: config-demo namespace: config-demo project: config-demo path: charts/all/config-demo hello-world: name: hello-world namespace: hello-world project: hello-world path: charts/all/hello-world
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
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 |
Check the Red Hat OpenShift GitOps Operator is installed.
Launch the Group-One OpenShift ArgoCD console from nines menu in the top right of the OpenShift console. Verify the applications report the status
Healthy
andSynched
.
Verify that the hello-world application deployed successfully as follows:
Navigate to the Networking → Routes menu options on your managed cluster (edge) OpenShift.
From the Project: drop down select the hello-world project.
Click the Location URL. This should reveal the following:
Hello World! Hub Cluster domain is 'apps.aws-hub-cluster.openshift.org' Pod is running on Local Cluster Domain 'apps.aws-hub-cluster.openshift.org'
Verify that the config-demo application deployed successfully as follows:
Navigate to the Networking → Routes menu options on your managed cluster (edge) OpenShift.
Select the config-demo Project.
Click the Location URL. This should reveal the following:
Hub Cluster domain is 'apps.aws-hub-cluster.openshift.org' Pod is running on Local Cluster Domain 'apps.aws-hub-cluster.openshift.org' The secret is `secret`