Metadata-Version: 2.4
Name: kubernetes-log-analysis
Version: 0.1.0
Summary: A tool to analyze Kubernetes log bundles using LLMs.
Home-page: https://github.com/ap-mic-inc/kubernetes-log-analysis
Author: Simon Liu / APMIC
Author-email: simonliuyuwei@gmail.com
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: System :: Logging
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: litellm>=1.34.0
Requires-Dist: click>=8.0
Requires-Dist: python-dotenv>=1.0.0
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

## Kubernetes Log Analysis Tool (k-log)

[中文版說明文件](https://github.com/ap-mic-inc/kubernetes-log-analysis/blob/main/package/README_zh_tw.md)

A command-line tool that utilizes Large Language Models (LLMs) to analyze collected Kubernetes log content.

## Prerequisites

-   Python 3.8+
-   A directory of Kubernetes log content (generated by `k8s-debug.sh`, for details see https://github.com/ap-mic-inc/kubernetes-log-analysis).
-   Google Gemini API Key (or an API key for other models supported by LiteLLM).

## Python Package Installation

1.  Install the package and its dependencies using pip:
    ```bash
    pip install kubernetes-log-analysis==0.1.0
    ```

## Configuration

1.  **API Key**: This tool requires the `GOOGLE_API_KEY` for Gemini. Create a file named `.env` in the directory where you will run `k-log` (or the project root during development) with the following content:
    ```env
    GOOGLE_API_KEY="YOUR_GEMINI_API_KEY_HERE"
    ```
    Alternatively, ensure this environment variable is set globally.

2.  **LLM Model (Optional)**: You can specify a different LiteLLM compatible model string by setting the `LLM_MODEL` environment variable in your `.env` file or globally. The default is `gemini/gemini-2.5-flash-preview-04-17`.
    ```env
    LLM_MODEL="gemini/gemini-2.5-flash-preview-04-17"
    ```

## Usage

1.  Ensure your `GOOGLE_API_KEY` is set (e.g., via the `.env` file).
2.  Navigate to your Kubernetes log bundle directory (e.g., `cd /path/to/k8s-debug-default-20250509034522`).
3.  Run the `k-log` command with your query:

    ```bash
    k-log "What is the current status of the nodes?"
    ```
    Alternatively, explicitly specify the log directory:
    ```bash
    k-log --log-dir /path/to/your/k8s-debug-default-20250509034522 "logs for pod kuberay-operator-6ddb59999c-mggc9"
    ```

### Example Queries:

-   `k-log "status of nodes"`
-   `k-log "logs for pod jupyterlab-54698b59b8-bmvgq in namespace default"`
-   `k-log "describe service kubernetes"`
-   `k-log "any critical events?"`

## About the Author

### Simon Liu

APMIC MLOps Engineer x Google Developer Expert (GDE) in AI

A technology enthusiast in the field of artificial intelligence solutions, focusing on assisting enterprises in adopting generative AI, MLOps, and large language model (LLM) technologies to drive digital transformation and practical technological implementation.

Currently also a Google Developer Expert (GDE) in the GenAI field, actively participating in technology communities. Through technical articles, speeches, and practical experience sharing, he promotes the application and development of AI technology. To date, he has published over a hundred technical articles on Medium, covering topics such as generative AI, RAG, and AI Agents, and has served multiple times as a speaker at technical seminars, sharing practical applications of AI and generative AI.

### Related Links:

- APMIC Official Website: https://www.apmic.ai/
- Personal Social Media Links: https://simonliuyuwei.my.canva.site/link-in-bio
