kubectl output format

The -o option and friends that change how kubectl prints objects: wide tables, full YAML or JSON, bare names, chosen columns or JSONPath.

In more detail

Scripts should ask for exactly the field they need, with -o jsonpath or custom-columns, rather than parsing the human table. --no-headers drops the header row and --show-labels adds a labels column. The full -o yaml view shows fields the cluster filled in that you never wrote.

Example

kubectl get events -o custom-columns=REASON:.reason,BY:.source.component --no-headers

Related terms

Taught in

References

Certification courses