AI-Powered Kubernetes MCP Server
Integrates with the Gemini API to provide AI-driven interpretation of natural language commands for Kubernetes operations.
Enables natural-language management of Kubernetes clusters, allowing operations such as listing pods, scaling deployments, restarting deployments, and retrieving logs.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@AI-Powered Kubernetes MCP ServerScale my-website-app to 5 replicas"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
π§ AI-Powered Kubernetes MCP Server (Minikube + Gemini + kubectl-ai)
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.
π Full Guide Available
π Check out the full Medium article walkthrough here:
π Read on Medium
Related MCP server: K8s MCP
π§± Architecture Overview
EC2 Ubuntu Instance (T2.Medium, 30 GiB EBS)
Minikube (Docker driver)
kubectl-ai β Googleβs CLI for AI-driven Kubernetes commands
Gemini API (1.5 Flash) β Natural language LLM
FastAPI MCP Server β Hosts custom
mcp-schema.jsonfor command interpretationNodePort Service β Exposes MCP server endpoint
Demo App β
my-website-appdeployed for live testing
π¦ Prerequisites
Tool | Required |
Ubuntu 22.04 EC2 | β |
Docker (non-root) | β |
Minikube | β |
Go 1.22+ | β |
kubectl | β |
Gemini API Key | β |
βοΈ Setup Steps
π 1. Create Security Group
Allow SSH (22)
Allow NodePort range:
30000β32767(TCP)Allow HTTP (80)
βοΈ 2. Launch EC2 Instance
AMI: Ubuntu 22.04+
Type:
t2.mediumor higherDisk:
30 GiBUser-data:
#!/bin/bash
set -e
Update system and install essentials
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
---- Python ----
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
---- Docker ----
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π¦ 4. Install Requirements
# kubectl
# GoFollow official Minikube install guide:
π https://minikube.sigs.k8s.io/docs/start/
π 5. Clone Repos
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/βΈοΈ 6. Start Minikube
minikube start --driver=dockerπ 7. Deploy MCP + App
kubectl apply -f rbac.yaml
kubectl apply -f my-website-app.yaml
kubectl apply -f mcp-deployment.yaml
kubectl apply -f mcp-service.yamlπ 8. Test MCP Server
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.
π 9. Configure kubectl-ai
mkdir -p ~/.kube/kubectl-ai
nano ~/.kube/kubectl-ai/config.yamlPaste:
mcp:
endpoint: http://192.168.49.2:31390/mcp-schema.json
name: mcp-server
llm:
provider: gemini
model: gemini-1.5-flashπ 10. Create Gemini Secret
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π§ 11. Use kubectl ai
kubectl ai --model gemini-1.5-flash㪠Demo Prompts
You can now ask kubectl ai things like:
Prompt | Action |
List all pods in the default namespace |
|
Restart the my-website-app deployment |
|
Scale the my-website-app to 5 replicas |
|
Delete pod |
|
Get logs from pod in default namespace |
|
List all nodes |
|
Get cluster namespaces |
|
Get events in default namespace |
|
π§Ή Cleanup
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π Acknowledgements
π Next Steps
Add HTTPS ingress controller with TLS
Package MCP as a Helm chart
Add multi-model support for OpenAI or Anthropic
This server cannot be deployed
Maintenance
Related MCP Connectors
Deploy, monitor, and manage your OpenClaw AI assistants via natural language.
Fail-closed policy guardrails for AI agents running kubectl, terraform, helm, and argocd.
Your AI Agent's Infrastructure Layer. Connect Claude, Copilot, Codex, or ChatGPT to 200+ managed open source services. Start databases, pipelines, and applications through natural language.
Manage Rackspace Spot Kubernetes Cloudspaces, node pools, and VMs from your AI assistant.
Related MCP Servers
- FlicenseBqualityDmaintenanceEnables managing Kubernetes clusters through natural language by providing tools to list resources, view logs, port-forward services, scale deployments, and execute kubectl operations via AI assistants.81-
- FlicenseNot gradedqualityCmaintenanceEnables interaction with Kubernetes clusters through 32 specialized tools for managing resources, deployments, and services. Provides both CLI and web interfaces for real-time Kubernetes operations powered by Google Gemini.5-
- FlicenseNot gradedqualityBmaintenanceExposes Kubernetes cluster management tools to LLMs, enabling querying pods, deployments, logs, metrics, and managing port forwards via natural language.1-
- AlicenseNot gradedqualityFmaintenanceEnables AI-powered management of multi-cluster Kubernetes environments through natural language, supporting kubectl operations, function execution, and agent interactions with multiple AI providers.7Apache 2.0