Skip to content

kx yaml

Prints the raw YAML manifest for one or more indexed resources. --show fetches the same full manifest and narrows it client-side to the named top-level fields, so it works with anything kubectl’s own YAML output has.

kubectl’s own flags pass through. Naming an output format yourself replaces kx’s own -o yaml rather than arriving beside it, so kx yaml 1 -o json prints JSON. --show cannot be combined with one: it parses the YAML it narrows.

Several indexes are joined the way their format joins documents: YAML separated by ---, JSON merged into the one List kubectl answers several names with.

A flag kx doesn’t know is refused; put it after -- to pass it through to kubectl.

Usage

kx yaml [OPTIONS] <index>... [kubectl flags]

Arguments

ArgumentDescription
<index>...Row number from the current listing, or @name for a mark; kx state or kx mark shows them

Options

OptionDescription
--show stringComma-separated fields to display (e.g. metadata,spec)

Passthrough options

OptionDescription
-A, --all-namespacesIf present, list the requested object(s) across all namespaces. Namespace in current context is ignored even if specified with --namespace.
--allow-missing-template-keysIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
--chunk-size int64Return large lists in chunks rather than all at once. Pass 0 to disable.
--field-selector stringSelector (field query) to filter on, supports ‘=’, ‘==’, and ‘!=’.(e.g. --field-selector key1=value1,key2=value2). The server only supports a limited number of field queries per type.
-f, --filename stringsFilename, directory, or URL to files identifying the resource to get from a server.
--ignore-not-foundIf set to true, suppresses NotFound error for specific objects that do not exist. Using this flag with commands that query for collections of resources has no effect when no resources are found.
-k, --kustomize stringProcess the kustomization directory. This flag can’t be used together with -f or -R.
-L, --label-columns stringsAccepts a comma separated list of labels that are going to be presented as columns. Names are case-sensitive. You can also use multiple flag options like -L label1 -L label2…
--no-headersWhen using the default or custom-column output format, don’t print headers (default print headers).
-o, --output stringOutput format. One of: (json, yaml, kyaml, name, go-template, go-template-file, template, templatefile, jsonpath, jsonpath-as-json, jsonpath-file, custom-columns, custom-columns-file, wide). See custom columns [https://kubernetes.io/docs/reference/kubectl/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [https://kubernetes.io/docs/reference/kubectl/jsonpath/].
--output-watch-eventsOutput watch event objects when --watch or --watch-only is used. Existing objects are output as initial ADDED events.
--raw stringRaw URI to request from the server. Uses the transport specified by the kubeconfig file.
-R, --recursiveProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
-l, --selector stringSelector (label query) to filter on, supports ‘=’, ‘==’, ‘!=’, ‘in’, ’notin’.(e.g. -l key1=value1,key2=value2,key3 in (value3)). Matching objects must satisfy all of the specified label constraints.
--server-printIf true, have the server return the appropriate table output. Supports extension APIs and CRDs.
--show-kindIf present, list the resource type for the requested object(s).
--show-labelsWhen printing, show all labels as the last column (default hide labels column)
--show-managed-fieldsIf true, keep the managedFields when printing objects in JSON or YAML format.
--sort-by stringIf non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. ‘{.metadata.name}’). The field in the API resource specified by this JSONPath expression must be an integer or a string.
--subresource stringIf specified, gets the subresource of the requested object.
--template stringTemplate string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
-w, --watchAfter listing/getting the requested object, watch for changes.
--watch-onlyWatch for changes to the requested object(s), without listing/getting first.
…kubectl’s global flags too: --context, --kubeconfig, --as and the rest; kubectl options lists them

Global options

OptionDescription
--no-colorDisable styled output
-h, --helpShow this message and exit

Examples

kx yaml 1
kx yaml 1 2
kx yaml 1 --show metadata,spec
kx yaml 1..3
kx yaml 3..
kx yaml 1 --show-managed-fields