CLI that explains Kubernetes pod failures from logs using AI. Works locally with kubectl.
Project description
k8s-ai
CLI that explains Kubernetes pod failures from logs using AI.
Features
- Collects logs from Kubernetes pods via
kubectl - AI-powered root-cause analysis (OpenAI-compatible API)
- Detects common failure classes:
- CrashLoopBackOff
- OOMKilled
- ImagePullBackOff
- DB connection timeout/errors
- Permission denied / RBAC-style issues
- HTTP 500 style failures
- Suggests remediation steps and safe
kubectlfollow-up commands - Supports multi-container pods and
--previouslogs - Offline
--mockmode (no kubectl calls required) - Sensitive data redaction before model input
Project Structure
k8s_ai/
├── .env.example
├── pyproject.toml
├── requirements.txt
├── README.md
└── k8s_ai/
├── __init__.py
├── __main__.py
├── cli.py
├── config.py
├── models.py
├── logging_setup.py
├── collector/
├── analyzer/
├── fixer/
└── utils/
Setup
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
Copy-Item .env.example .env
Update .env values:
LLM_API_KEYLLM_BASE_URLLLM_MODEL
Usage
Analyze pod:
python -m k8s_ai analyze <namespace> <pod>
Analyze specific container:
python -m k8s_ai analyze <namespace> <pod> --container <container-name>
Use previous container logs:
python -m k8s_ai analyze <namespace> <pod> --previous
Run fully offline:
python -m k8s_ai analyze default dummy-pod --mock
Notes
- In non-mock mode,
kubectland cluster access are required. - In mock mode, realistic sample logs are used and no kubectl command is executed.
License
MIT
Kubernetes Log Analyzer Agent
AI-powered CLI tool to collect Kubernetes pod logs and perform root-cause analysis with safe, structured remediation guidance.
Features
- Analyze logs for any namespace/pod
- Multi-container pod support
- Previous container logs (
--previous) - Timeout handling
- Intelligent log truncation
- Secret redaction before LLM call
- Optional suggested
kubectlfix commands - Offline mock mode for testing without API calls
- Rich terminal output
Project Structure
k8s_ai/
├── .env.example
├── requirements.txt
├── README.md
└── k8s_ai/
├── __init__.py
├── __main__.py
├── cli.py
├── config.py
├── models.py
├── logging_setup.py
├── collector/
│ ├── __init__.py
│ └── kubectl_collector.py
├── analyzer/
│ ├── __init__.py
│ └── llm_analyzer.py
├── fixer/
│ ├── __init__.py
│ └── command_generator.py
└── utils/
├── __init__.py
├── redaction.py
└── truncation.py
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
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.1.tar.gz.
File metadata
- Download URL: k8s_ai_cli-0.1.1.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c41deee745932a87dde9adc1acfbac95e71528c08fa1e6e46a908fa688aac66a
|
|
| MD5 |
e7503d8807239b6c6eac1ff8ccb5c056
|
|
| BLAKE2b-256 |
37a374df1021354263702ed16831fde3d6d8c5a6a8050af8f190620acabf61b3
|
File details
Details for the file k8s_ai_cli-0.1.1-py3-none-any.whl.
File metadata
- Download URL: k8s_ai_cli-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.5 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 |
c8e4aa8f2a88552beda29c10c9d251f2ffd91cf084725a6b36e0f9a21181cc88
|
|
| MD5 |
6e8402ec88822f952c07c39d85875805
|
|
| BLAKE2b-256 |
0bac435cddc8521713781230a51857598304c51ec377026796c02d9c6bb2756f
|