OpenShift: How to update app based on ImageStream

1.7k views Asked by At

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?

3

There are 3 answers

2
Simon On BEST ANSWER

(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).

0
Guildenstern70 On

The build starts automatically if your image stream has

--reference-policy source

In that case, it is correct to update the image stream using

oc -import-image [...]

To update a "local" ImageStream, instead of

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

you should update the existing local ImageStream tag

oc tag quay.io/xxx/myimage:latest is:2.0 --reference-policy local 

This command automatically triggers a new deployment of your app.

1
Dashrath Mundkar On

Add this to your deploymentConfig

triggers:
- type: ConfigChange
- imageChangeParams:
    automatic: true
    containerNames:
      - <your-container-name>
    from:
      kind: ImageStreamTag
      name: '<image_name>:latest'
      namespace: <your-namespace>
  type: ImageChange