Skip to content

Tarique-B-DevOps/Agentic-Kubernetes-CLI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Agentic Kubernetes CLI

Python Kubernetes AWS Bedrock License

An intelligent Agentic Kubernetes CLI assistant that integrates your local MCP server with AWS Bedrock, enabling natural language control over kubectl commands, cluster management, and real-time Kubernetes insights.


πŸš€ Features

πŸ—£οΈ Natural Language Kubernetes Operations

  • Conversational kubectl interface β€” execute commands in plain English
  • AI-powered command generation and validation
  • Context-aware management of clusters and namespaces
  • Real-time monitoring: pods, logs, resources, and events

βš™οΈ Advanced Capabilities

  • βœ… Resource Management β€” List, describe, and manage Kubernetes resources
  • πŸ“Š Troubleshooting Assistant β€” Analyze logs and diagnose issues
  • πŸ”„ Context Switching β€” Move between clusters easily
  • ⚑ Interactive CLI β€” Friendly prompt-driven interface

πŸŽ₯ Demo

Below is an example interaction between the User and the Agentic Kubernetes CLI demonstrating real-time troubleshooting and remediation.


πŸ§‘β€πŸ’» User: list all pods in the cluster
πŸ€– Agent: There are no running pods, but one pod nginx is showing an issue (ImagePullBackOff).

πŸ§‘β€πŸ’» User: analyze the issue with nginx pod
πŸ€– Agent: Issue identified β€” the container image tag nginx:lt is incorrect and not found in the registry.

πŸ§‘β€πŸ’» User: fix the image tag issue and make the pod running
πŸ€– Agent: Updated the image tag to nginx:latest, redeployed the pod, and verified that it is now Running successfully.


Demo.mp4

πŸ“š Table of Contents


πŸ”§ Prerequisites

Required Software

  • Python 3.12+
  • kubectl
  • Access to a running Kubernetes cluster
  • AWS account with Bedrock API access

AWS Bedrock Setup

  1. Enable Claude models in the AWS Bedrock console
  2. Configure AWS credentials with Bedrock access
  3. Ensure IAM permissions for bedrock:InvokeModel

πŸ“¦ Installation

Quick Setup

# Clone the repository
git clone https://github.com/Tarique-B-DevOps/Agentic-Kubernetes-CLI.git
cd Agentic-Kubernetes-CLI

# Install dependencies
pip install -r requirements.txt

# Verify kubectl installation
kubectl version --client

# Run the agent
python3 agent.py

βš™οΈ Configuration

Environment Variables

Set or export the following variables before running the agent:

# AWS Bedrock Configuration
export BEDROCK_MODEL_REGION=us-east-1
export BEDROCK_MODEL_ID=apac.anthropic.claude-3-5-sonnet-20241022-v2:0

# AWS Credentials (optional if configured with AWS CLI)
export AWS_ACCESS_KEY_ID=your_access_key
export AWS_SECRET_ACCESS_KEY=your_secret_key
export AWS_REGION=us-east-1

🎯 Usage

Start the Agent

python3 agent.py

Example Interactive Commands

⎈ kubectl> list all pods in production namespace
⎈ kubectl> what's wrong with my nginx deployment?
⎈ kubectl> show me the last 100 logs from api-server
⎈ kubectl> switch to staging cluster

πŸ’‘ Examples

List Pods

⎈ kubectl> show all pods in the cluster

AI Response:

βœ… Command executed successfully:
NAME                     READY   STATUS    RESTARTS   AGE
nginx-7854ff8877-2kxq9   1/1     Running   0          5d
api-server-abc123        1/1     Running   2          3d

Troubleshoot a Pod

⎈ kubectl> why is my app-server pod failing?

AI Response:

Analyzing pod app-server...
Issue: ImagePullBackOff
Root Cause: Container exits with code 1
Last Error: Connection refused to database:5432
Suggestion: Check database service and credentials

View Logs

⎈ kubectl> get the last 50 lines of logs from nginx pod and summarize

Manage Contexts

⎈ kubectl> list all available clusters
⎈ kubectl> switch to production-cluster
⎈ kubectl> what's my current context?

Scale Deployments

⎈ kubectl> scale nginx deployment to 5 replicas

Namespace Operations

⎈ kubectl> show all resources in kube-system namespace
⎈ kubectl> get all deployments across all namespaces

πŸ—οΈ Architecture

System Components

Architecture Diagram


🧩 MCP Tools

run_kubectl_command

{
  "command": "kubectl get pods -n default -o json",
  "return_code": 0,
  "stdout": "...",
  "success": true
}

kubectl_context

{
  "action": "list",
  "success": true,
  "output": "..."
}

About

Agentic AI system that transforms natural language into kubectl commands via Strands Agent and MCP server integration.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages