I have an openshift deployment with buildConfig as follows:
apiVersion: v1
kind: BuildConfig
metadata:
name: '#OKD_COMPONENT_NAME#'
spec:
output:
to:
kind: ImageStreamTag
name: '#OKD_COMPONENT_NAME#:latest'
runPolicy: SerialLatestOnly
source:
git:
uri: '#CI_REPOSITORY_URL#'
ref: '#CI_COMMIT_REF_NAME#'
type: Git
contextDir: #OKD_COMPONENT_NAME#
strategy:
dockerStrategy:
buildArgs:
- name: "CA_HOSTS_LIST"
value: "get-ca-cert.apps.test.fr:443 get-ca-cert.apps.test.fr:443 get-ca-cert.apps.test.fr:443"
type: Docker
triggers:
- type: ConfigChange
- imageChange: {}
type: ImageChange
At the end of the build openshift build the image and push it to its internal registry.
The issue is that I want to copy that image build and pushed to openshift internal registry to AWS ECR. The openshift pods has to be created with images in the openshift internal registry but I just want to also have a copy of that image pushed to internal registry automatically in AWS ECR also.
I there a way this can be achieved?
I have not tested this, but oc image mirror
command may fit for your use case, refer Transferring Images
for more details. This command can copy an image in the registry to the multiple registries. For example, it shows how to copy the internal image "image:latest" to docker.io
and quay.io
.
oc image mirror docker-registry.default.svc.cluster.local/project/image:latest \
docker.io/project/image:stg \
quay.io/project/image:prod
For the automation, you may do this through the script which implements above copy tasks using Configuring Post Commit Build Hooks trigger, or you may need to more complicated build process like Jenkins Pipeline for this.