ktalk is a kubectl plugin that converts natural language descriptions into kubectl commands using Anthropic's Claude (Opus 4.7). It makes interacting with your Kubernetes cluster more intuitive by allowing you to describe what you want to do in plain English.
- Natural language to kubectl command conversion
- Interactive command execution with confirmation
- Powered by Anthropic's Claude Opus 4.7 model
- Safe command execution with user confirmation
- Support for complex kubectl queries
- Robust error handling and validation
- Command format validation
- HTTP status code checking
- Detailed error messages
- Go 1.26.0 or later
- kubectl installed and configured
- Anthropic API key
- Access to a Kubernetes cluster
- Clone the repository:
git clone https://github.com/yourusername/ktalk.git
cd ktalk- Build the plugin:
go build -o kubectl-ktalk- Install the plugin:
# For macOS/Linux
cp kubectl-ktalk /usr/local/bin/- Set up your Anthropic API key:
export ANTHROPIC_API_KEY='your-api-key-here'Basic syntax:
kubectl ktalk <your natural language query>- List containers in a namespace:
kubectl ktalk show me all containers in the kube-system namespace- Check pod status:
kubectl ktalk what's the status of pods in default namespace- Complex queries:
kubectl ktalk find all pods that are running as root user across all namespaces- You provide a natural language description of what you want to do with your Kubernetes cluster
- ktalk uses Anthropic's Claude Opus 4.7 to convert your description into the appropriate kubectl command
- The generated command is validated to ensure it:
- Starts with "kubectl"
- Is properly formatted
- Is safe to execute
- The command is shown to you for confirmation
- Upon confirmation (pressing Enter), the command is executed
- All generated commands are shown to you before execution
- You must explicitly confirm by pressing Enter to execute any command
- Commands are validated to ensure they start with "kubectl"
- The plugin uses Claude Opus 4.7's understanding of Kubernetes to generate safe and appropriate commands
- HTTP status codes are checked for API responses
- Response format is thoroughly validated
- Empty or malformed responses are caught and reported
The plugin includes comprehensive error handling for:
- Missing or invalid Anthropic API key
- API request failures
- Invalid API responses
- Malformed commands
- Command execution errors
- User input errors
- Uses Anthropic's Claude Opus 4.7 model for state-of-the-art reasoning
- Implements robust JSON response parsing
- Includes thorough type checking and validation
- Provides detailed error messages for debugging
- Uses Go's standard library for command execution
- Implements proper signal handling for command interruption
Contributions are welcome! Please feel free to submit a Pull Request. When contributing:
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request
To set up the development environment:
- Install Go 1.26.0 or later
- Clone the repository
- Install dependencies:
go mod download- Run tests:
go test ./...- Build the plugin:
go build -o kubectl-ktalkThis project is licensed under the MIT License - see the LICENSE file for details.
- Anthropic for providing the Claude API
- The Kubernetes community for kubectl and its plugin architecture
- The Go community for excellent tools and libraries
If you encounter any issues or have questions:
- Check the error messages for detailed information
- Review the documentation
- Open an issue in the GitHub repository