Deploying the application via GitOps

Deploy your instance of ArgoCD

We will start by deploying an instance of ArgoCD in your namespace.
This will be used to deploy the application.

  • Copy the following text, and paste it in the OpenShift Terminal to deploy ArgoCD.

    cat <<EOF | oc apply -f -
    ---
    apiVersion: argoproj.io/v1alpha1
    kind: ArgoCD
    metadata:
      name: argocd
    spec:
      sso:
        dex:
          openShiftOAuth: true
          resources:
            limits:
              cpu: 500m
              memory: 256Mi
            requests:
              cpu: 250m
              memory: 128Mi
        provider: dex
      rbac:
        defaultPolicy: "role:readonly"
        policy: "g, system:authenticated, role:admin"
        scopes: "[groups]"
      server:
        insecure: true
        route:
          enabled: true
          tls:
            insecureEdgeTerminationPolicy: Redirect
            termination: edge
    EOF
  • Still in the Terminal, run the following command to check the status of the ArgoCD deployment.

    oc rollout status deploy/argocd-server
  • After a few seconds, the deployment should be complete:

    argocd rollout

Optional: If you know and understand ArgoCD and want to look at its interface, look at the following details. Otherwise, you can skip to the next step.

Details

Now that Argo is deployed, you can connect to its UI through its Route.

  • Let’s find the Route of the ArgoCD instance by running the following command in the Terminal:

    echo "   ArgoCD UI : https://$(oc get route argocd-server -ojsonpath='{.status.ingress[0].host}')/ "
  • You should obtain something like this:

    argocd route
  • You can now connect to the ArgoCD UI using your given credentials (userX/openshift).

Deploy the application(s) via GitOps

Now that ArgoCD is deployed in your namespace, we can use it to deploy the application via GitOps.

  • Copy the content of the following text, and paste it in the OpenShift Terminal to deploy the application.

    cat <<EOF | oc apply -f -
    ---
    apiVersion: argoproj.io/v1alpha1
    kind: Application
    metadata:
      name: claim-insurance-app
    spec:
      destination:
        server: https://kubernetes.default.svc
        namespace: userX
      project: default
      source:
        path: lab-materials/05/app
        repoURL: https://github.com/rh-aiservices-bu/insurance-claim-processing.git
        targetRevision: main
      syncPolicy:
        automated:
          prune: true
          selfHeal: false
        syncOptions: [CreateNamespace=false]
    EOF
  • Wait for the application to be fully deployed and initialized. It will be the case when the two Jobs db-init-job and populate-images are completed (Completions: 1 of 1).

Make sure you are in the right project (your username) and then check Jobs under AdministratorStorage.

jobs completed
  • Once the application is deployed, you can check its Route with the following command:

    echo "   Application URL : https://$(oc get route ic-app -ojsonpath='{.status.ingress[0].host}')/ "

Open the URL in your browser to access the application and head to the next step.