GitOps 101 (Part 4)

In our previous article, we explained how to create the necessary manifest files for our “React Application” to be deployed via ArgoCD. In this article, we will explain that we will create the manifest files of the “React Application” to be created for ArgoCD. While applying these manifest files, we will apply the ArgoCD pattern, the App of Apps pattern, and we will explain this pattern at a basic level.

ArgoCD Image

First of all, we need to answer the question of what these manifest files do. These manifest files in YAML format contain information on how the application will be located on ArgoCD. ArgoCD runs these manifest definitions and sends deployment instructions to Kubernetes.

The App of Apps pattern, on the other hand, is a managerial approach where we gather your applications under a single application. It will be easier and more understandable for the person who will manage the applications to collect the microservices of your application within the framework of such a pattern. To make a hierarchy, we need to reference all applications with a manifest root file.

App of Apps Logic

In the manifest file, we refer to the applications, we need to define the metadata of the application that is the root and the specs of this root application. There are definitions such as where the application should be deployed, what are the sync policies, which directory the manifest files of the applications are in, etc. in this root manifest file.

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: app-of-apps
  namespace: argocd
spec:
  destination:
    server: https://kubernetes.default.svc
    namespace: argocd
  project: gitops # you can change the project name
  source:
    path: applications-manifest-folder-path
    repoURL: https://gitlab.com/group/subgroup-if-any/gitops-argo-cd.git
    targetRevision: HEAD
  syncPolicy:
    automated:
      prune: true
      selfHeal: true
      allowEmpty: true

With the definitions we made in the root manifest, we have referred to the directory where the manifests of the applications are located. Now let’s create our application manifest file and make the necessary definitions for the “React Application”.

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: gitops-react-app
spec: 
  destination:
    namespace: gitops
    server: https://kubernetes.default.svc
  project: gitops
  source:
    path: charts/gitops-react-app
    repoURL: 'https://gitlab.com/devops-obss/demos/gitops-argo-cd.git'
    targetRevision: HEAD
  syncPolicy:
    automated:
      prune: true
      selfHeal: true
      allowEmpty: true
    syncOptions:
      - CreateNamespace=true

The biggest difference in our application manifest, which contains a similar structure to the root manifest, is that the directory where we define the path refers to the Kubernetes manifest YAML files we created in our previous article. In this way, ArgoCD starts the deployment process by receiving the manifest files at the referenced points.

You can implement the App of Apps pattern through the UI and the ArgoCD CLI. You can execute the following command on the CLI to create the application:

argocd app create -f root.yaml

After executing the command, applications will be created automatically on ArgoCD UI. If you define sync policies correctly, applications on Kubernetes will start the automatic deployment process.

ArgoCD output with App of Apps Pattern

In our next article, we will define a deploy job in our CI/CD structure so that the GitOps system can work, and after this definition, we will observe how an end-to-end GitOps solution works together with the results. Thanks for reading our article.