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
kubectlcontext - 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
- Collects logs for the target pod using
kubectl. - Sends relevant log context to an OpenAI-compatible model (OpenAI SDK v1.x).
- Produces structured output with probable cause, confidence, and remediation steps.
Safety
- Runs locally on your machine.
- Uses your current
kubectlpermissions 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)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7be35e545766da8ad320f533dd9cf731fc9375b3a25fd3ae7083419dbbe5296
|
|
| MD5 |
f66dadb3f7ef033608cc3a64ac3b98d2
|
|
| BLAKE2b-256 |
8f3ba57d5057e0eda3b9407b7b1e2e4cd82e76134e17e988320f7a4112f954e6
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61c8a7b7a957ec938bdd189db3a077e5c660ed11e2c52237eb56fac89eef2194
|
|
| MD5 |
53ba97fdd7bf08e74c447cf24db9cade
|
|
| BLAKE2b-256 |
fe8a420b9df585a2610940c9be8473c43a53293b83d188e011e84872dbfde0c2
|