kopilot

command module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 31, 2026 License: MIT Imports: 7 Imported by: 0

README ΒΆ

Kopilot - Kubernetes Cluster Status Agent

CI codecov Security CodeQL Release Go Version Go Report Card Author Made in Sweden

A professional interactive agent built with the official GitHub Copilot SDK in Go that provides real-time status information about Kubernetes clusters from your kubeconfig file.

πŸ€– AI-Generated Project Notice
This entire project was created during a vibe coding session using GitHub Copilot (Claude Sonnet 4.5 model) with the sole purpose of having fun and exploring what's possible with AI-assisted development. While it works, it started as an experiment in AI-powered software creation.

Contributions welcome! If you'd like to help turn this fun experiment into a serious, production-ready tool, pull requests are greatly appreciated.

Features

  • πŸ” List All Clusters: View all Kubernetes clusters configured in your kubeconfig
  • πŸ“Š Detailed Status: Get comprehensive status information for specific clusters
  • βš–οΈ Compare Clusters: Side-by-side comparison of multiple clusters
  • πŸ₯ Health Monitoring: Real-time node and pod health tracking across all clusters
  • ⚑ Parallel Execution: Check all clusters simultaneously for 5-10x faster results
  • πŸ€– Interactive Agent: Natural language interface powered by GitHub Copilot
  • πŸ› οΈ kubectl Integration: Execute kubectl commands through natural language
  • οΏ½ Safe by Default: Read-only mode protects against accidental changes
  • πŸ”“ Interactive Mode: Confirmation prompts for write operations with clear visibility
  • οΏ½πŸš€ Proactive Monitoring: Automatic cluster health check on startup with pod status
  • πŸ“‹ Pretty Output: Markdown tables and structured formatting for easy reading
  • πŸ’Ž Quota Tracking: Real-time Copilot Premium request quota display with color indicators
  • 🎯 Type-Safe Tools: Uses Copilot SDK's DefineTool for automatic schema generation
  • πŸ’° Smart Cost Optimization: Intelligent model selection based on task complexity (see docs/MODEL_SELECTION.md)
    • Uses gpt-4o-mini for simple queries (list, status, health checks)
    • Automatically upgrades to gpt-4o for troubleshooting and complex operations
    • 50-70% cost reduction while maintaining quality for critical tasks

Architecture

The agent uses the official GitHub Copilot SDK to create an interactive assistant that can query your Kubernetes clusters. The SDK handles model invocation, tool selection, and response generation, while our custom tools provide the actual cluster information.

Supported Platforms

Kopilot is compiled and released for:

OS Architecture Tested in CI Binary Available
Linux amd64 βœ… βœ…
Linux arm64 ❌ βœ…
macOS amd64 (Intel) ❌ βœ…
macOS arm64 (Apple Silicon) βœ… βœ…
Windows amd64 ❌ βœ…
Windows arm64 ❌ βœ…

Note: All platforms are verified to compile successfully in CI. Full test suite runs on Ubuntu (linux/amd64) and macOS (darwin/arm64).

Quick Start

# Install dependencies
make deps

# Build the binary
make build

# Run kopilot
./bin/kopilot

# Or install and run from anywhere
make install
kopilot

Prerequisites

  • Go 1.23 or later - For building from source
  • kubectl - Kubernetes command-line tool
  • GitHub Copilot CLI - Version 0.0.350 or later (tested with 0.0.394)
  • GitHub Copilot subscription - Required for AI features
  • Access to Kubernetes clusters via kubeconfig
  • Valid kubeconfig file at ~/.kube/config or set via KUBECONFIG
Dependencies

This project uses the following key dependencies:

  • GitHub Copilot SDK: github.com/github/copilot-sdk/go@v0.1.18 (minimum required)
  • Kubernetes Client: k8s.io/client-go@v0.31.4
  • Kubernetes API: k8s.io/api@v0.31.4

Run go mod verify to ensure dependency integrity.

Compatibility Matrix
Component Minimum Version Tested Version Notes
Go 1.23.0 1.23.3 Required for building
Copilot CLI 0.0.350 0.0.394 Auto-detected from PATH or VS Code
Copilot SDK v0.1.18 v0.1.18 Critical - earlier versions have deadlock issues
kubectl Any Latest Must be in PATH
Kubernetes 1.28+ 1.31.4 API compatibility

Installation

1. Install Copilot CLI

Choose one of the following methods:

Option A: Using npm (recommended)

npm install -g @githubnext/github-copilot-cli

# Verify installation
copilot --version

# Authenticate
copilot auth login

Option B: Using Homebrew

brew install github/gh-copilot/gh-copilot

Option C: Using GitHub CLI extension

gh extension install github/gh-copilot

Option D: VS Code Extension

# Install GitHub Copilot extension in VS Code
# The CLI will be automatically bundled

For more details, see: https://docs.github.com/en/copilot/github-copilot-in-the-cli

2. Install Kopilot

Option A: Using Homebrew (recommended)

brew tap e9169/tap
brew install kopilot

Option B: Download from releases

# Download the latest binary for your platform from:
# https://github.com/e9169/kopilot/releases

# macOS example:
curl -L https://github.com/e9169/kopilot/releases/latest/download/kopilot_$(uname -s)_$(uname -m).tar.gz | tar xz
sudo mv kopilot /usr/local/bin/

Option C: Build from source

cd kopilot
make deps
make build
3. Verify Installation
kopilot --version

Usage

# Run in read-only mode (default - safest)
./bin/kopilot

# Run in interactive mode (asks before write operations)
./bin/kopilot --interactive

# Show version information
./bin/kopilot --version

# Run with verbose logging
./bin/kopilot -v

# Show help
./bin/kopilot --help

# Use custom kubeconfig
KUBECONFIG=/path/to/kubeconfig ./bin/kopilot

# Use custom kubeconfig and context
./bin/kopilot --kubeconfig /path/to/kubeconfig --context my-context

# JSON output for tool responses
./bin/kopilot --output json
Execution Modes

πŸ”’ Read-Only Mode (Default)

  • Blocks all write operations (scale, delete, apply, etc.)
  • Safe for production environments and exploratory use
  • Perfect for monitoring, troubleshooting, and viewing cluster state
  • Use --interactive flag to enable writes with confirmation

πŸ”“ Interactive Mode

  • Asks for confirmation before executing write operations
  • Shows exactly what command will run
  • Allows cancellation of dangerous operations
  • Can be enabled at startup with --interactive flag

Runtime Mode Switching

  • /readonly - Switch to read-only mode
  • /interactive - Switch to interactive mode
  • /mode - Show current execution mode
Command-Line Flags
  • --version - Display version information
  • --interactive - Enable interactive mode (asks before write operations)
  • --kubeconfig - Path to kubeconfig file (default: $KUBECONFIG or ~/.kube/config)
  • --context - Override kubeconfig context
  • --output - Output format: text or json
  • -v, --verbose - Enable verbose logging with timestamps
  • --help - Show usage information
Environment Variables

Optional:

  • KUBECONFIG - Path to kubeconfig file (default: ~/.kube/config)

Optional - Model Configuration:

  • KOPILOT_MODEL_COST_EFFECTIVE - Override AI model for simple queries (default: gpt-4o-mini)
  • KOPILOT_MODEL_PREMIUM - Override AI model for complex operations (default: gpt-4o)

Example:

# Use different AI models
export KOPILOT_MODEL_COST_EFFECTIVE="gpt-3.5-turbo"
export KOPILOT_MODEL_PREMIUM="gpt-4"
./bin/kopilot

# Use custom kubeconfig
export KUBECONFIG="/path/to/custom/kubeconfig"
./bin/kopilot --interactive
Interactive Session

When you start kopilot, it automatically:

  1. Checks the health of ALL your clusters
  2. Reports any issues or confirms everything is healthy
  3. Asks "What would you like me to do?"

Then you can interact naturally:

> Show me pods in the default namespace on dev-mgmt-01
> Scale the nginx deployment to 3 replicas in prod-wrk-01
> Check the logs of the api pod in namespace apps
> What's the status of nodes in the SEML region clusters?
> exit

The agent will execute kubectl commands on your behalf and explain the results.

Available Tools

  1. list_clusters - Lists all clusters from kubeconfig
  2. get_cluster_status - Gets detailed status for a specific cluster
  3. compare_clusters - Compares multiple clusters side by side
  4. check_all_clusters - Fast parallel health check of all clusters (πŸš€ 5-10x faster)
  5. kubectl_exec - Execute kubectl commands against any cluster

References

Author

Eneko P (@e9169)
πŸ“ Based in Sweden

License

MIT License - Copyright Β© 2026 e9169

Documentation ΒΆ

The Go Gopher

There is no documentation for this package.

Directories ΒΆ

Path Synopsis
pkg
agent
Package agent provides the core Copilot agent functionality for Kubernetes cluster operations.
Package agent provides the core Copilot agent functionality for Kubernetes cluster operations.
k8s
Package k8s provides Kubernetes cluster interaction capabilities.
Package k8s provides Kubernetes cluster interaction capabilities.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL