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 -
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. Results are merged and displayed together.
Resource Specification
Resources can be specified 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) |
Examples
# Get pods from current namespace
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)'
|
The plugin merges results from both live cluster and KubeArchive, so you’ll see both current and archived resources in the output. Archived resources may have different timestamps and status information. |
|
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 most recent pod will be selected automatically. |
|
Container Selection: If no container is specified 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]
completion Command
Generate shell autocompletion scripts for bash, zsh, fish, or PowerShell. Autocompletion provides tab completion for commands and flags.
|
Resource names and types are not yet supported for autocompletion. |
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