Search code examples
kubernetesargocdgitops

How to init an ArgoCD application from a git repository


I would like to create an argoCD application right from the git repository, ie the gitOps way. I already created a CRD file for the application which looks like this:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: my-service
  namespace: argocd
spec:
  destination:
    namespace: default
    server: https://kubernetes.default.svc
  syncPolicy:
    syncOptions:
    - CreateNamespace=true
  project: default
  source:
    path: clusters/helm-chart
    repoURL: https://github.com/user/my-repo.git
    targetRevision: HEAD
    helm:
      values: |
        image:
          repository: user/my-image
          pullPolicy: Always
          tag: xxx


My current workflow is to apply this CRD to my cluster with k apply -f application.yaml.

Question: how can I instruct ArgoCD to go and sync/create the application I have defined at https://github.com/user/my-repo.git without first creating that application "manually"?


Solution

  • At some point you have to manually apply a manifest to your ArgoCD instance.

    You can limit that to a single manifest if you utilize the app-of-apps pattern, in which you have a repository that contains all your ArgoCD application manifests.

    You can also create ApplicationSets to automatically generate ArgoCD applications from templates based on the content of a git repository, the names of clusters registered with ArgoCD, and other data.