Schedule icon
Script icon
AIAgent icon
GoogleGemini icon
Create icon
If icon
SlackIncomingWebhook icon
Log icon

Kubernetes OOMKilled and CrashLoopBackOff AI Root Cause Sentinel

Automate Kubernetes pod incident response with Kestra. Detect CrashLoopBackOff and OOMKilled events, diagnose root causes with Gemini AI, and alert Slack.

Categories
CloudInfrastructure

Silent pod crashes and out-of-memory (OOMKilled) restarts in production Kubernetes clusters lead to degraded service availability and recurring outages. This blueprint provides an automated SRE incident sentinel that inspects pod termination logs, leverages Google Gemini to diagnose root-cause memory starvation or crash loops, logs an actionable incident report to GitHub, and alerts on-call teams via Slack.

How it works

  1. A Schedule trigger (io.kestra.plugin.core.trigger.Schedule) runs periodically (every 15 minutes) to audit cluster namespace reliability.
  2. The inspect_pod_failure_events task (io.kestra.plugin.scripts.python.Script) inspects pod status and container termination reasons, pulling failure logs and exit codes.
  3. The ai_root_cause_analysis task (io.kestra.plugin.ai.agent.AIAgent) analyzes the crash logs using Google Gemini 2.0 Flash to diagnose the underlying memory or configuration issue and writes a Kubernetes patch snippet.
  4. The create_github_incident_issue task (io.kestra.plugin.github.issues.Create) logs an incident issue in the SRE tracking repository.
  5. The check_incident_severity task (io.kestra.plugin.core.flow.If) evaluates failure criticality (OOMKilled or CrashLoopBackOff): if true, it sends an urgent Slack alert linking directly to the created GitHub issue.

What you get

  • Automated pod crash diagnosis without manual kubectl describe or kubectl logs triage.
  • AI-generated root-cause explanation and container resource sizing recommendations.
  • Centralized incident documentation logged automatically into GitHub Issues.
  • Immediate Slack alerts linking directly to remediation guidance.

Who it's for

  • Site Reliability Engineers (SREs) and DevOps engineers managing production Kubernetes clusters.
  • Platform teams building automated self-healing and incident intake pipelines.
  • Backend developers needing fast explanations for container crashes.

Why orchestrate this with Kestra

Connecting Kubernetes telemetry, generative AI reasoning, incident issue tracking, and chat notifications requires coordinating multiple secure services. Kestra unifies these tools into a single declarative workflow with reliable secret management, comprehensive execution logs, and automated retry policies.

Prerequisites

  • A running Kestra instance with Kubernetes, AI, GitHub, Slack, and Python plugins.
  • Access to a Kubernetes cluster or configured service account.
  • A Google Gemini API key.
  • A GitHub Personal Access Token with repo issues scope.
  • A Slack incoming webhook URL for SRE alerts.

Secrets

  • GEMINI_API_KEY: API key for Google Gemini AI model provider.
  • GITHUB_TOKEN: GitHub OAuth or Personal Access Token for incident issues.
  • SLACK_WEBHOOK: Incoming Webhook URL for SRE on-call notifications.

Quick start

  1. Configure the three secrets in your Kestra namespace or instance settings.
  2. Import this flow into your target namespace (e.g., company.sre).
  3. Set namespace and pod_name to monitor your cluster workloads.
  4. Execute the flow manually to verify crash detection, AI diagnostic generation, and Slack alerting.
  5. Enable the schedule trigger for continuous 24/7 reliability monitoring.

How to extend

  • Connect a Kubernetes Patch task to automatically increment memory limits in staging clusters.
  • Chain PagerDuty or Opsgenie notifications for production severity-1 incidents.
  • Extend the Python script to watch cluster-wide events dynamically using Kubernetes Client watchers.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.