I want to get a list of just the pod names and the Result should not include the status, number of instances etc.
I am using the command
oc get pods
It prints
Pod1-qawer Running 1/1 2d
Pod2g-bvch Running 1/1 3h
Expected result
Pod1-qawer
Pod2g-bvch
How do i avoid the extra details from getting printed
Use the oc get <object> -o name
syntax, here (for pods):
oc get pods -o name
but it also applies to dc, svc, route, template, ..
Sample output: pod/m0001-v5-tst-1-b5xfs pod/m0001-v5-tst-1-mv5zl
note that these object prefixes (here: pod/
) are perfectly acceptable for all oc client tools commands, so no need to strip the prefixes, they can stay and be processed further, e.g. thus:
oc describe $(oc get pods -o name | grep m0001-v5) | grep TAG
CONTAINER_TAG: 20200430 CONTAINER_TAG: 20200430
Notice we do not use pods
as usual (i.e. oc describe
not oc describe pods
) to avoid duplication.
You can omit the headers with --no-headers
and you can use -o custom-columns=
to customize the output.
oc get pods -o custom-columns=POD:.metadata.name --no-headers
Example output
$ oc get pods -o custom-columns=POD:.metadata.name --no-headers
goapp-75d9b6bfbf-b5fdh
httpd-58c5c54fff-b97h8
app-proxy-6c8dfb4899-8vdkb
app-64d5985fdb-xjp58
httpd-dd5976fc-rsnhz
oc get po --no-headers | awk '{print $1}'