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.

Syntax

kubectl ka get [RESOURCE[.VERSION[.GROUP]]] [flags]

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

--all-namespaces, -A

List resources across all namespaces

false

--namespace, -n

Kubernetes namespace to use for this request

(from kubeconfig)

--output, -o

Output format: json, yaml, or table

table

--selector, -l

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 (-l) cannot be used together with specifying a resource name. Use either a label selector to filter multiple resources (kubectl ka get pods -l app=nginx) OR specify a specific resource name (kubectl ka get pod nginx-pod), but not both.

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 -c and the pod has multiple containers, a random container may be selected. Always specify the container name for predictable results.

Init Container Support: The command supports retrieving logs from init containers by specifying their names with the -c flag.

Syntax

kubectl ka logs ([RESOURCE[.VERSION[.GROUP]]/NAME] | [RESOURCE[.VERSION[.GROUP]]] | [NAME]) [flags]

Resource Specification

If the resource is not provided, the CLI assumes it is a Pod.

Options

Flag Description Default

--container, -c

Container name to retrieve logs from

(first container)

--namespace, -n

Kubernetes namespace to use for this request

(from kubeconfig)

--selector, -l

Label selector to filter resources

(none)

Examples

# Get logs from a pod
kubectl ka logs nginx-pod -c sidecar-container

# Get logs from deployment (picks one pod)
kubectl ka logs deployment/nginx

# Get logs from all pods matching label
kubectl ka logs pods -l app=nginx

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.

Syntax

kubectl ka completion [bash|zsh|fish|powershell]

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

Fish

# Install completion for current session
kubectl ka completion fish | source

# Install completion permanently
kubectl ka completion fish > ~/.config/fish/completions/kubectl-ka.fish

PowerShell

# Install completion for current session
kubectl ka completion powershell | Out-String | Invoke-Expression

# Install completion permanently (add to PowerShell profile)
kubectl ka completion powershell >> $PROFILE