Search code examples
openshiftquay.ioopenshift-4

OpenShift: How to update app based on ImageStream


I created a project on OpenShift 4.2 with an ImageStream that is pulling an Image from Quay.io:

oc new-project xxx-imagestream
oc import-image is:1.0 --from quay.io/xxx/myimage:latest --confirm --reference-policy local 

Now I create a new project to host an app based on that ImageStream

oc new-project xxx-app
oc new-app --name myapp -i xxx-imagestream/is:1.0

The app is built and I can use it by exposing it. (But no Build or BuildConfig is created. Why???)

Now I update the image on Quay.io with a new version, and import the new version into the xxx-imagestream project:

oc import-image is:2.0 --from quay.io/xxx/myimage:latest --confirm --reference-policy local

The question is: how do I update my app (myapp)? In other words, how can I launch a new build of "myapp" based on the updated ImageStream?


Solution

  • (But no Build or BuildConfig is created. Why???)

    A BuildConfig is only created when you use the "Source to Image" (S2I) functionality and is only needed when you want to create a container image from source. In your case, the image already exists, so there is no need to build anything. The only thing that oc new-app will do is deploy your existing image, there is no build necessary.

    The question is: how do I update my app (myapp)? In other words, how can I launch a new build of "myapp" based on the updated ImageStream?

    You are looking for "Deployment triggers", specifically the "ImageChange deployment trigger". The ImageChange trigger results in a new ReplicationController whenever the content of an imagestreamtag changes (when a new version of the image is pushed).

    On a side-note, you can also periodically automate the importing of new image versions in your ImageStreams (see documentation).