How to replicate artifacts cross site and resolve in Artifactory

Pradnya Shinde
2019-02-15 23:55

Summary

How to replicate artifacts cross site and resolve in Artifactory

Solution

Option [I]:
In this option in addition to the usual benefits of remote repositories, smart remote repositories offer several additional benefits. Create a smart repository in site B pointing to the local repository in site A. 

Option [II]:
In this functional example there are two sites A and B. We want to push docker artifacts to site A, replicate them to site B and pull those replicated docker artifacts from site B.

  1. On site B artifactory –

    1. Create a local repository named 'docker-local' and a virtual repository 'docker'. You can also create a remote Docker repository and add both the local and remote repositories to the virtual 'docker' repository. Optionally you can use Quick setup for setting up these Docker standard repositories.

  2. On site A artifactory –

    1. Similarly create a local, remote and virtual repo named 'docker-local' and virtual repo 'docker'.

    2. On ‘docker-local' set up replication to replicate artifacts to 'docker-local' repo of site B.​​​​​​

  3. Push to site A:

    1. docker login <site A artifactory server>

    2. docker tag <docker image id> <site A artifactory server>/docker/<docker image tag>

    3. docker push <site A artifactory server>/docker/<docker image tag>

for example:

docker login siteA.com

docker push siteA.com/docker/nginx

docker tag c82521676580 siteA.com/docker/nginx

  1. Earlier configured(& enabled) replication will replicate the docker artifact to site B's 'docker-local' repo which you can pull from the virtual repo 'docker' in site B as following:

    1. docker login <site B artifactory server>

    2. docker pull <site B artifactory server>/docker/<docker image tag>

for example:

  • docker login siteB.com
  • docker pull siteB.com/docker/nginx

Comparing the above two options [I] & [II]- in option [II] when you replicate the artifacts to site B then it benefits the following scenarios:

  1. Reduce the latency for the users accessing site B as the artifacts will be local to site B
  2. High availability of the artifacts: In case site A is unavailable then the artifacts for site A users would be still available when those users are redirected to use the site B.