Argo CD Application Sync Degraded Sentinel
Audits Argo CD applications to detect out-of-sync states and degraded Kubernetes deployment conditions.
Clears finalizers on namespaces stuck Terminating and reports the cleanup on Slack.
list_namespaces (io.kestra.plugin.scripts.shell.Commands) dumps all namespaces as JSON with kubectl.find_stuck (io.kestra.plugin.scripts.python.Script) keeps only namespaces in Terminating phase whose deletion timestamp is older than stuck_minutes. System namespaces (kube-system, kube-public, kube-node-lease) are skipped unconditionally. The stuck names land in stuck.txt.maybe_clean (io.kestra.plugin.core.flow.If) runs only when something is stuck. Inside it, do_clean runs only in live mode (dry_run: false): clear_finalizers GETs each stuck namespace, empties its finalizer list, and PUTs it back through the /finalize subresource, which is the only write the API accepts for a Terminating namespace. send_summary always posts the report to Slack.kubectl replace --raw .../finalize dance.dry_run is true unless you explicitly turn it off, and only namespaces already Terminating past the threshold are ever touched.Anyone who has ever had kubectl delete namespace hang forever because a finalizer never cleared: operators, platform teams, and minikube experimenters alike.
The manual fix is a multi-step incantation people copy from Stack Overflow under pressure, which is exactly when mistakes happen. As a flow it is scheduled, audited, and safe by default: credentials stay in secrets, every run keeps its logs where you can see what was cleared, and the dry-run default means the first run can never surprise you.
| Secret | What it is |
|---|---|
CLIENT_CRT |
base64-encoded client certificate from your kubeconfig |
CLIENT_KEY |
base64-encoded client key from your kubeconfig |
MASTERURL |
base64-encoded Kubernetes API server URL, reachable from inside the Kestra container |
SLACK_WEBHOOK |
base64-encoded Slack Incoming Webhook URL |
In Kestra OSS, secrets come from environment variables prefixed with SECRET_ and must be base64-encoded. If the API URL uses 127.0.0.1 or localhost, replace it with host.docker.internal so the Kestra container can reach it.
SECRET_ environment variables.dry_run: true: the Slack report lists stuck namespaces, and nothing is touched.dry_run: false: the finalizers are cleared, the namespaces finish deleting, and the Slack report says so.stuck_minutes for dev clusters where you want faster recovery.| Input | Type | Default | What it does |
|---|---|---|---|
stuck_minutes |
INT | 30 |
namespaces Terminating longer than this count as stuck |
dry_run |
BOOL | true |
when true, only reports what would be cleaned without touching anything |
slack_webhook |
STRING | (required) | Incoming webhook URL of the Slack channel for the cleanup report |
dry_run defaults to true for a reason. Flip it to false only after you have seen a dry-run report and you trust the list.