Spaces:
Build error
Build error
File size: 3,679 Bytes
f20ebef 74db197 93c73aa 74db197 93c73aa 74db197 f20ebef 74db197 93c73aa 74db197 e5b2667 74db197 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | ---
title: AgentCTL – Kubernetes Agent UI
emoji: 🧠
colorFrom: blue
colorTo: green
sdk: gradio
sdk_version: "4.42.0"
app_file: app.py
pinned: false
---
# AgentCTL — LLM-Driven Kubernetes Automation
### Natural Language → Kubernetes Jobs, Deployments & CronJobs
Built for real clusters via Minikube + kubectl proxy + ngrok or Cloudflare Tunnel.
---
## 🚀 Overview
**AgentCTL** is an agentic workflow system that converts **natural language instructions** into **Kubernetes manifests** (Jobs, Deployments, CronJobs) and applies them to a **real Kubernetes cluster**.
It works by exposing your cluster via:
- `kubectl proxy`
- a public tunnel (`ngrok` or `cloudflared`)
- a Gradio web UI
- a lightweight NL → YAML agent (heuristic + optional OpenAI LLM)
---
## ✨ Features
- Natural language → Kubernetes YAML
- Supports:
- Jobs
- Deployments
- CronJobs
- Optional OpenAI LLM YAML refinement
- Cluster dashboard (Jobs, Pods, Deployments, CronJobs)
- Pod logs viewer
- Pure HTTP client — no kubeconfig required
---
## 🧱 Architecture
```
Gradio UI → AgentCTL (NL→YAML) → K8sClient (HTTP) → Kubernetes API
```
---
## 📦 Installation
```bash
pip install -r requirements.txt
```
or
```bash
conda create -n agentctl python=3.10 -y
conda activate agentctl
pip install -r requirements.txt
```
---
## 🧪 Minikube Setup
```bash
minikube start --driver=docker
kubectl get pods -A
```
Expose API publicly:
```bash
kubectl proxy --port=8001 --address=0.0.0.0 --accept-hosts='.*' --accept-paths='.*'
```
Tunnel:
```bash
ngrok http 8001
```
---
## 🌐 Environment Variables
```bash
export K8S_API_BASE_URL="https://xxxx.ngrok-free.dev"
export K8S_NAMESPACE="default"
export K8S_VERIFY_SSL=false
```
Enable LLM YAML:
```bash
export AGENTCTL_USE_LLM=true
export OPENAI_API_KEY="sk-..."
export OPENAI_MODEL="gpt-4o-mini"
```
---
## ▶️ Run the App
```bash
python app.py
```
Open:
```
http://localhost:7860
```
---
## 📝 Usage Examples
### 🟦 Job
```
run a python job to preprocess data
```
### 🟧 Deployment
```
Prompt
create an nginx deployment with 3 replicas
Example
**Generated YAML:**
```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
namespace: default
labels:
app: agentctl-deployment
spec:
replicas: 3
selector:
matchLabels:
app: agentctl-deployment
template:
metadata:
labels:
app: agentctl-deployment
spec:
containers:
- name: main
image: nginx:1.27-alpine
ports:
- containerPort: 80
```
### 🟩 CronJob
```
Prompt
schedule a python cleanup script every 5 minutes
example
apiVersion: batch/v1
kind: CronJob
metadata:
name: agentctl-cronjob
namespace: default
spec:
schedule: "*/5 * * * *"
jobTemplate:
spec:
template:
metadata:
labels:
app: agentctl-cronjob
spec:
restartPolicy: Never
containers:
- name: main
image: python:3.11-slim
command:
- /bin/sh
- -c
- python cleanup.py
```
---
## 🚀 Deploy to Hugging Face Spaces
1. Create a Space (Gradio)
2. Upload project files
3. Set environment variables
4. Run the UI remotely controlling your real cluster
---
## 🔐 Security Notes
- ngrok + kubectl proxy is for demos only
- For real environments use:
- Cloudflare Tunnel
- RBAC service accounts
- Namespaced permissions
---
## ❤️ Credits
Built by **Murali Chandran (codeninja3d)**
AI Agents • Kubernetes • MLOps
---
## 📄 License
MIT License
|