Boost Kubernetes Management with AI: Introducing the Lightweight k8m Console
This article introduces k8m, a lightweight AI‑enhanced console for Kubernetes that simplifies cluster management, installation, configuration, and daily operations, while offering features such as YAML auto‑translation, AI‑driven event and log diagnostics, command generation, multi‑cluster support, and role‑based access control.
1. Introduction
Kubernetes (K8s) has become ubiquitous, improving development and operations efficiency, yet its complexity poses challenges in networking, troubleshooting, and resource management. With rapid AI advances, intelligent tools can simplify many of these tasks.
2. What is k8m?
k8m is a lightweight console that combines AI and Kubernetes. Built on AMIS and using
komas the Kubernetes API client, it embeds the Qwen2.5‑Coder‑7B model and supports private large models such as DeepSeek.
3. Installation and Usage
3.1 ChatGPT Configuration
From version v0.0.8, ChatGPT is built‑in and requires no extra configuration. To use a custom model, set the following environment variables:
<code>export OPENAI_API_KEY="sk-XXXXX"
export OPENAI_API_URL="https://api.siliconflow.cn/v1"
export OPENAI_MODEL="Qwen/Qwen2.5-7B-Instruct"
</code>Run
./k8m -v 6for verbose debugging if needed.
3.2 Binary Deployment
Download the latest binary from the GitHub repository https://github.com/weibaohui/k8m/ and start the service:
<code>./k8m
Usage of ./k8m:
--admin-password string (default "123456")
--admin-username string (default "admin")
-k, --chatgpt-key string (default "sk-xxxxxxx")
-m, --chatgpt-model string (default "Qwen/Qwen2.5-7B-Instruct")
-u, --chatgpt-url string (default "https://api.siliconflow.cn/v1")
-d, --debug (default false)
--in-cluster (default true)
--jwt-token-secret string (default "your-secret-key")
-c, --kubeconfig string (default "/root/.kube/config")
--kubectl-shell-image string (default "bitnami/kubectl:latest")
--log-v int (default 2)
--login-type string (default "password")
--node-shell-image string (default "alpine:latest")
-p, --port int (default 3618)
--sqlite-path string (default "./data/k8m.db")
-v, --v Level (default 2)
</code>3.3 YAML Deployment in Kubernetes
Key environment variables and their defaults are listed in the table below:
Environment Variable
Default
Description
PORT
3618
Listening port
KUBECONFIG
~/.kube/config
Path to kubeconfig file
OPENAI_API_KEY
""
API key for the large model
OPENAI_API_URL
""
API URL for the large model
OPENAI_MODEL
Qwen/Qwen2.5-7B-Instruct
Default model name (change to deepseek‑ai/DeepSeek‑R1‑Distill‑Qwen‑7B for DeepSeek)
LOGIN_TYPE
"password"
Login method (password, oauth, token, etc.)
ADMIN_USERNAME
"admin"
Administrator username
ADMIN_PASSWORD
"123456"
Administrator password
DEBUG
"false"
Enable debug mode
LOG_V
"2"
klog verbosity level
JWT_TOKEN_SECRET
"your-secret-key"
Secret for JWT token generation
KUBECTL_SHELL_IMAGE
bitnami/kubectl:latest
Image for kubectl shell
NODE_SHELL_IMAGE
alpine:latest
Image for node shell
SQLITE_PATH
/data/k8m.db
SQLite database file path
IN_CLUSTER
"true"
Automatically register host cluster (default enabled)
These variables can be overridden by command‑line arguments.
4. Core Features
4.1 YAML Auto‑Translation
k8m provides integrated YAML browsing, editing, and documentation with automatic translation of YAML fields, eliminating the need to search for attribute meanings.
4.2 Event AI Diagnosis
On the Event page, an AI assistant analyzes abnormal events and provides detailed explanations with a single click.
4.3 Log AI Diagnosis
Select error logs in the Pod log view and click the AI diagnosis button to receive a diagnostic report that pinpoints key errors and suggests solutions.
4.4 AI‑Driven Inspection
The AI inspection feature leverages predefined rules from the k8s_gpt tool to automatically audit clusters, nodes, deployments, stateful sets, services, ingress, and other resources.
4.5 Command Generation
Describe the desired operation in natural language, and k8m generates the appropriate shell command, reducing lookup time.
4.6 Multi‑Cluster Management (MCP)
Version 0.0.66 adds support for managing multiple clusters from a single dashboard via kubeconfig files.
4.7 Role‑Based Access Control
k8m supports adding users and groups, assigning three role types: Cluster Administrator (full control), Cluster Read‑Only (view only), and Platform Administrator (manage platform settings).
5. Conclusion
k8m combines AI with Kubernetes to deliver a concise, efficient console that streamlines file management, log diagnostics, YAML translation, and fault isolation. Its intuitive UI and AI capabilities greatly improve Kubernetes usability for developers and operators, while supporting private model deployment for enhanced data security and autonomy.
Ops Development Stories
Maintained by a like‑minded team, covering both operations and development. Topics span Linux ops, DevOps toolchain, Kubernetes containerization, monitoring, log collection, network security, and Python or Go development. Team members: Qiao Ke, wanger, Dong Ge, Su Xin, Hua Zai, Zheng Ge, Teacher Xia.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.