Skip to content

Commit f4474ea

Browse files
authored
Merge pull request #20440 from jimangel/custom-columns
adding custom-columns examples
2 parents 50cb2a0 + 11ac6b9 commit f4474ea

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

content/en/docs/reference/kubectl/cheatsheet.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,21 @@ Output format | Description
351351
`-o=wide` | Output in the plain-text format with any additional information, and for pods, the node name is included
352352
`-o=yaml` | Output a YAML formatted API object
353353

354+
Examples using `-o=custom-columns`:
355+
356+
```bash
357+
# All images running in a cluster
358+
kubectl get pods -A -o=custom-columns='DATA:spec.containers[*].image'
359+
360+
# All images excluding "k8s.gcr.io/coredns:1.6.2"
361+
kubectl get pods -A -o=custom-columns='DATA:spec.containers[?(@.image!="k8s.gcr.io/coredns:1.6.2")].image'
362+
363+
# All fields under metadata regardless of name
364+
kubectl get pods -A -o=custom-columns='DATA:metadata.*'
365+
```
366+
367+
More examples in the kubectl [reference documentation](/docs/reference/kubectl/overview/#custom-columns).
368+
354369
### Kubectl output verbosity and debugging
355370

356371
Kubectl verbosity is controlled with the `-v` or `--v` flags followed by an integer representing the log level. General Kubernetes logging conventions and the associated log levels are described [here](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-instrumentation/logging.md).

0 commit comments

Comments
 (0)