Script icon
Docker icon
If icon
SlackIncomingWebhook icon
Log icon
Return icon
Schedule icon

Kubernetes cert-manager ACME Challenge Timeout Sentinel

Audits Kubernetes cert-manager ACME challenge custom resources for stalled validation states, alerting platform teams via Slack before certificates expire.

Categories
CloudInfrastructure

Audits Kubernetes cert-manager ACME HTTP01 and DNS01 challenge custom resources across targeted namespaces, detecting stalled validation attempts before TLS certificate expiration outages impact public ingress traffic.

How it works

  1. ACME Custom Resource Discovery: Authenticates to the Kubernetes API server using kubeconfig credentials or in-cluster ServiceAccount tokens to inspect acme.cert-manager.io/v1 Challenge custom resources.
  2. Validation State and Age Computation: Evaluates challenge status conditions against lookback duration thresholds, isolating pending or errored challenges exceeding maximum tolerated resolution windows.
  3. Conditional SRE Alerting: Evaluates whether stalled challenges equal or exceed configured threshold limits, dispatching formatted operational incident alerts to Slack webhook endpoints.
  4. Compliance Telemetry Export: Emits structured execution outputs including challenged domain records, status messages, and duration timings for cluster security observability.

Architecture diagram

flowchart TD
    A[periodic_acme_challenge_audit Schedule Trigger] --> B[scan_acme_challenges Python Script]
    B --> C[check_stalled_challenges Flowable If]
    C -- Threshold Breached --> D[notify_slack_cert_alert Webhook]
    C -- Metrics Nominal --> E[log_nominal_cert_state Log]
    D --> E
    E --> F[export_cert_manifest Return]

Architecture components

  • Trigger (periodic_acme_challenge_audit): Drives scheduled recurring surveillance cycles without human intervention.
  • Inspection Task (scan_acme_challenges): Queries target APIs and structures diagnostic indicators via Kestra outputs.
  • Evaluation Gate (check_stalled_challenges): Evaluates operational safety boundaries using deterministic boolean branching.
  • Notification Action (notify_slack_cert_alert): Dispatches rich, actionable incident messages directly to team channels.
  • Manifest Return (export_cert_manifest): Emits structured compliance payloads for SIEM and analytics records.

Key capabilities

  • Automated Health Polling: Continuous scheduled surveillance executed on customizable recurring intervals without dedicated agent daemons.
  • Deterministic Threshold Evaluation: Pure boolean and numeric tolerance checks eliminating false positives and alert noise.
  • Contextual Incident Notification: Rich Slack messages populated with explicit resource identifiers, error reasons, and metrics.
  • Machine-Readable Audit Manifest: Structured execution telemetry exported for compliance archives, SIEM ingestion, or analytics dashboards.

What you get

  • Continuous automated surveillance of cert-manager ACME challenge lifecycles without manual kubectl intervention
  • Early warning for Let's Encrypt DNS01 propagation failures, Cloudflare API throttling, and HTTP01 ingress routing misconfigurations
  • Guaranteed zero-failure alerting pipeline preventing silent certificate expiration on production ingress controllers
  • Auditable structured telemetry manifest containing challenge names, namespace scopes, and validation failure reasons

Who it's for

  • Platform Engineering teams running Kubernetes ingress controllers with automated Let's Encrypt TLS renewal
  • Site Reliability Engineers managing public-facing gateway APIs requiring five-nines transport layer encryption uptime
  • DevOps teams maintaining automated microservice routing using Istio, Traefik, Contour, or NGINX ingress

Why orchestrate this with Kestra

  • Native Kubernetes API script runner executing isolated queries without maintaining persistent daemon processes
  • Decoupled secret management securing cluster kubeconfig credentials and notification webhooks through encrypted vaults
  • Declarative Flowable branching logic ensuring team notifications are dispatched only during actionable operational incidents
  • Unified schedule triggers enabling customizable cron frequency aligned with cluster maintenance windows

Use cases

  • DNS-01 Provider Failure Detection: Identify Route53 or Cloudflare API authentication failures before production TLS certificates expire.
  • HTTP-01 Ingress Deadlock Discovery: Detect routing collisions where ACME challenge solver pods fail ingress connectivity tests.
  • Fleet-wide Certificate Renewal Auditing: Audit automated certificate renewals across multi-region Kubernetes clusters from a central control plane.

Inputs

Name Type Default Description
namespace_filter STRING istio-system Kubernetes namespace containing cert-manager Certificate and Challenge custom resources to audit.
max_challenge_age_minutes INT 30 Maximum tolerated duration in minutes an ACME challenge may remain in pending state before classified as stalled.
stalled_challenge_threshold INT 1 Threshold count of pending or failed ACME challenges that triggers an automated team alert.
alert_on_stalled BOOL True Toggle whether Slack webhook alerts are dispatched upon detecting stalled ACME challenges.

Expected outputs

  • {{ outputs.scan_acme_challenges.vars.total_challenges }}: Total number of ACME challenge custom resources currently active in the audited namespace.
  • {{ outputs.scan_acme_challenges.vars.stalled_count }}: Count of ACME challenges persisting in pending or errored states exceeding maximum age limits.
  • {{ outputs.scan_acme_challenges.vars.stalled_names }}: Comma-separated list of identified stalled ACME challenge resource identifiers.
  • {{ outputs.scan_acme_challenges.vars.failure_reasons }}: Concatenated error conditions and failure messages extracted from challenge status blocks.
  • {{ outputs.scan_acme_challenges.vars.is_alerting }}: Boolean flag indicating whether stalled challenge volume breached configured alert thresholds.

Prerequisites

  • Cert-manager v1.0 or higher deployed within the target Kubernetes cluster managing ACME Issuer or ClusterIssuer resources.
  • Kubernetes ServiceAccount with RBAC get and list permissions on challenges.acme.cert-manager.io custom resources.
  • Valid KUBECONFIG_DATA base64-encoded secret stored within Kestra namespace secret configuration.
  • Configured Slack incoming webhook URL with permissions to post messages into the designated alert channel.

Secrets

  • KUBECONFIG_DATA: Vault secret required for authenticated API execution and notifications.
  • SLACK_WEBHOOK_URL: Vault secret required for authenticated API execution and notifications.

Quick start

  1. Register the required secrets in your Kestra namespace settings.
  2. Import this blueprint into your Kestra instance under the company.cloud namespace.
  3. Review input parameters such as threshold levels and target resource identifiers.
  4. Execute the flow manually to verify connectivity, then enable the automated schedule.

Common pitfalls and troubleshooting

  • RBAC API Group Permissions: Ensure the ServiceAccount possesses explicit permissions for acme.cert-manager.io/v1 challenges rather than standard core Kubernetes API groups.
  • Transient DNS Propagation Delays: Configure max_challenge_age_minutes to at least 20 minutes to accommodate authoritative DNS TTL propagation intervals before triggering alerts.
  • ClusterIssuer Namespace Scoping: Challenges generated by ClusterIssuers reside within the specific namespace of the originating Certificate resource rather than kube-system.
  • Base64 Kubeconfig Encoding Artifacts: Verify the base64-encoded kubeconfig secret contains no extraneous carriage returns or unescaped newline characters.

How to extend

  • Automated ACME Challenge Cleanup: Trigger automatic kubectl delete commands on orphaned challenges exceeding 24 hours to clear cert-manager queue blockage.
  • DNS Provider Health Validation: Forward DNS-01 failure messages directly to Route53 or Cloudflare health-check workflows to verify API key validity.
  • PagerDuty Escalation: Escalate to PagerDuty high-urgency incident pipelines if target certificates are within 72 hours of hard expiration.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.