Deploying Argo CD with the App of Apps Pattern

In this article, we will explore how to set up Argo CD using the app of apps pattern on a local Kubernetes cluster, specifically using Docker Desktop. This approach allows you to manage multiple applications through a single root application.

Prerequisites

  • A running Kubernetes cluster (e.g., Docker Desktop)
  • Helm installed on your local machine

Step 1: Deploy Argo CD Using Helm

To deploy Argo CD, you can use the official Helm chart. Run the following command to install it:

helm repo add argo https://argoproj.github.io/argo-helm
helm install argocd argo/argo-cd --namespace argocd --create-namespace

Step 2: Create the Root Application YAML

Once Argo CD is deployed, you can create a root application that follows the app of apps pattern. Below is an example YAML configuration:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: root
  finalizers:
    - resources-finalizer.argocd.argoproj.io
spec:
  destination:
    server: http://kubernetes.default.svc
    namespace: argocd
  project: default
  source:
    path: apps/
    repoURL: https://github.com/gajewa/gitops.git
    targetRevision: HEAD
  syncPolicy:
    automated:
      prune: true
      selfHeal: true

This YAML file defines the root application, specifying where to find the child applications in your Git repository.

Step 3: Apply the YAML

To create the root application in Argo CD, apply the YAML file using the following command:

kubectl apply -f root-application.yaml

Step 4: Troubleshooting

If the application does not appear in the Argo CD UI, check the following:

  • Ensure that the Custom Resource Definitions (CRDs) for Argo CD are installed:
kubectl get crd

You should see entries for applications.argoproj.io and appprojects.argoproj.io.

  • Verify that the repository URL and path are correct and accessible from the Argo CD server.
  • Check the Argo CD logs for any errors that might indicate why the applications are not being created.

Conclusion

By following these steps, you should be able to set up Argo CD using the app of apps pattern effectively. This method allows for better organization and management of multiple applications within your Kubernetes environment.