Skip to content

Put a service under ArgoCD management

Step-by-step guide for taking a service that's currently deployed manually (kubectl apply) and putting it under automated ArgoCD management — plus the specific failure modes to check for before turning on selfHeal.

Step 1 — Add a kustomization.yaml, if the service doesn't have one

For a folder of raw manifests with no kustomization.yaml:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - 01-namespace.yaml
  - 02-configmap.yaml
  - 03-deployment.yaml
  # ...every manifest file in the folder

If every file in the folder already declares its own namespace: field explicitly, don't add a top-level namespace: override to the kustomization — it's redundant and can conflict. Only add one if the files themselves don't set a namespace.

Exclude anything explicitly marked as unused (a folder or file named with (no use), (not use), or similar) — don't wire up something someone already intentionally disabled.

Be cautious with one-time Jobs. If the folder contains a migration/setup Job meant to run once, think about whether it belongs in continuous selfHeal-managed GitOps at all — if someone deletes that Job object later (routine cleanup), selfHeal will recreate it, which means re-running the migration. Consider excluding one-time Jobs from the kustomization, or accept that re-running them is safe/idempotent before including them.

Step 2 — Create the ArgoCD Application

NUC vs DO cluster namespace difference:
Applications targeting the NUC cluster use metadata.namespace: argocd.
Applications targeting the DO cluster use metadata.namespace: default.
This matches how each cluster's ArgoCD instance was bootstrapped. Using the wrong namespace means ArgoCD on that cluster won't see the Application.

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: <service>-<env>
  namespace: argocd   # use 'default' for DO cluster apps
spec:
  project: default
  source:
    repoURL: <your-repo-url>
    targetRevision: main
    path: <path-to-the-folder-with-kustomization.yaml>
  destination:
    server: https://kubernetes.default.svc
    namespace: <target-namespace>
  syncPolicy:
    automated:
      prune: true
      selfHeal: true
    syncOptions:
      - CreateNamespace=true

Step 3 — Wire it into whatever root app already recurses your Applications

Check your root Application(s) for a directory: { recurse: true } source. If one already covers the parent folder you're adding into, nothing more is needed — it'll auto-discover the new file on next sync. If you're introducing a whole new top-level folder (e.g. splitting cdn/infrastructure out from a per-environment folder into their own shared top-level folders), add that new path explicitly to the root Application's sources: list.

A multi-source root Application (spec.sources, plural) lets one root Application recurse multiple independent paths — useful when you want e.g. staging, prod, and a shared cross-cutting folder (like monitoring) all under one root, without duplicating per-environment folder structures.

Step 4 — Before enabling selfHeal, check for drift risk

This is the step most likely to bite you at scale. selfHeal: true means ArgoCD will forcibly revert any difference between git and live state back to whatever's in git — including changes that were made manually and never got written back to the repo. Before turning this on for a service you didn't just personally verify:

  1. Check whether the object is already managed by a different, possibly out-of-repo, ArgoCD Application. Look for the argocd.argoproj.io/tracking-id annotation on the live resource:
    kubectl get <kind> <name> -n <namespace> -o jsonpath='{.metadata.annotations.argocd\.argoproj\.io/tracking-id}'
    
    If it already belongs to a different app, adding a second Application that also targets it risks both fighting for ownership. Resolve this explicitly (rename yours to match and adopt it, or scope yours away from that object) rather than leaving two Applications pointed at the same resource.
  2. Compare the live resource's actual spec against what's in the repo file, field by field, for anything nontrivial (image tag, resource limits, storage class, replica count, extra env vars). A stale or copy-pasted manifest that doesn't match reality will cause selfHeal to actively downgrade/break the running service the moment it syncs.
  3. For anything that owns its own child resources (an Operator-managed custom resource like a VMSingle/VMAlert/database Cluster CR that auto-creates a PVC or Service for itself) — declare only the top-level custom resource, not the child objects it manages. Declaring both makes the Operator and ArgoCD both think they own the child object, which risks the child getting deleted/recreated (data loss, for a PVC) the next time either one reconciles.
  4. If a shared PVC-backed workload needs a rollout, confirm its Deployment/StatefulSet strategy is compatible with the PVC's access mode. A ReadWriteOnce PVC with a RollingUpdate strategy default will deadlock the first time ArgoCD (or anything else) triggers a rollout — see the dedicated pitfall below.

Step 5 — Extracting ground truth when the checked-in manifest doesn't match reality

If you suspect (or confirm) that what's in git doesn't match what's actually running, don't guess — pull the live spec directly and rewrite the manifest to match it exactly before enabling automation:

kubectl get <kind> <name> -n <namespace> -o yaml

Strip anything server-managed that shouldn't be in a manifest you apply (status:, resourceVersion, uid, creationTimestamp, controller-injected ownerReferences). Cross-check any ConfigMap/Secret/Service dependencies the same way. Only once the manifest is a faithful, minimal reflection of live state should you point an automated Application at it — at that point, the first sync should be a true no-op.

Common pitfalls (all hit in practice)

  • Missing --- document separator when a file has two YAML resources back-to-back — the parser merges them and errors on duplicate apiVersion/kind/metadata/spec keys. Every additional resource in a multi-document file needs its own --- before it.
  • Declaring a PVC that an Operator already manages itself via a custom resource's spec.storage (or equivalent) — same class of bug as above, causes dual-ownership risk.
  • RollingUpdate strategy + ReadWriteOnce PVC + single replica — the new pod can never attach the volume while the old one holds it (Multi-Attach error ... Volume is already used by pod(s) ...). Fix: strategy: { type: Recreate }.
  • Stale ArgoCD manifest cache after fixing a broken file — a normal sync can keep reporting the old error. Force it:
    kubectl annotate application <app> -n argocd argocd.argoproj.io/refresh=hard --overwrite
    
  • A non-fast-forward git push after committing a fix locally — always git fetch and check git log HEAD..origin/main --oneline before pushing, in case something else landed on the remote in the meantime.
  • Assuming a comment in an old manifest is accurate. A file claiming a value means "1 day" when the actual tool's flag semantics interpret it as "1 month" (or similar unit mismatches) is a real, previously-seen failure mode — verify against the tool's actual documented flag format, not the comment someone wrote next to it.
  • SharedResourceWarning when two Apps own the same Secret — if two ArgoCD Applications both declare a Secret with the same name/namespace, ArgoCD logs a warning and the second app to sync will overwrite or fight the first. Fix: give each app its own uniquely-named Secret (e.g. ai-agent-secret, ai-mcp-secret) rather than sharing one.
  • HPA/replica count conflict causing OutOfSync — if an HPA has scaled a Deployment above the replicas: count in the kustomization, ArgoCD reports OutOfSync and selfHeal will keep fighting the HPA. Keep replicas: in the kustomization (so the pattern is consistent with other apps), and raise resource limits on the Deployment so the HPA has less pressure to scale above the declared count.

ArgoCD App Location Reference

All Application manifests live under argocd/apps/. The root apps recurse each subdirectory:

argocd/apps/
├── prod/
│   ├── nuc/        ← NUC cluster apps (namespace: argocd)
│   └── do/         ← DO cluster apps (namespace: default)
├── staging/
│   ├── nuc/
│   └── do/
├── ai/             ← AI stack apps (cross-env)
├── monitoring/     ← Monitoring stack apps
└── infrastructure/ ← Infrastructure apps (cert-manager, etc.)

Services under ArgoCD as of 2026-09:

Cluster App Namespace Path
NUC authapi-prod application services/application/authapi/overlays/prod
NUC orgconsole-prod application services/application/orgconsole/overlays/prod
NUC platformconsole-prod application services/application/platformconsole/overlays/prod
NUC tellyboardadmin-prod application services/application/tellyboard/overlays/prod
NUC tellyid-prod application services/application/tellyid/overlays/prod
NUC vernemq-prod vernemq services/access/vernemq/...
NUC nexus-prod nexus services/access/nexus/...
DO headscale-prod headscale headscale/
DO elb-prod cdn services/cdn/elb/...
DO gslb-prod cdn services/cdn/gslb/...
DO promoweb-prod application services/application/promoweb/...
Shared vector-prod monitoring services/monitoring/vector/
Shared ai-agent-staging ai services/ai/agent/overlays/staging
Shared ai-mcp-staging ai services/ai/mcp/overlays/staging