LinuxCommandLibrary

kubectl-api-resources

List available Kubernetes API resources

TLDR

Print the supported API resources

$ kubectl api-resources
copy

Print the supported API resources with more information
$ kubectl api-resources [[-o|--output]] wide
copy

Print the supported API resources sorted by a column
$ kubectl api-resources --sort-by [name]
copy

Print the supported namespaced resources
$ kubectl api-resources --namespaced
copy

Print the supported non-namespaced resources
$ kubectl api-resources --namespaced=false
copy

Print the supported API resources with a specific API group
$ kubectl api-resources --api-group [api_group]
copy

SYNOPSIS

kubectl api-resources [--namespaced[=<true|false|all>]] [--verbs=<verbs>] [--api-group=<group>] [--sort-by=<field>] [-o <output_format>] [--no-headers]

PARAMETERS

--allow-missing-template-keys
    Ignore missing keys in templates during print operations.

-o, --output string
    Output format: json|yaml|wide|name|custom-columns=... (wide adds group/version/kind).

--namespaced[=<true|false|all>]
    Filter by namespace scope: true (namespaced), false (cluster), all (both).

--no-headers
    Omit headers in default or custom-column output.

--sort-by string
    Sort output list by specified field.

--verbs strings
    Comma-separated verbs to filter (default: create,list,watch).

--api-group string
    Limit to specific API group (* for all).

DESCRIPTION

The kubectl api-resources command displays a table of all supported API resources in the current Kubernetes cluster. It provides essential details such as resource names, short names, API groups, namespaced status, and kinds.

This tool is invaluable for discovering cluster capabilities, scripting automation, and understanding available Custom Resource Definitions (CRDs). By default, it outputs a formatted table with columns: NAME, SHORTNAMES, APIGROUP, NAMESPACED, and KIND.

Users can filter results by namespace scope, supported verbs (e.g., list, watch), or specific API groups. The -o wide option adds GROUP, VERSION, and KIND columns for more detail. It's particularly useful in dynamic environments with many CRDs, helping avoid trial-and-error when working with unfamiliar resources. Permissions are governed by RBAC; users see only accessible resources.

CAVEATS

Output reflects user RBAC permissions and cluster API server features; may exclude inaccessible or disabled resources.
Relies on API discovery endpoint.

EXAMPLES

kubectl api-resources # Default table
kubectl api-resources -o wide # Extra columns
kubectl api-resources --namespaced=true # Namespaced only
kubectl api-resources --api-group=apps # Specific group

COLUMNS

NAME: Resource name.
SHORTNAMES: Aliases.
APIGROUP: API group (empty for core).
NAMESPACED: true/false.
KIND: Resource kind.

HISTORY

Introduced in Kubernetes v1.14 (2018) to simplify resource discovery amid growing CRD ecosystem; evolved with kubectl core.

SEE ALSO

Copied to clipboard