CLI Usage
The kubectl-ka plugin provides commands to retrieve Kubernetes resources from both live cluster and KubeArchive,
as well as logs from archived resources.
The plugin is designed to mimic the
kubectl-get and
kubectl-logs commands,
providing a consistent interface for accessing both current and historical data.
Available Commands
The plugin supports the following commands:
-
get- Retrieve Kubernetes resources from both live cluster and KubeArchive -
logs- Retrieve container logs from archived resources -
config- Manage persistent configuration for different clusters -
completion- Generate shell autocompletion scripts (limited functionality)
|
All commands support the standard kubectl configuration flags plus KubeArchive-specific options. For detailed configuration information, see CLI Configuration. |
get Command
Retrieve Kubernetes resources from both the live cluster and KubeArchive. The command merges and displays results together.
Resource Specification
You can specify resources in multiple formats:
-
pods- Resource name only (discovers version and group automatically) -
jobs.batch- Resource with group (discovers preferred version) -
jobs.v1.batch- Fully qualified resource specification
The plugin supports resource names, short names, and singular forms.
For example, pods, pod, po resolve to the Pod resource.
Options
| Flag | Description | Default |
|---|---|---|
|
List resources across all namespaces |
|
|
Kubernetes namespace to use for this request |
(from kubeconfig) |
|
Output format: |
table |
|
Label selector to filter resources |
(none) |
|
Include resources from the live Kubernetes cluster |
|
|
Include resources from KubeArchive |
|
|
Providing |
Examples
# Get pods from current namespace (shows both live and archived)
kubectl ka get pods
# Get pods from all namespaces
kubectl ka get pods --all-namespaces
# Get a specific pod resource in YAML format
kubectl ka get po my-pod -n my-ns -o yaml
# Get deployments with multiple labels
kubectl ka get deployments -l 'tier=frontend,env in (staging,production)'
# Get only live cluster resources (no archive query)
kubectl ka get pods --in-cluster
# Get only archived resources (no cluster query)
kubectl ka get pods --archived
|
The plugin merges results from both live cluster and KubeArchive, showing availability indicators for each resource. The command deduplicates resources with the same UID from both sources and shows them once with both availability flags set. |
|
You cannot use label selectors ( |
|
Use label selectors effectively to filter large result sets. KubeArchive may contain extensive historical data, so targeted queries perform better than broad searches. |
logs Command
Retrieve container logs from archived resources only. Unlike the get command which merges live and archived data,
the logs command exclusively retrieves logs from the KubeArchive.
The command supports direct pod logs and logs from resources that own pods (like deployments, jobs).
|
Pod Selection: When multiple pods match the search criteria (e.g., from deployments or label selectors), the command automatically selects the most recent pod. |
|
Container Selection: If you do not specify a container with |
|
Init Container Support: The command supports retrieving logs from init containers
by specifying their names with the |
Syntax
kubectl ka logs ([RESOURCE[.VERSION[.GROUP]]/NAME] | [RESOURCE[.VERSION[.GROUP]]] | [NAME]) [flags]
config Command
Manage persistent configuration for different Kubernetes clusters. The plugin automatically stores cluster-specific KubeArchive settings, eliminating the need to specify connection details repeatedly.
|
For detailed configuration information, including environment variables, authentication methods, and certificate handling, see CLI Configuration. |
Quick Start
# First time usage triggers automatic setup
kubectl ka get pods
# List configured clusters
kubectl ka config list
# Manual setup for current cluster
kubectl ka config setup
Subcommands
remove
Remove configuration for a specific cluster or the current cluster (--current).
|
See CLI Configuration for detailed examples, configuration file format, and advanced configuration options. |
completion Command
Generate shell autocompletion scripts for bash, zsh, fish, or PowerShell. Autocompletion provides tab completion for commands and flags.
|
Autocompletion does not yet support resource names and types. |
Installation Examples
Bash
# Install completion for current session
source <(kubectl ka completion bash)
# Install completion permanently
kubectl ka completion bash > /etc/bash_completion.d/kubectl-ka
# Or for user-specific installation
kubectl ka completion bash > ~/.local/share/bash-completion/completions/kubectl-ka
Zsh
# Install completion for current session
source <(kubectl ka completion zsh)
# Install completion permanently
kubectl ka completion zsh > "${fpath[1]}/_kubectl-ka"
# Then reload your shell or run: autoload -U compinit; compinit