Dagweave catalog

Sync an Argo CD application

argocd-syncv1.0.0updated 2026-10-181 version

Tell Argo CD to sync an application to its Git source and wait until the sync finishes and the application is healthy. Logs in with an API token from a Kubernetes Secret.

Install v1.0.0

Installs the template into your Argo namespace. The URL is pinned to this version.

kubectl apply -n argo -f https://catalog.dagweave.com/api/v1/items/argocd-sync/1.0.0/template.yaml

Or with the Argo CLI:

argo template create -n argo https://catalog.dagweave.com/api/v1/items/argocd-sync/1.0.0/template.yaml

Facts

Category
Kubernetes
Tags
kubernetes python
Entrypoint
sync
Template SHA-256
b1f8391f3bada8bb38b6cf7c305ba40a5de36d91644d2da406e4d686bc739c79
Source
argocd-sync at catalog commit 67458f7
API
item document, latest template.yaml

Images and provenance

Every image is pinned by digest, so a rebuilt tag can never change what this version runs.

RepositoryTagDigest
cgr.dev/chainguard/pythonlatest-devsha256:8a5780972067cfba4592b10e786a889807ed876c1100f89410fd0ed4e398992c

Parameters

NameDescriptionDefault
app required Name of the Argo CD application.
Example checkout-api
none
server-url required Address of the Argo CD server, with https://.
Example https://argocd.example.com
none
insecure Set to "true" to skip TLS certificate checks, for a server with a self-signed certificate.
One of true, false
false
prune Set to "true" to delete resources that are no longer in Git.
One of true, false
false
revision Git revision to sync to. Leave blank to use the revision the application tracks. empty
timeout Seconds to wait for the sync, counted again from the same start for health. 300
token-secret-key Key in that Secret that holds the token. token
token-secret-name Name of the Kubernetes Secret that holds an Argo CD API token. argocd-auth
wait-for-health Set to "true" to wait for the application to report Healthy after the sync.
One of true, false
true

WorkflowTemplate

Download template.yaml

apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: argocd-sync
  labels:
    dagweave.io/catalog-item: argocd-sync
  annotations:
    dagweave.io/catalog-version: "1.0.0"
    dagweave.io/catalog-category: "Kubernetes"
spec:
  entrypoint: sync
  templates:
    - name: sync
      inputs:
        parameters:
          - name: app
          - name: server-url
          - name: revision
            default: ""
          - name: prune
            default: "false"
          - name: wait-for-health
            default: "true"
          - name: timeout
            default: "300"
          - name: insecure
            default: "false"
          - name: token-secret-name
            default: "argocd-auth"
          - name: token-secret-key
            default: "token"
      retryStrategy:
        limit: "2"
        retryPolicy: OnError
        backoff:
          duration: 10s
          factor: "2"
          maxDuration: 2m
      container:
        # cgr.dev/chainguard/python:latest-dev
        image: cgr.dev/chainguard/python@sha256:8a5780972067cfba4592b10e786a889807ed876c1100f89410fd0ed4e398992c
        command: [sh, -c]
        args:
          - |
            set -eu
            python - <<'PY'
            import json, os, ssl, sys, time, urllib.error, urllib.request

            env = os.environ
            base = env["SERVER_URL"].rstrip("/") + "/api/v1/applications/" + env["APP"]
            ctx = ssl._create_unverified_context() if env["INSECURE"] == "true" else None
            deadline = time.time() + int(env["TIMEOUT"])


            def call(method, url, body=None):
                req = urllib.request.Request(
                    url, method=method, data=None if body is None else json.dumps(body).encode(),
                    headers={"Content-Type": "application/json", "Authorization": "Bearer " + env["ARGOCD_AUTH_TOKEN"]})
                try:
                    with urllib.request.urlopen(req, timeout=30, context=ctx) as resp:
                        return json.load(resp)
                except urllib.error.HTTPError as err:
                    sys.exit("argocd answered %s: %s" % (err.code, err.read().decode()))


            body = {"prune": env["PRUNE"] == "true"}
            if env["REVISION"]:
                body["revision"] = env["REVISION"]
            call("POST", base + "/sync", body)
            print("sync requested for", env["APP"])

            while True:
                app = call("GET", base)
                op = app.get("status", {}).get("operationState", {})
                if not app.get("operation") and op.get("phase") in ("Succeeded", "Failed", "Error"):
                    break
                if time.time() > deadline:
                    sys.exit("timed out waiting for the sync to finish")
                time.sleep(3)
            print("sync", op["phase"], "-", op.get("message", ""))
            if op["phase"] != "Succeeded":
                sys.exit(1)

            if env["WAIT_FOR_HEALTH"] == "true":
                while True:
                    health = call("GET", base).get("status", {}).get("health", {}).get("status")
                    if health == "Healthy":
                        break
                    if time.time() > deadline:
                        sys.exit("timed out waiting for Healthy, last saw " + str(health))
                    time.sleep(3)
                print("application is Healthy")
            PY
        env:
          - name: APP
            value: "{{inputs.parameters.app}}"
          - name: SERVER_URL
            value: "{{inputs.parameters.server-url}}"
          - name: REVISION
            value: "{{inputs.parameters.revision}}"
          - name: PRUNE
            value: "{{inputs.parameters.prune}}"
          - name: WAIT_FOR_HEALTH
            value: "{{inputs.parameters.wait-for-health}}"
          - name: TIMEOUT
            value: "{{inputs.parameters.timeout}}"
          - name: INSECURE
            value: "{{inputs.parameters.insecure}}"
          - name: ARGOCD_AUTH_TOKEN
            valueFrom:
              secretKeyRef:
                name: "{{inputs.parameters.token-secret-name}}"
                key: "{{inputs.parameters.token-secret-key}}"
        resources:
          requests:
            cpu: 50m
            memory: 64Mi
          limits:
            memory: 256Mi

Version history

Read from the item's changelog. Each version has its own JSON document; the pinned catalogue vendors the manifest of the latest one, so that is the version that installs.

  1. 1.0.0 latest 2026-10-18

    Initial release.

    kubectl apply -n argo -f https://catalog.dagweave.com/api/v1/items/argocd-sync/1.0.0/template.yaml
    argo template create -n argo https://catalog.dagweave.com/api/v1/items/argocd-sync/1.0.0/template.yaml

    version document, template.yaml

Run it once

After installing, from the command line.

argo submit -n argo --from workflowtemplate/argocd-sync \
  -p app=checkout-api \
  -p server-url=https://argocd.example.com

Workflow that references it

A Workflow with the required parameters filled from the examples.

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: argocd-sync-
spec:
  workflowTemplateRef:
    name: argocd-sync
  arguments:
    parameters:
      - name: app
        value: "checkout-api"
      - name: server-url
        value: "https://argocd.example.com"

As a step of a larger workflow

steps:
  - - name: argocd-sync
      templateRef:
        name: argocd-sync
        template: sync