kubectl-claude

AI-powered kubectl plugin for multi-cluster Kubernetes management, with built-in diagnostic tools.

Overview

kubectl-claude provides two main interfaces:

  1. Claude Code Plugin - Use natural language to query and manage Kubernetes clusters directly in Claude Code
  2. CLI Tool - Traditional kubectl plugin with AI-powered natural language queries

Features

  • Multi-cluster management - Discover and manage clusters from your kubeconfig
  • Health monitoring - Check cluster and node health status
  • Workload inspection - View pods, deployments, services, and events
  • RBAC analysis - Analyze permissions for users, groups, and service accounts
  • Diagnostic tools - Find pod issues, deployment problems, security misconfigurations
  • OPA Gatekeeper integration - Manage and monitor policy violations

Quick Start

Installation

brew tap kubestellar/tap
brew install kubectl-claude

From Releases

Download from GitHub Releases.

From Source

git clone https://github.com/kubestellar/kubectl-claude.git
cd kubectl-claude
go build -o kubectl-claude ./cmd/kubectl-claude
sudo mv kubectl-claude /usr/local/bin/

Claude Code Plugin Setup

  1. Add the KubeStellar marketplace:
    /plugin marketplace add kubestellar/claude-plugins
  2. Go to /pluginDiscover tab
  3. Install kubectl-claude

Verify Installation

Run /mcp in Claude Code - you should see:

plugin:kubectl-claude:kubectl-claude · ✓ connected

Allow Tools Without Prompts

To avoid permission prompts for each tool call, add to ~/.claude/settings.json:

{
  "permissions": {
    "allow": [
      "mcp__plugin_kubectl-claude_kubectl-claude__*"
    ]
  }
}

Or run in Claude Code:

/allowed-tools add mcp__plugin_kubectl-claude_kubectl-claude__*

Usage in Claude Code installed, ask questions like:

  • “List my Kubernetes clusters”
  • “Find pods with issues in the production namespace”
  • “Check for security misconfigurations in my cluster”
  • “What permissions does the admin service account have?”
  • “Show me warning events in kube-system”
  • “Analyze the default namespace”

Available Tools

Cluster Management

ToolDescription
list_clustersDiscover clusters from kubeconfig
get_cluster_healthCheck cluster health status
get_nodesList cluster nodes with status
audit_kubeconfigAudit all clusters for connectivity and recommend cleanup

Workload Tools

ToolDescription
get_podsList pods with filtering options
get_deploymentsList deployments
get_servicesList services
get_eventsGet recent events
describe_podGet detailed pod information
get_pod_logsRetrieve pod logs

RBAC Analysis

ToolDescription
get_rolesList Roles in a namespace
get_cluster_rolesList ClusterRoles
get_role_bindingsList RoleBindings
get_cluster_role_bindingsList ClusterRoleBindings
can_iCheck if you can perform an action
analyze_subject_permissionsFull RBAC analysis for any subject
describe_roleDetailed view of Role/ClusterRole rules

Diagnostic Tools

ToolDescription
find_pod_issuesFind CrashLoopBackOff, ImagePullBackOff, OOMKilled, pending pods
find_deployment_issuesFind stuck rollouts, unavailable replicas, ReplicaSet errors
check_resource_limitsFind pods without CPU/memory limits
check_security_issuesFind privileged containers, root users, host network
analyze_namespaceComprehensive namespace analysis
get_warning_eventsGet Warning events
find_resource_ownersFind who owns/manages resources via managedFields, labels, annotations

OPA Gatekeeper Policy Tools

ToolDescription
check_gatekeeperCheck if OPA Gatekeeper is installed and healthy
get_ownership_policy_statusGet ownership policy configuration and violation count
list_ownership_violationsList resources missing required ownership labels
install_ownership_policyInstall ownership labels policy (dryrun/warn/enforce modes)
set_ownership_policy_modeChange policy enforcement mode
uninstall_ownership_policyRemove the ownership policy

CLI Usage

As kubectl plugin

# List all clusters
kubectl claude clusters list
 
# Check cluster health
kubectl claude clusters health
 
# Natural language queries (requires ANTHROPIC_API_KEY)
kubectl claude "show me failing pods"

As MCP Server

# Start MCP server (used by Claude Code)
kubectl-claude --mcp-server

Environment Variables

VariableDescription
KUBECONFIGPath to kubeconfig file
ANTHROPIC_API_KEYAPI key for Claude AI (for natural language queries)

Contributing

Contributions are welcome! Please read our contributing guidelines.

License

Apache License 2.0 - see LICENSE for details.