kubectl
This directory provides Talon voice command integration for the Kubernetes command-line tool, kubectl. It allows users to manage Kubernetes clusters using intuitive, shorthand voice commands prefixed with the word "cube" (a homophone for kube).
The integration relies on two primary files that work together to expose and format kubectl commands in any terminal session where the user.kubectl tag is active.
How It Works
The functionality is split between a Python definition file and a Talon command file:
- kubectl.py: Registers the
user.kubectltag and declares lists for commonkubectlactions and objects. - kubectl.talon: Defines the voice commands, leveraging the lists declared in the Python file to provide flexible syntax.
Dynamic Actions and Objects
To avoid hardcoding every possible combination of kubectl commands, kubectl.py defines two key list types:
kubectl_action: Actions likeget,delete,describe, andlabel.kubectl_object: Kubernetes resource types likepods,nodes,jobs,namespaces,services,deployments, anddaemonsets.
These lists are combined in kubectl.talon to allow dynamic combinations using the syntax:
cube {user.kubectl_action} [{user.kubectl_object}]
For example, saying "cube get pods" or "cube delete services" dynamically constructs and types the correct command in your terminal.
Specialized Commands
Beyond standard commands, kubectl.talon includes several utility commands to speed up common shell operations inside containers:
cube shell: Typeskubectl exec -itand appends-- /bin/bashwith the cursor positioned in the middle, allowing you to easily target a pod and open an interactive bash session.cube detach: Sends the escape sequenceCtrl-pfollowed byCtrl-qto detach safely from an interactive container session without terminating it.