theautomation
theautomation

Reputation: 85

ArgoCD path in application, how does it work?

I am using ArgoCD for a couple of weeks now and I don't really understand how to define spec.source.path in the application.

I have set the following path:

...
spec:
  source:
    repoURL: https://github.com/theautomation/home-assistant.git
    targetRevision: main
    path: deploy/k8s
...

but still argoCD syncs when a commit is committed outside this path in the repo, argoCD should ONLY watch this path for changes right? or does it not work that way?

Full application yaml:

---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: home-assistant
  namespace: devops
  annotations:
    notifications.argoproj.io/subscribe.slack: cicd
    argocd.argoproj.io/manifest-generate-paths: /deploy
spec:
  project: default
  source:
    repoURL: https://github.com/theautomation/home-assistant.git
    targetRevision: main
    path: deploy/k8s
    directory:
      recurse: true
  destination:
    server: https://kubernetes.default.svc
    namespace: home-automation
  syncPolicy:
    syncOptions:
      - CreateNamespace=true
      - Validate=true
      - PrunePropagationPolicy=foreground
      - PruneLast=true
    automated:
      selfHeal: true
      prune: true
    retry:
      limit: 2
      backoff:
        duration: 5s
        factor: 2
        maxDuration: 3m

Upvotes: 0

Views: 12259

Answers (2)

crenshaw-dev
crenshaw-dev

Reputation: 8402

By default, Argo CD will sync when the commit changes regardless of what files were modified. This can be helpful when something in an App's directory references (via symlink or some other mechanism) something outside its directory.

If you are using webhooks to trigger the syncs, and you know an App isn't influenced by outside files, you can use an annotation to specify which directory (or directories) to watch for changes.

If you are not using webhooks and are relying on the usual reconciliation loop, the sync will still happen regardless of the annotation.

Upvotes: 2

LostJon
LostJon

Reputation: 2387

Argo CD will ONLY look for changes that have been applied to your targetRevision (ie main) and changes within your defined path. Assuming you have deploy/k8s with a bunch of manifests in that space, it will automatically look for changes to files within that path. Also, bc you have syncPolicy.automated configured, it will automatically apply changes when it is found (normally ab 3-5 mins bc of git polling, unless you have have webhooks configured)

Upvotes: 0

Related Questions