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

Kubernetes Ingress TLS Certificate Expiry Guard

Probes Kubernetes Ingress domain endpoints over TLS, measuring certificate validity and alerting SRE teams on Slack before expiration.

Categories
CloudInfrastructure

In cloud-native Kubernetes environments, Ingress controllers (such as Ingress-NGINX, Traefik, or AWS Load Balancer Controller) terminate incoming SSL/TLS connections for customer-facing services. While automated tools like cert-manager and Let's Encrypt handle automated certificate renewals, ACME HTTP-01 challenge failures, rate limits, or expired DNS API credentials frequently stall renewal pipelines.

When an ingress certificate expires, web browsers immediately block user traffic with severe security warnings (ERR_CERT_DATE_INVALID), causing catastrophic availability outages for production web applications and REST APIs.

This blueprint provides an independent external observability guard that establishes live TLS socket handshakes with your public Ingress hostnames daily. It verifies peer x509 certificates, calculates remaining days until expiration, and alerts Site Reliability Engineering teams via Slack whenever a certificate enters its critical renewal window (default: 21 days).

How it works

  1. Scheduled Daily Audit: The daily_cert_audit trigger (io.kestra.plugin.core.trigger.Schedule) executes every morning at 08:00 UTC.
  2. Python TLS Handshake Probe: The probe_tls_certificates task (io.kestra.plugin.scripts.python.Script) establishes socket connections to each configured host over port 443, extracts notAfter metadata, and generates cert_audit_report.json.
  3. Condition Branching: The evaluate_cert_expiry flowable task (io.kestra.plugin.core.flow.If) branches based on whether any certificates breached the expiration threshold.
  4. Slack Alert Dispatch: When expiring certificates are found, notify_slack_sre_team (io.kestra.plugin.slack.notifications.SlackIncomingWebhook) delivers an actionable triage card detailing the host, days remaining, and cert-manager remediation advice.
  5. Compliant Logging: When all endpoints possess healthy validity margins, log_valid_certs_status records nominal status in execution logs.
  6. Audit Manifest: The export_cert_manifest task records execution state for compliance tracking.

Architecture diagram

flowchart TD
    A[Schedule: Daily 08:00 UTC] --> B[probe_tls_certificates: Python TLS Handshake]
    B --> C{Certificates Expiring?}
    C -- Yes --> D[send_slack_expiry_alert: Slack Webhook]
    C -- No --> E[log_valid_certs_status: Log]
    D --> F[export_cert_manifest: Return JSON]
    E --> F

Use cases

  • External Blackbox Ingress Monitoring: Verify public-facing SSL/TLS certificates directly over HTTPS independently of internal cluster health.
  • Proactive cert-manager Outage Detection: Catch failed ACME challenges, Let's Encrypt rate limits, or DNS provider token expirations 21 days before outage.
  • Compliance and Audit Readiness: Generate automated daily manifests proving active certificates across all customer-facing endpoints.

What you get

  • Blackbox external verification of SSL/TLS certificate health independent of Kubernetes cluster state.
  • Early warning weeks before browser certificate expiration errors occur.
  • Automated detection of expired Let's Encrypt renewal tokens or failing ACME issuers.
  • Formatted Slack alert cards with domain names and renewal instructions.

Who it is for

  • Site Reliability Engineers (SREs) maintaining Kubernetes ingress controllers and external domains.
  • DevOps and Security Engineers auditing enterprise public cryptographic certificates.
  • Infrastructure Leads managing high-availability web applications.

Why orchestrate this with Kestra

Setting up standalone cert-monitoring agents or Prometheus blackbox exporters requires configuring scrape jobs, Alertmanager routes, and dashboard panels. Kestra provides a lightweight, declarative workflow that runs the probe, scores expiration dates, and notifies Slack directly without external monitoring overhead.

Inputs

Name Type Default Description
days_before_expiry_warning INT 21 Days before expiration to raise an operational alert.
ingress_hosts_list STRING api.company.com,app.company.com Comma-separated list of hostnames to probe.
slack_channel STRING #sre-alerts Slack channel destination for alerts.

Expected outputs

  • {{ outputs.probe_tls_certificates.vars.has_expiring }}: Boolean flag indicating if expiring certs were found.
  • {{ outputs.probe_tls_certificates.vars.expiring_count }}: Number of endpoints breaching threshold.
  • {{ outputs.probe_tls_certificates.vars.top_host }}: Hostname with the earliest expiration date.
  • {{ outputs.probe_tls_certificates.outputFiles['cert_audit_report.json'] }}: Complete JSON diagnostic report.

Prerequisites

  • Outbound internet access from Kestra workers to connect to target domains over port 443.
  • Slack Incoming Webhook configured for your SRE alerting channel.

Secrets

  • SLACK_WEBHOOK_URL: Slack Incoming Webhook endpoint URL.

Quick start

  1. Configure SLACK_WEBHOOK_URL in your Kestra namespace secrets.
  2. Import this flow YAML into your Kestra instance.
  3. Set your production domain names in ingress_hosts_list.
  4. Click Execute in the UI to run an initial verification probe across your endpoints.

Common pitfalls and troubleshooting

  • SNI Matching: The Python probe sets server_hostname during socket wrapping; ensure hostnames match the Server Name Indication (SNI) configured on the ingress controller.
  • Cloudflare / CDN Edge Certificates: Probing domains fronted by Cloudflare or CloudFront checks the edge CDN certificate rather than the origin Kubernetes certificate; ensure origin domains are also probed.
  • Port Accessibility: Verify that corporate egress firewalls allow outbound TCP port 443 traffic from Kestra task execution containers.

How to extend

  • Add io.kestra.plugin.kubernetes.pods.Logs to inspect cert-manager pod logs when certificates fail to renew automatically.
  • Dynamically discover Ingress hostnames from the Kubernetes cluster API rather than providing a static list.
  • Integrate with PagerDuty for critical severity alerts when certificates have fewer than 7 days remaining.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.