kubectl-ai with Gemini AI Support (Linux/macOS/Windows) + Demo
What is kubectl-ai?
kubectl-ai
is a Kubernetes CLI plugin that uses AI models (like OpenAI's GPT or Google's Gemini) to generate, optimize, and debug Kubernetes manifests using natural language prompts.
Key Features
✅ AI-Powered Kubernetes Manifests — Describe what you need in plain English, and it generates YAML.
✅ Supports Multiple AI Models — Works with OpenAI (GPT-4, GPT-3.5) and Google Gemini.
✅ Helm Chart Generation — Creates Helm templates from simple descriptions.
✅ Error Debugging — Helps fix broken Kubernetes configurations.
✅ Cross-Platform — Works on Linux, macOS, and Windows.
Example Use Cases
- “Create a Deployment for PostgreSQL with 2 replicas” → Generates a full YAML.
- “Fix this broken Kubernetes ConfigMap” → AI suggests corrections.
- “Generate a Helm chart for a Node.js app” → Creates a Helm directory.
How It Works
- You type a natural language command (
kubectl ai "..."
). - The plugin sends the prompt to Gemini or OpenAI.
- The AI returns valid Kubernetes YAML, which you can apply directly.
Why Use kubectl-ai?
🚀 Faster than manual YAML writing
🛠️ Reduces syntax errors
🤖 Great for learning Kubernetes concepts
🔧 Helps automate DevOps workflows
This guide walks you through installing kubectl-ai
(an AI-powered Kubernetes assistant) and demonstrates its usage with Google's Gemini model to generate Kubernetes manifests.
Prerequisites
- kubectl installed (Installation Guide)
- Google Gemini API Key (Get it here)
- Terminal (Linux/macOS) or PowerShell (Windows)
1. Install kubectl-ai
Linux & macOS (Terminal)
# Install using Homebrew (recommended)
brew install kubectl-ai
# OR manual install
curl -LO https://github.com/sozercan/kubectl-ai/releases/latest/download/kubectl-ai-$(uname -s)-$(uname -m).tar.gz
tar -xvzf kubectl-ai-*.tar.gz
chmod +x kubectl-ai
sudo mv kubectl-ai /usr/local/bin/
Windows (PowerShell)
# Download and install
Invoke-WebRequest -Uri "https://github.com/sozercan/kubectl-ai/releases/latest/download/kubectl-ai-windows-amd64.exe" -OutFile "kubectl-ai.exe"
Move-Item -Path kubectl-ai.exe -Destination "$env:windir\System32\kubectl-ai.exe"
2. Set Up Gemini API Key
# Linux/macOS (add to ~/.bashrc or ~/.zshrc)
export GEMINI_API_KEY="your-api-key-here"
# Windows (Powershell)
$env:GEMINI_API_KEY = "your-api-key-here"
3. Demo: Generate a Kubernetes Deployment with Gemini
Let’s use kubectl-ai
with Gemini Pro to create an Nginx Deployment:
kubectl ai "Create a Kubernetes Deployment for Nginx with 3 replicas, 2 CPU cores, and 1GB memory limit"
Expected Output (nginx-deployment.yaml
)
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:latest
resources:
limits:
cpu: "2"
memory: "1Gi"
requests:
cpu: "1"
memory: "512Mi"
Apply to Kubernetes
kubectl apply -f nginx-deployment.yaml
Live Demo Screenshot attached for your references
4. Advanced Example: Helm Chart for Flask App
kubectl ai "Generate a Helm chart for a Python Flask app with Redis caching" --model=gemini-pro --output=flask-helm/
Conclusion
With kubectl-ai
and Gemini, you can:
✅ Generate Kubernetes manifests in seconds
✅ Automate Helm chart creation
✅ Reduce YAML errors with AI
About Me
As the world increasingly adopts cloud-based solutions, I bring over 16 years of industry expertise to help businesses transition seamlessly to the cloud. Currently serving as a Google Cloud Principal Architect, I specialize in building highly scalable, secure, and efficient solutions on the Google Cloud Platform (GCP). My areas of expertise include cloud infrastructure design, zero-trust security, Google Cloud networking, and infrastructure automation using Terraform.
I am proud to hold multiple cloud certifications that Google Cloud, HashiCorp Terraform, Microsoft Azure, and Amazon AWS, reflecting my commitment to continuous learning and multi-cloud proficiency.
Multi-Cloud Certified
- Google Cloud Certified — Cloud Digital Leader
- Google Cloud Certified — Associate Cloud Engineer
- Google Cloud Certified — Professional Cloud Architect
- Google Cloud Certified — Professional Data Engineer
- Google Cloud Certified — Professional Cloud Network Engineer
- Google Cloud Certified — Professional Cloud Developer Engineer
- Google Cloud Certified — Professional Cloud DevOps Engineer
- Google Cloud Certified — Professional Security Engineer
- Google Cloud Certified — Professional Database Engineer
- Google Cloud Certified — Professional Workspace Administrator
- Google Cloud Certified — Professional Machine Learning Engineer
- HashiCorp Certified — Terraform Associate
- Microsoft Azure AZ-900 Certified
- Amazon AWS Certified Practitioner
Empowering Others
Beyond my professional work, I am passionate about helping professionals and students build successful careers in the cloud. Through my content and mentorship, I aim to demystify complex cloud technologies, making them accessible and practical for all skill levels. My areas of guidance include Google Cloud, AWS, Microsoft Azure, and Terraform.
I regularly share insights, tutorials, and resources on various platforms. Whether you’re preparing for a certification exam, exploring cloud architecture, or tackling DevOps challenges, my goal is to provide clear, actionable content that supports your learning journey.
Connect With Me
Stay updated with the latest in cloud computing by following me on these platforms:
- YouTube: Grow with Google Cloud
- Topmate: Consult with Me
- Medium: My Blogs
- Telegram: Community Channel
- Twitter: Follow Me
- Instagram: Connect on Instagram
- LinkedIn: Professional Profile
- GitHub: My Projects
- Facebook: Follow on Facebook
- Linktree: All Resources
I’m here to help — together, we can achieve great heights in the cloud.
Let’s connect and grow! 😊