DEV Community

Cover image for ๐Ÿ› ๏ธ Manage & Troubleshoot EKS Cluster Like a Pro Using kubectl-AIโšก

๐Ÿ› ๏ธ Manage & Troubleshoot EKS Cluster Like a Pro Using kubectl-AIโšก

๐Ÿ‘‹ Hey there, tech enthusiasts!

I'm Sarvar, a Cloud Architect with a passion for transforming complex technological challenges into elegant solutions. With extensive experience spanning Cloud Operations (AWS & Azure), Data Operations, Analytics, DevOps, and Generative AI, I've had the privilege of architecting solutions for global enterprises that drive real business impact. Through this article series, I'm excited to share practical insights, best practices, and hands-on experiences from my journey in the tech world. Whether you're a seasoned professional or just starting out, I aim to break down complex concepts into digestible pieces that you can apply in your projects.

Let's dive in and explore the fascinating world of cloud technology together! ๐Ÿš€


Amazon EKS simplifies Kubernetes cluster management by abstracting the control plane and infrastructure setup. But when it comes to daily operations debugging, managing workloads, or understanding errors EKS users still face challenges using raw kubectl commands.

What if you could troubleshoot Kubernetes issues on Amazon EKS using plain English?

Meet kubectl-ai, an open-source command-line tool by Google Cloud that brings generative AI directly into your Kubernetes terminal. Itโ€™s not a replacement for kubectl, nor does it deploy workloads but it acts as a smart assistant to generate commands, explain errors, and guide you through troubleshooting all in natural language. Instead of searching forums or asking ChatGPT, just type your question or paste an error directly into kubectl-ai on your local machine. Within seconds, youโ€™ll receive step-by-step guidance simple, fast, and right where you need it.


What is kubectl-ai?

kubectl-ai is a CLI plugin that connects natural language prompts to powerful AI models (like Google Gemini or OpenAI GPT). It generates helpful suggestions, including:

  • Kubernetes kubectl commands
  • YAML templates
  • Explanations of cluster behavior or errors

Think of it as an AI-powered Kubernetes ChatGPT right in your terminal perfect for learning, troubleshooting, and reducing time spent Googling or Doing GPT.


Why EKS Users Should Use kubectl-ai

Managing EKS often means working with:

  • Complex namespace and workload structures
  • Unclear pod errors or network issues
  • Frequent debugging using logs or status messages

kubectl-ai simplifies this. Ask it your problem in plain English, and it returns kubectl commands or explanations. It uses your current kubeconfig, so if you're connected to an EKS cluster it works immediately.


Installing kubectl-ai

kubectl-ai can be installed on Linux, macOS, and Windows systems. Below are the installation steps for each platform.


Installation on Linux/macOS

Option 1: Install via Script

This script downloads and installs the latest release.

curl -sSL https://raw.githubusercontent.com/GoogleCloudPlatform/kubectl-ai/main/install.sh | bash
Enter fullscreen mode Exit fullscreen mode

Image description

Option 2: Manual Installation

  1. Download the appropriate binary from the GitHub Releases page.
  2. Extract the archive and move the binary to a directory in your system's PATH:
tar -zxvf kubectl-ai_Linux_x86_64.tar.gz
chmod +x kubectl-ai
sudo mv kubectl-ai /usr/local/bin/
Enter fullscreen mode Exit fullscreen mode

Installation on Windows (via PowerShell)

The following steps demonstrate how to install kubectl-ai on Windows using PowerShell. After installation, the tool can be accessed from Git Bash or any terminal.

Step 1: Download the ZIP File

Invoke-WebRequest -Uri "https://github.com/GoogleCloudPlatform/kubectl-ai/releases/latest/download/kubectl-ai_Windows_x86_64.zip" -OutFile "kubectl-ai_Windows_x86_64.zip"
Enter fullscreen mode Exit fullscreen mode

Download ZIP

Step 2: Extract the ZIP File

Expand-Archive -Path "kubectl-ai_Windows_x86_64.zip" -DestinationPath ".\kubectl-ai"
Enter fullscreen mode Exit fullscreen mode

This creates a folder named kubectl-ai in your current directory.

Extract ZIP

Step 3: Move the Binary to a Folder in PATH (Optional but Recommended)

Create a directory for CLI tools if it doesn't already exist:

New-Item -ItemType Directory -Force -Path "C:\kubectl-ai"
Enter fullscreen mode Exit fullscreen mode

Copy the binary to the directory:

Copy-Item -Path ".\kubectl-ai\kubectl-ai.exe" -Destination "C:\kubectl-ai"
Enter fullscreen mode Exit fullscreen mode

Move Executable

Step 4: Add the Directory to System PATH

To make kubectl-ai accessible from any terminal, add the folder to your system PATH:

[System.Environment]::SetEnvironmentVariable("Path", $Env:Path + ";C:\kubectl-ai", [System.EnvironmentVariableTarget]::Machine)
Enter fullscreen mode Exit fullscreen mode

Note: Restart your PowerShell or terminal session to apply the updated PATH.

Add to PATH

Step 5: Verify the Installation

Run the following command in PowerShell:

kubectl-ai --help
Enter fullscreen mode Exit fullscreen mode

PowerShell Verification

You can also verify it from Git Bash:

Git Bash Verification


Configure AI Model

Choose your preferred AI backend. In this guide, we are using Google Gemini, which is free to use and easy to integrate. The setup works seamlessly on both Linux and Windows environments. Follow the steps below to configure Gemini as your AI model with kubectl-ai.


How to Get Google Gemini API Key

To use Gemini with kubectl-ai, you'll first need to get your API key from Google:

Image description

  • Click on "Create API Key".

Image description

  • Copy the generated key securely โ€” youโ€™ll need it in the next step.

Image description


Configure Gemini with kubectl-ai

  • Once you have your Gemini API key, export it using:
export GEMINI_API_KEY=your_gemini_api_key
Enter fullscreen mode Exit fullscreen mode

Image description

  • To test with Gemini, run this interactive command and this opens an interactive shell where you can input prompts.
kubectl-ai --model gemini-2.5-flash-preview-04-17
Enter fullscreen mode Exit fullscreen mode

Image description

Note: If the Gemini model is not responding correctly, please visit the official GitHub repository. Errors often occur due to version mismatches, so verify the supported Gemini version there. Always use flash version its available for free.


Additional Models Supported

You can also configure other models like:

  • OpenAI (e.g., GPT-4)
  • Grok (xAI)
  • Local LLM (via Ollama)
  • Azure OpenAI (via AZURE_OPENAI_API_KEY)

Check the official kubectl-ai documentation for the latest supported providers and configuration options.


Common Use Cases for EKS with kubectl-ai

kubectl-ai simplifies Kubernetes management on Amazon EKS by enabling natural language interactions for tasks like debugging pods, explaining errors, and generating kubectl commands. So let's look at below use cases with output.

Debugging Pod Crashes

Prompt:

A pod in the "dev" namespace is stuck in CrashLoopBackOff. What do I check?
Enter fullscreen mode Exit fullscreen mode

AI Response:

Image description

Restarting a Deployment

Prompt:

How can I restart a deployment in EKS?
Enter fullscreen mode Exit fullscreen mode

AI Response:

Image description

Diagnosing Image Pull Issues

Prompt:

My pod is stuck in ImagePullBackOff. What can I do?
Enter fullscreen mode Exit fullscreen mode

AI Response:

Image description

Checking Resource Usage in EKS

Prompt:

Which pods in the "prod" namespace are using the most CPU and memory?
Enter fullscreen mode Exit fullscreen mode

AI Response:

Image description

Checking Service Connectivity

Prompt:

My frontend service is not reachable from the internet. How can I check?
Enter fullscreen mode Exit fullscreen mode

AI Response:

Image description


Limitations

  • kubectl-ai does not run or apply commands no the eks cluster for now you can run them manually.
  • It does not support deployment or automation on eks cluster.
  • It's not a replacement for eksctl, Helm, or CI/CD pipelines but a companion to help understand and debug faster.

Conclusion: kubectl-ai is like having a smart Kubernetes tutor at your fingertips. While it wonโ€™t directly deploy or manage workloads in your EKS cluster, it empowers you to troubleshoot smarter, faster, and more efficiently. If youโ€™re an EKS user overwhelmed by YAML, logs, or cryptic error messages, kubectl-ai is your new best friend.


๐Ÿ“Œ Wrapping Up
Thank you for investing your time in reading this article! I hope these insights have provided you with practical value and a clearer understanding of the topic. Your engagement and learning journey matter to me.

๐Ÿ’ก What's Next?
Stay tuned for more in-depth articles where we'll explore other exciting aspects of cloud operations, GenAI, DevOps, and data operations. Follow me for weekly content that aims to demystify complex tech concepts and provide actionable insights.

๐Ÿค Let's Connect!
I'd love to hear your thoughts and experiences! Drop your comments below or connect with me on LinkedIn. Your feedback helps me create more valuable content for our tech community.

Happy Learning! ๐Ÿš€

Top comments (0)