Schedule icon
Script icon
If icon
Create icon
SlackIncomingWebhook icon
Log icon

Kubernetes Ingress Unhealthy Backend and Blackhole Sentinel

Monitor Kubernetes Ingress backends and prevent HTTP 502 routing blackholes with Kestra. Query endpoints, log GitHub issues, and alert SRE on Slack.

Categories
CloudInfrastructure

Kubernetes Ingress controllers route external HTTP/HTTPS traffic to internal microservices based on declarative hostname and path rules. However, when backing deployment pods fail readiness probes, crash repeatedly, or experience deployment rollout deadlocks, the backing Kubernetes Service has zero active endpoints, causing the Ingress controller to return immediate HTTP 502 or 503 errors to clients. This blueprint audits Kubernetes Ingress rules and verifies that backing Service endpoints have healthy, ready pods, logs an automated GitHub incident ticket, and alerts on-call SREs via Slack.

How it works

  1. check_ingress_readiness_periodic (io.kestra.plugin.core.trigger.Schedule) initiates the audit every 10 minutes (shipped disabled for safe verification).
  2. probe_ingress_backends (io.kestra.plugin.scripts.python.Script) uses the official Kubernetes Python SDK to read Ingress routing rules and inspect corresponding Endpoints or EndpointSlices in the cluster.
  3. branch_on_unhealthy_backends (io.kestra.plugin.core.flow.If) evaluates whether any Ingress paths point to services with zero ready pod addresses (has_unhealthy == true):
    • then: Automatically files a GitHub tracking issue via create_ingress_incident_issue (io.kestra.plugin.github.issues.Create) and alerts the Slack channel via alert_sre_slack (io.kestra.plugin.slack.notifications.SlackIncomingWebhook).
    • else: Emits an informational log entry (log_ingress_healthy) confirming full backend readiness.
  4. log_audit_summary (io.kestra.plugin.core.log.Log) records the final health summary.
  5. The errors block alerts Slack if Kubernetes API credentials or network connectivity fails.

What you get

  • Automated, scheduled auditing of Kubernetes ingress routing paths.
  • Immediate detection of silent traffic blackholes and broken upstream services.
  • Consolidated GitHub incident tickets with specific Ingress paths and service names.
  • Real-time Slack notifications with direct ticket hyperlinks.

Who it's for

  • Platform Engineers and Kubernetes SREs managing cluster ingress controllers (Nginx, Traefik, AWS ALB).
  • DevOps engineers deploying microservices to production namespaces.
  • Cloud Infrastructure leads ensuring high service availability.

Why orchestrate this with Kestra

Kestra coordinates Kubernetes API interaction, multi-layer endpoint health validation, conditional incident escalation, and team alerting in a single declarative workflow. It manages cluster credentials securely, provides complete execution history, and eliminates the need for separate standalone monitoring daemons.

Prerequisites

  • A Kubernetes cluster with an active Ingress controller.
  • A ServiceAccount, kubeconfig, or IAM role with read permissions on ingresses and endpoints.
  • A GitHub Personal Access Token with repository issue creation permissions.
  • A Slack incoming webhook URL for notifications.

Secrets

  • KUBECONFIG (or in-cluster ServiceAccount): Authentication credentials for Kubernetes API.
  • GITHUB_TOKEN: GitHub token used to open incident issues.
  • SLACK_WEBHOOK: Incoming Webhook URL for alerting.

Inputs

  • namespace (STRING, default production): Kubernetes namespace hosting the Ingress and services.
  • ingress_name (STRING, default primary-app-ingress): Name of the Ingress resource to audit.
  • github_repository (STRING, default my-org/kubernetes-cluster-operations): Target GitHub repository for logging incident issues.

Outputs

  • outputs.probe_ingress_backends.vars.total_backends: Total number of Ingress routing paths inspected.
  • outputs.probe_ingress_backends.vars.unhealthy_count: Number of paths pointing to services without ready pods.
  • outputs.probe_ingress_backends.vars.unhealthy_backends: List of unhealthy backend objects (path, service, ready_endpoints).

Quick start

  1. Configure GITHUB_TOKEN and SLACK_WEBHOOK in your Kestra namespace.
  2. Import this flow and set namespace and ingress_name to match an existing Ingress resource.
  3. Run the flow manually to verify Ingress inspection and Slack notification delivery.
  4. Enable the check_ingress_readiness_periodic trigger for continuous routing health monitoring.

How to extend

  • Add an automated rollout restart task (kubectl rollout restart deployment/<svc>) to attempt automatic recovery.
  • Integrate with Prometheus metrics to cross-reference HTTP 502/503 error rates.
  • Loop over multiple Ingress resources across all production namespaces using io.kestra.plugin.core.flow.ForEach.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.