Parallel icon
Get icon
ChatCompletion icon
GoogleGemini icon
Script icon
SlackIncomingWebhook icon
Schedule icon

Kubernetes AI-powered incident monitoring, analysis, and alerting

Monitor a Kubernetes cluster with AI in Kestra. Collect pod, node, and deployment data, diagnose incidents with Gemini, classify severity, and alert Slack.

Categories
AIInfrastructure

Continuously monitor a Kubernetes cluster for health problems and incidents without writing custom controllers or stitching together cron jobs and shell scripts. Every five minutes this flow snapshots the live state of your cluster, hands the raw data to a large language model for site reliability analysis, classifies how serious the situation is, and pages your team on Slack only when something genuinely needs attention. It turns noisy kubectl output into a concise root cause summary with concrete remediation steps, so on-call engineers spend less time triaging and more time fixing.

How it works

  1. A io.kestra.plugin.core.flow.Parallel task fans out seven io.kestra.plugin.kubernetes.kubectl.Get calls at once to collect pods, events, nodes, deployments, services, resourcequotas, and selected kube-system pod logs, each written to its own output file.
  2. io.kestra.plugin.ai.completion.ChatCompletion sends the collected data to Google Gemini (gemini-2.5-flash) acting as an SRE, returning a health summary, root cause analysis, impact assessment, and remediation commands.
  3. A io.kestra.plugin.scripts.python.Script task (classify_severity) scans the AI response for keywords and labels the incident LOW, MEDIUM, or HIGH.
  4. io.kestra.plugin.slack.notifications.SlackIncomingWebhook fires only when runIf evaluates severity as HIGH, posting the full analysis to your channel.
  5. A io.kestra.plugin.core.trigger.Schedule trigger runs the whole pipeline on a */5 * * * * cron.

What you get

  • Parallel, low-latency collection of the cluster signals that matter most
  • Plain-language incident reports with named affected resources and kubectl fixes
  • Severity gating so Slack only lights up for real HIGH events
  • A hands-off monitor that runs on a schedule with no extra infrastructure

Who it's for

  • Platform and SRE teams running production Kubernetes
  • On-call engineers who want triage done before they open a terminal
  • DevOps teams adding AIOps to existing observability

Why orchestrate this with Kestra

Kubernetes ships a scheduler for pods, not for cross-resource diagnostic workflows. Kestra adds the missing layer: event and schedule triggers, automatic retries on transient API failures, full execution lineage and replay of every snapshot and AI verdict, and a declarative YAML definition you can version in Git. The parallel collection, conditional Slack alerting, and AI step live in one auditable flow instead of scattered scripts.

Prerequisites

  • A reachable Kubernetes API endpoint and a token with read access to the monitored resources
  • A Google Gemini API key
  • A Slack incoming webhook URL for production alerting

Secrets

  • K8S_MASTER_URL: Kubernetes API master URL
  • K8S_TOKEN: OAuth token for cluster access
  • GOOGLE_API_KEY: Google Gemini API key
  • SLACK_WEBHOOK_URL: Slack incoming webhook (swap in for the mock URL in production)

Quick start

  1. Add the four secrets above to your Kestra instance.
  2. Adjust the namespace in pluginDefaults and the resource selectors to match your cluster.
  3. Replace the mock Slack URL in send_slack_summary with {{ secret('SLACK_WEBHOOK_URL') }}.
  4. Run the flow once manually, then let the five-minute schedule take over.

How to extend

  • Point it at multiple clusters by parameterizing the connection details via inputs.
  • Swap Gemini for another provider supported by the AI plugin.
  • Add severity tiers or route MEDIUM incidents to a different channel or PagerDuty.
  • Persist each analysis to a database or object store for trend reporting.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.