Kubernetes AutoHotkey Tool
English | 中文
A powerful AutoHotkey script that provides quick shortcuts and GUI interface for common Kubernetes operations.
Features
Text Shortcuts
Quick text expansion shortcuts for common kubectl commands:
@ksetns- Set namespace@kgetns- Get current namespace@kpod- Get pods@kdep- Get deployments@kns- Get all namespaces@klog- View pod logs (uses clipboard content as pod name)@krestart- Restart deployment@ksetimg- Set deployment image
GUI Command Selector
Press Ctrl+Shift+K to open the Kubernetes Commander GUI with:
- Namespace management (set, view, edit current namespace)
- Dropdown menu with all available commands
- Visual interface for easier command selection
- Context-aware command execution
Installation
- Install AutoHotkey v2.0 or later
- Download the
kubectl_tool.ahkscript - Double-click the script file to run it
- The script will run in the background and provide shortcuts
Usage
Using Text Shortcuts
- Type any shortcut (e.g.,
@kpod) in any text field - The shortcut will automatically expand to the corresponding kubectl command
- For commands requiring pod/deployment names, copy the name to clipboard first
Using GUI Interface
- Press
Ctrl+Shift+Kto open Kubernetes Commander - Set your preferred namespace (optional)
- Select a command from the dropdown menu
- Click "execute" to run the command
Namespace Management
The tool maintains a global namespace context:
- Commands automatically include
-n <namespace>when a namespace is set - You can change namespace anytime through the GUI or
@ksetnsshortcut - View current namespace with
@kgetnsor through the GUI
Command Examples
| Shortcut | Generated Command | Description |
|---|---|---|
@kpod |
kubectl get pods |
List all pods |
@kpod (with namespace) |
kubectl get pods -n <namespace> |
List pods in namespace |
@klog |
kubectl logs -f --tail 200 <clipboard> |
Follow logs of pod from clipboard |
@krestart |
kubectl rollout restart deployment |
Restart deployment (cursor positioned for name input) |
Requirements
- AutoHotkey v2.0 or later
- kubectl installed and configured
- Windows operating system
Configuration
The script stores the current namespace in a global variable that persists during the session. No additional configuration files are needed.
Contributing
Feel free to submit issues and enhancement requests!
License
This project is open source and available under standard terms.