I am having a trouble to figure out how OpenShift can trigger deployment based on change in GitLab container registry. I have configured option in OpenShift called Deploy an existing Image from an Image Stream or Image registry.
This works and I can see my pod up and running. When I tried updating docker image and pushed to GitLab container registry, I did not see any new deployment in OpenShift. Please guide.
Thanks!!
OpenShift can automatically trigger redeployment on an image update, but only if the image changes in an ImageStreamTag
resource on the same cluster.
The image.openshift.io/triggers
annotation can be configured in the deployment to reference an ImageStreamTag
on the local cluster.
In the following example, the Deployment will be triggered by an update of the -n ci imagestreamtag mirror:latest
tag.
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
image.openshift.io/triggers: '[{"from":{"kind":"ImageStreamTag","name":"content-mirror:latest","namespace":"ci"},"fieldPath":"spec.template.spec.containers[?(@.name==\"mirror\")].image"}]'
name: base-4-10
namespace: app
spec:
...
To achieve the same thing, you can either:
Establish an ImageStream
resource in your cluster and push your image there
instead of the GitLab container registry. Configure your Deployment to be reactive to changes to the tag you push the image to.
ImageStreams can be configured to periodically import external images. The import happens every 15 minutes.
ImageStream
like app-images
.ImageStream
like: oc tag docker.io/app:latest app-images:app --scheduled
image.openshift.io/triggers
annotation to be reactive to the app-images:myapp
ImageStreamTag
.