quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.83k stars 2.7k forks source link

OpenShift: improve triggering of Deployment from ImageStream #42747

Open grdryn opened 2 months ago

grdryn commented 2 months ago

Description

The main reason for opening this issue is that the deploying-to-openshift docs page says the following:

Since Deployment is a Kubernetes resource and not OpenShift specific, it can’t possibly leverage ImageStream resources, as is the case with DeploymentConfig.

I don't think this is entirely correct to say: it's possible to set the image.openshift.io/triggers annotation in a Deployment (also works with other resource types like CronJob/Job, StatefulSet, DaemonSet, Pod) such that it will be updated with the new image reference, when the ImageStreamTag is updated.

I think past releases of Quarkus defaulted to using DeploymentConfig, and the latest image in the ImageStreamTag was automatically deployed, no matter if the image was updated by something that the developer did outside Quarkus (such as manually triggering a BuildConfig that updated it), or by using one of the quarkus conveniences (such as the quarkus build -Dquarkus.openshift.deploy=true in the docs that seems like it waits for the build to finish, then modifies the Deployment with the new image reference). Now that Quarkus appears to default to Deployment, the Deployment doesn't appear to get updated with the new image reference if the ImageStreamTag is updated outside of Quarkus.

Now that DeploymentConfig is deprecated since OpenShift 4.14 and Deployment is the default in Quarkus, I think this would be a nice improvement

Implementation ideas

Per the OpenShift docs on triggering updates on ImageStream changes, an annotation can be added like this to appropriate Kubernetes resources:

    image.openshift.io/triggers:
      [
       {
         "from": {
           "kind": "ImageStreamTag", 
           "name": "example:latest", 
           "namespace": "myapp" 
         },
         "fieldPath": "spec.template.spec.containers[?(@.name==\"web\")].image", 
         "paused": false 
       },
      # ...
      ]
quarkus-bot[bot] commented 2 months ago

/cc @geoand (kubernetes,openshift), @iocanel (kubernetes,openshift)

iocanel commented 3 weeks ago

Thanks for pointing it out. If it's something that works with Deployment then it would be really nice to have.