Script icon
Process icon
If icon
SlackIncomingWebhook icon
Log icon
Return icon
Schedule icon

Argo CD Application Sync Degraded Sentinel

Audits Argo CD applications to detect out-of-sync states and degraded conditions, preventing GitOps deployment failures and silent drift.

Categories
CloudInfrastructure

Enterprise Kubernetes platforms rely on Argo CD for declarative GitOps continuous delivery. When deployments suffer from Helm value syntax errors, missing secrets, failing probes, or CRD schema mismatches, applications become stuck in OutOfSync or Degraded states. If unattended, automated rollouts freeze and production workloads diverge from Git source-of-truth repositories. This sentinel interrogates the Argo CD REST API, audits sync and health conditions across target projects, and notifies DevOps and GitOps teams on Slack with exact sync remediation commands.

How it works

  1. Scheduled triggering: Executes every 30 minutes using an automated cron schedule trigger (*/30 * * * *) or triggers on-demand via manual execution or CI/CD commit webhooks.
  2. Application enumeration: Queries the Argo CD REST API (/api/v1/applications) with an authorized bearer token.
  3. Health and sync inspection: Parses .status.sync.status and .status.health.status for each application, flagging states like OutOfSync, Degraded, or Missing.
  4. Condition evaluation: An io.kestra.plugin.core.flow.If task evaluates whether degraded_apps_count exceeds max_tolerated_degraded_apps.
  5. Slack alert dispatch: Sends a high-priority incident payload via SlackIncomingWebhook listing application names, projects, sync states, and argocd app sync commands.
  6. Audit trail logging and return: Emits operational execution logs and returns a structured compliance manifest for auditing.

Architecture diagram

flowchart TD
  A[scheduled_argocd_audit Schedule Trigger] --> B[scan_argocd_applications Python Script]
  B --> C[check_degraded_apps Flowable If]
  C -- Degraded Found --> D[notify_slack_gitops Webhook]
  C -- All Apps Synced --> E[log_argocd_audit_status Log]
  D --> E
  E --> F[export_argocd_manifest Return]

Use cases

  • GitOps drift prevention: Detect unauthorized cluster modifications or failed automated reconciliations before production environments diverge.
  • Deployment rollout verification: Confirm that new container image updates or Helm charts applied via Git successfully complete health checks.
  • Multi-cluster fleet governance: Monitor application health across dozens of peripheral Kubernetes clusters managed by a central Argo CD control plane.

Inputs

Name Type Default Description
argocd_server_url STRING https://argocd.internal.company.com Base URL for the Argo CD API server.
project_filter STRING default Name of the Argo CD project to audit, or all to scan all registered applications.
alert_on_degraded_sync BOOL true Whether to dispatch alerts when out-of-sync or degraded applications are detected.
max_tolerated_degraded_apps INT 0 Maximum allowable count of degraded or out-of-sync applications before raising alerts.

Expected outputs

  • {{ outputs.scan_argocd_applications.vars.total_applications_audited }}: Number of Argo CD applications inspected during the audit.
  • {{ outputs.scan_argocd_applications.vars.degraded_apps_count }}: Number of applications in degraded, out-of-sync, or missing states.
  • {{ outputs.scan_argocd_applications.vars.degraded_apps_details }}: Serialized JSON list of degraded applications with sync status and CLI commands.
  • {{ outputs.export_argocd_manifest.value }}: Structured dictionary containing the consolidated GitOps cluster health summary.

Prerequisites

  • Outbound HTTPS network access from Kestra execution workers to the Argo CD API server.
  • Argo CD service account bearer token with applications, get permissions.
  • Incoming Slack Webhook configured for GitOps deployment alerting.

Secrets

  • ARGOCD_AUTH_TOKEN: Argo CD API bearer token with read access to applications.
  • SLACK_WEBHOOK_URL: Slack Incoming Webhook endpoint URL used for sending security alerts.

Quick start

  1. Define ARGOCD_AUTH_TOKEN and SLACK_WEBHOOK_URL in your Kestra Secret storage.
  2. Import this workflow into your Kestra instance under the company.devops namespace.
  3. Configure argocd_server_url to point to your internal Argo CD domain.
  4. Run a manual execution to test application discovery and verify Slack alerting.

Common pitfalls and troubleshooting

  • Self-signed TLS certificates: Internal Argo CD instances often use self-signed certificates; configure CA bundle environment variables or verify SSL parameters appropriately.
  • RBAC project scoping: Ensure the service account token has read access to the specified project; unscoped tokens default to the default project only.
  • Sync windows: Argo CD applications with active deny sync windows may show out-of-sync as intended; ensure automated maintenance schedules account for maintenance windows.

How to extend

  • Automated sync trigger: Add a task that executes POST /api/v1/applications/{name}/sync to automatically trigger reconciliation for transient sync failures.
  • Rollback automation: Automatically trigger a Git commit reverting the offending deployment commit when health conditions remain degraded for over 15 minutes.
  • PagerDuty on-call escalation: Escalate critical production application degradations directly to the on-call platform engineering team.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.