Can I have an OpenShift build trigger a sync of an ImageStream from an external Docker Repository?

10/9/2019

I have an OpenShift BuildConfig that creates a Docker image stored in a remote repository. The DeploymentConfig uses an OpenShift ImageStream to trigger a deployment when a new image is available. I've managed to push to the remote repo and sync the ImageStream from the remote repo. However, when I run a fresh build, the ImageStream does not automatically sync up with the remote repo. New deployments use the old image until that occurs. I have found that I can not have multiple spec.output.to fields in the BuildConfig or I'd just push it to both locations. I have set the importPolicy.scheduled: true field, but by default this only imports every 15 minutes and at that point the deployment trigger fires and the new version is deployed. I'd like to not wait for that time. I'd prefer not to make a global config change for this. I'd be willing to push to the local docker repo and push that to the external if there is a way to accomplish this.

How can I be sure at build time that the ImageStream is sync'd so a deployment is triggered?

-- Josiah
continuous-delivery
docker
kubernetes
openshift

2 Answers

10/18/2019

I've managed to push to the remote repo and sync the ImageStream from the remote repo

In order to give a good answer some more information on how you did this will help greatly.

One way to solve your problem is to tag your docker registry with several tags and listen to one of these tags as a scheduled imageStreamTag in your ImageStream. That will make it (eventually) get deployed. You can do this in your CI pipeline.

If you want to deploy it right away after you have created a build you need to do something like

oc tag my.regisstry/group/name:<myBuildTag> isName:isTagName 
-- bjartek
Source: StackOverflow

10/9/2019

How about try to adjust Image Policy Configuration in /etc/origin/master/master-config.yaml ? This post is also helpful for your case, refer Automatically Update Red Hat Container Images on OpenShift 3.11 for more details.

Or when you images are pushed by CI/CD, you can consider to configure post trigger to execute oc import-image <imagestream name>:<tag> --confirm for manual sync.

-- Daein Park
Source: StackOverflow