Skip to main content

CLI that explains Kubernetes pod failures from logs using AI. Works locally with kubectl.

Project description

k8s-ai

A Python CLI for Kubernetes pod failure triage using AI-powered log analysis.

Features

  • Reads pod logs directly through your local kubectl context
  • Uses OpenAI Python SDK v1.x for log analysis
  • Returns likely root cause, confidence level, and remediation guidance
  • Supports --mock, --previous, --container, and --timeout

Installation

pip install k8s-ai-cli

Quick Start

k8s-ai default my-pod
k8s-ai default my-pod --mock
k8s-ai default my-pod --previous
k8s-ai default my-pod --container app

Mock Example

k8s-ai default my-pod --mock

Real Cluster Example

# Current pod logs
k8s-ai default my-pod

# Previous logs (useful for CrashLoopBackOff)
k8s-ai default my-pod --previous

# Target a specific container
k8s-ai default my-pod --container app

Environment Variables

k8s-ai requires an OpenAI API key.

Linux/macOS:

export OPENAI_API_KEY="your_api_key_here"

Windows PowerShell:

$env:OPENAI_API_KEY="your_api_key_here"

How It Works

  1. Collects logs for the target pod using kubectl.
  2. Sends relevant log context to an OpenAI-compatible model (OpenAI SDK v1.x).
  3. Produces structured output with probable cause, confidence, and remediation steps.

Safety

  • Runs locally on your machine.
  • Uses your current kubectl permissions and context.
  • Does not persist collected pod logs by default.

Roadmap

  • Broader failure-pattern coverage for common Kubernetes workloads
  • Optional structured output modes for CI and automation
  • Additional debugging context integration (events/describe)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

k8s_ai_cli-0.1.5.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

k8s_ai_cli-0.1.5-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file k8s_ai_cli-0.1.5.tar.gz.

File metadata

  • Download URL: k8s_ai_cli-0.1.5.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for k8s_ai_cli-0.1.5.tar.gz
Algorithm Hash digest
SHA256 e7be35e545766da8ad320f533dd9cf731fc9375b3a25fd3ae7083419dbbe5296
MD5 f66dadb3f7ef033608cc3a64ac3b98d2
BLAKE2b-256 8f3ba57d5057e0eda3b9407b7b1e2e4cd82e76134e17e988320f7a4112f954e6

See more details on using hashes here.

File details

Details for the file k8s_ai_cli-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: k8s_ai_cli-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for k8s_ai_cli-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 61c8a7b7a957ec938bdd189db3a077e5c660ed11e2c52237eb56fac89eef2194
MD5 53ba97fdd7bf08e74c447cf24db9cade
BLAKE2b-256 fe8a420b9df585a2610940c9be8473c43a53293b83d188e011e84872dbfde0c2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page