Skip to content

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.kubectl tag and declares lists for common kubectl actions 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 like get, delete, describe, and label.
  • kubectl_object: Kubernetes resource types like pods, nodes, jobs, namespaces, services, deployments, and daemonsets.

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: Types kubectl exec -it and appends -- /bin/bash with the cursor positioned in the middle, allowing you to easily target a pod and open an interactive bash session.
  • cube detach: Sends the escape sequence Ctrl-p followed by Ctrl-q to detach safely from an interactive container session without terminating it.