This is a cache of https://docs.openshift.com/container-platform/4.7/cicd/gitops/configuring_argo_cd_to_recursively_sync_a_git_repository_with_your_application/configuring-an-openshift-cluster-by-deploying-an-application-with-cluster-configurations.html. It is a snapshot of the page at 2024-11-27T21:58:23.695+0000.
Configuring an OpenShift cluster by deploying an application with cluster configurations - GitOps | CI/CD | OpenShift Container Platform 4.7
×

With Red Hat OpenShift GitOps, you can configure Argo CD to recursively sync the content of a Git directory with an application that contains custom configurations for your cluster.

Prerequisites
  • Red Hat OpenShift GitOps is installed in your cluster.

Logging in to the Argo CD instance by using your OpenShift credentials

Red Hat OpenShift GitOps Operator automatically creates a ready-to-use Argo CD instance that is available in the openshift-gitops namespace.

Prerequisites
  • You have installed the Red Hat OpenShift GitOps Operator in your cluster.

Procedure
  1. In the Administrator perspective of the web console, navigate to OperatorsInstalled Operators to verify that the Red Hat OpenShift GitOps Operator is installed.

  2. Navigate to the red hat applications menu icon menu → OpenShift GitOpsCluster Argo CD. The login page of the Argo CD UI is displayed in a new window.

  3. Obtain the password for the Argo CD instance:

    1. Navigate to the Developer perspective of the web console. A list of available projects is displayed.

    2. Navigate to the openshift-gitops project.

    3. Use the left navigation panel to navigate to the secrets page.

    4. Select the openshift-gitops-cluster instance to display the password.

    5. Copy the password.

  4. Use this password and admin as the username to log in to the Argo CD UI in the new window.

Creating an application by using the Argo CD dashboard

Argo CD provides a dashboard which allows you to create applications.

This sample workflow walks you through the process of configuring Argo CD to recursively sync the content of the cluster directory to the cluster-configs application. The directory defines the OpenShift Container Platform web console cluster configurations that add a link to the Red Hat Developer Blog - Kubernetes under the red hat applications menu icon menu in the web console, and defines a namespace spring-petclinic on the cluster.

Procedure
  1. In the Argo CD dashboard, click NEW APP to add a new Argo CD application.

  2. For this workflow, create a cluster-configs application with the following configurations:

    Application Name

    cluster-configs

    Project

    default

    Sync Policy

    Manual

    Repository URL

    https://github.com/redhat-developer/openshift-gitops-getting-started

    Revision

    HEAD

    Path

    cluster

    Destination

    https://kubernetes.default.svc

    Namespace

    spring-petclinic

    Directory Recurse

    checked

  3. Click CREATE to create your application.

  4. Open the Administrator perspective of the web console and navigate to AdministrationNamespaces in the menu on the left.

  5. Search for and select the namespace, then enter argocd.argoproj.io/managed-by=openshift-gitops in the Label field so that the Argo CD instance in the openshift-gitops namespace can manage your namespace.

Creating an application by using the oc tool

You can create Argo CD applications in your terminal by using the oc tool.

Procedure
  1. Download the sample application:

    $ git clone git@github.com:redhat-developer/openshift-gitops-getting-started.git
  2. Create the application:

    $ oc create -f openshift-gitops-getting-started/argo/cluster.yaml
  3. Run the oc get command to review the created application:

    $ oc get application -n openshift-gitops
  4. Add a label to the namespace your application is deployed in so that the Argo CD instance in the openshift-gitops namespace can manage it:

    $ oc label namespace spring-petclinic argocd.argoproj.io/managed-by=openshift-gitops

Synchronizing your application with your Git repository

Procedure
  1. In the Argo CD dashboard, notice that the cluster-configs Argo CD application has the statuses Missing and OutOfSync. Because the application was configured with a manual sync policy, Argo CD does not sync it automatically.

  2. Click SYNC on the cluster-configs tile, review the changes, and then click SYNCHRONIZE. Argo CD will detect any changes in the Git repository automatically. If the configurations are changed, Argo CD will change the status of the cluster-configs to OutOfSync. You can modify the synchronization policy for Argo CD to automatically apply changes from your Git repository to the cluster.

  3. Notice that the cluster-configs Argo CD application now has the statuses Healthy and Synced. Click the cluster-configs tile to check the details of the synchronized resources and their status on the cluster.

  4. Navigate to the OpenShift Container Platform web console and click red hat applications menu icon to verify that a link to the Red Hat Developer Blog - Kubernetes is now present there.

  5. Navigate to the Project page and search for the spring-petclinic namespace to verify that it has been added to the cluster.

    Your cluster configurations have been successfully synchronized to the cluster.