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 that during such further processing we do not use object names such as pods
(i.e. oc describe
without pods
) to avoid duplication.
Another example:
$ oc delete $(oc get dc,svc,route,is -o name)
service "nginx" deleted
route.route.openshift.io "nginx" deleted
imagestream.image.openshift.io "nginx" deleted
oc get pods -o name
? Runoc get --help
for help strings on all the options. – Irickoc get pod -o template --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}'
. See cookbook.openshift.org/working-with-resource-objects/… – Irick