LinuxCommandLibrary

kubectl-get

lists Kubernetes resources

TLDR

List pods

$ kubectl get pods
copy
List all resources
$ kubectl get all
copy
Output as YAML
$ kubectl get pod [pod-name] -o yaml
copy
Output as JSON
$ kubectl get pods -o json
copy
Watch changes
$ kubectl get pods --watch
copy
List across namespaces
$ kubectl get pods -A
copy
Custom columns
$ kubectl get pods -o custom-columns=NAME:.metadata.name,STATUS:.status.phase
copy

SYNOPSIS

kubectl get [options] resource [name]

DESCRIPTION

kubectl get retrieves and displays one or more Kubernetes resources from the cluster. It is the most frequently used kubectl subcommand for inspecting cluster state, supporting every resource type including pods, deployments, services, nodes, configmaps, and custom resources defined by CRDs.
The command provides flexible output formatting through the `-o` flag, including human-readable tables, YAML, JSON, JSONPath expressions, and custom column definitions. Results can be filtered by label selectors, field selectors, and namespaces, or retrieved across all namespaces with the `-A` flag. The `--watch` flag enables real-time streaming of resource changes via the Kubernetes watch API.
By default, the output shows a summary table with key fields like name, status, and age. The `wide` output format adds additional columns such as node assignments and IP addresses, while structured formats like YAML and JSON return the complete resource specification for scripting and automation.

PARAMETERS

RESOURCE

Resource type (pods, deployments, services, etc.).
NAME
Resource name (optional).
-o FORMAT
Output format (yaml, json, wide, custom-columns).
--watch
Watch for changes.
-A, --all-namespaces
All namespaces.
-l SELECTOR
Label selector.
-n NAMESPACE
Target namespace.
--help
Display help information.

CAVEATS

Subcommand of kubectl. Wide output for more columns. Watch doesn't catch all changes.

HISTORY

kubectl get is the primary resource listing command for Kubernetes cluster inspection.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community