loading…
Search for a command to run...
loading…
Enables natural-language management of Kubernetes clusters via kubectl-ai and Gemini, providing commands like listing pods, scaling deployments, and retrieving
Enables natural-language management of Kubernetes clusters via kubectl-ai and Gemini, providing commands like listing pods, scaling deployments, and retrieving logs through a FastAPI backend.
This project deploys an AI-connected Kubernetes MCP (Model-Controller-Prompt) server on an EC2 instance using Minikube, Google Gemini, and kubectl-ai. The MCP server allows natural-language interaction with Kubernetes — powered by a custom schema and FastAPI backend.
📝 Check out the full Medium article walkthrough here:
👉 Read on Medium
mcp-schema.json for command interpretationmy-website-app deployed for live testing| Tool | Required |
|---|---|
| Ubuntu 22.04 EC2 | ✅ |
| Docker (non-root) | ✅ |
| Minikube | ✅ |
| Go 1.22+ | ✅ |
| kubectl | ✅ |
| Gemini API Key | ✅ |
30000–32767 (TCP)t2.medium or higher30 GiB#!/bin/bash
set -e
apt-get update -y && apt-get upgrade -y apt-get install -y curl wget git ca-certificates gnupg lsb-release apt-transport-https software-properties-common
apt-get install -y python3 python3-pip update-alternatives --install /usr/bin/python python /usr/bin/python3 1 update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
apt-get install -y docker.io systemctl enable docker systemctl start dockeru
---
### 🧑💻 3. Initial Setup After SSH
```bash
sudo usermod -aG docker ubuntu
sudo reboot
# kubectl
# Go
Follow official Minikube install guide:
👉 https://minikube.sigs.k8s.io/docs/start/
git clone https://github.com/your-username/k8s-mcp-server-prod.git
cd k8s-mcp-server-prod
git clone https://github.com/GoogleCloudPlatform/kubectl-ai.git
cd kubectl-ai
go build -o kubectl-ai ./cmd/kubectl-ai
sudo mv kubectl-ai /usr/local/bin/
minikube start --driver=docker
kubectl apply -f rbac.yaml
kubectl apply -f my-website-app.yaml
kubectl apply -f mcp-deployment.yaml
kubectl apply -f mcp-service.yaml
minikube ip # e.g. 192.168.49.2
kubectl get svc mcp-service # Note NodePort, e.g. 31390
curl http://192.168.49.2:31390/mcp-schema.json
✅ Should return your schema in JSON.
kubectl-aimkdir -p ~/.kube/kubectl-ai
nano ~/.kube/kubectl-ai/config.yaml
Paste:
mcp:
endpoint: http://192.168.49.2:31390/mcp-schema.json
name: mcp-server
llm:
provider: gemini
model: gemini-1.5-flash
kubectl create secret generic gemini-api-key --from-literal=GEMINI_API_KEY=your-key
export GEMINI_API_KEY=your-key
echo 'export GEMINI_API_KEY=your-key' >> ~/.bashrc
source ~/.bashrc
kubectl aikubectl ai --model gemini-1.5-flash
You can now ask kubectl ai things like:
| Prompt | Action |
|---|---|
| List all pods in the default namespace | list_pods |
| Restart the my-website-app deployment | restart_deployment |
| Scale the my-website-app to 5 replicas | scale_deployment |
Delete pod my-website-app-xyz |
delete_pod |
| Get logs from pod in default namespace | get_pod_logs |
| List all nodes | get_nodes |
| Get cluster namespaces | get_namespaces |
| Get events in default namespace | get_events |
kubectl delete -f mcp-service.yaml
kubectl delete -f mcp-deployment.yaml
kubectl delete -f my-website-app.yaml
kubectl delete -f rbac.yaml
kubectl delete secret gemini-api-key
Выполни в терминале:
claude mcp add ai-powered-kubernetes-mcp-server -- npx Безопасность
Низкий рискАвтоматическая эвристика по публичным данным — не гарантия безопасности.