7

I would like to know the tag applied to all the images in a namespace. Is there any oc command to view tags in a namespace?

Before posting this question, i googled. However i didn't find any. So I am posting this question here.

Graham Dumpleton
  • 57,726
  • 6
  • 119
  • 134
srk
  • 3,606
  • 2
  • 18
  • 23
  • You can view details of all image streams in a project by running ``oc describe is``. This will list tags for each image stream along with lots of other information. Add an extra argument of a specific image stream to be selective. – Graham Dumpleton Apr 04 '18 at 11:00
  • @Graham Dumpleton, Thank you for prompt response. let me put my requirement, "retrieve all images with "release" tag <\b> in a namespace." I see oc get is -n providing information. But i was wondering is there any easy way to get like application name and all the tag names of that application. For Example: apache application has 8 tags. Then expected response would be apache 1.2, 1.4, 1.8, 2.0 release, baseline, build , prod. – srk Apr 04 '18 at 13:37
  • 6
    Try playing with this ``oc get is python -n openshift --template='{{.metadata.name}}{{range .spec.tags}}{{" "}}{{.name}}{{end}}{{"\n"}}'``. This will output ``python 2.7 3.3 3.4 3.5 3.6 latest``. – Graham Dumpleton Apr 05 '18 at 00:31
  • @GrahamDumpleton super helpful! thank you! question - if I wanted to add the image created date / age at the end do you know the construct? I tried `{{.created}}` with no luck :( – skålfyfan Oct 16 '18 at 20:58
  • 1
    You may want to look at ``imagestreamtag`` objects instead if need more detail that not in the ``imagestream`` object. Use ``oc get imagestreamtag imagename:tagname -o json`` and see if details are in there. – Graham Dumpleton Oct 17 '18 at 16:50

1 Answers1

3

You may get details from imagestreamtag object. If you need formatted tags only as a list you can execute this command.

oc get imagestreams imagename -o jsonpath='{range .status.tags[*]}{.tag}{"\n"}'

This will return something like this as result as formatted:

20.10.321
20.13.328
20.14.333
20.14.338
20.16.342
Bibek Shrestha
  • 470
  • 5
  • 13
  • This is pretty nice for displaying the tags for a specific `imagename`, but is there a way to do this for all the images in the namespace? That is, all the images in a project? I tried the command omitting the `imagename`, but there was no output. I know there are tags for the images in my project (at least `latest`) because I see them if I use the command `oc get imagestreams`. – Mr. Lance E Sloan Oct 19 '22 at 12:49