ARTIFACTORY: How to add cold instance using the Rest API

Pranav Hegde
2023-01-22 11:07

Adding cold instances to a live instance can be done via the UI, however, it is also possible to add cold instances via REST API by using the create pairing token REST API call. This can be achieved by following these steps:

Step 1: Make sure the custom base URL is configured in the cold instance and once the cold instance is ready, generate the pairing token for cold storage. You need to execute the below rest api in the cold instance.curl -X POST -u<adminuser>:<password> http://localhost:8082/artifactory/api/v1/service_trust/pairing/artifactory-coldE.g:root@ab601f6cc4b9:~# curl -X POST -u<adminuser>:<password> http://localhost:8082/artifactory/api/v1/service_trust/pairing/artifactory-cold
{
 “pairing_token” : “eyJ2ZXIiOiIyIiwidHlwI…….***********hpziuu3UKl4A”
}

Step 2: Make sure the custom base URL is configured in the live instance and once the live instance is ready. Create a repo.json file in the live instance and add the pairing token generated in step 1 in json object as shown below.

cat repo.json:{
 “pairing_token” : “eyJ2ZXIiOiIyIiwidHlwI…….0pkj64cIQaJjYjL4nnkWl7qhpziuu3UKl4A”
}

Step 3: Execute the below command in the live instance for pairing both instances.curl -X PUT -u<adminuser>:<Password> http://localhost:8082/artifactory/api/v1/service_trust/pairing/artifactory-cold  -H "Content-type:application/json" -T repo.jsonE.g:root@a879090cfc8a:~# curl -X PUT -u<adminuser>:<Password> http://localhost:8082/artifactory/api/v1/service_trust/pairing/artifactory-cold  -H "Content-type:application/json" -T repo.json
{
  "message" : "Trust with service artifactory-cold was established successfully"
}

Once the trust is successfully established, you should see the below UI in the deployment bindings section.

User-added image

Also, the Cold Storage Monitoring should be visible in Administration->Artifactory->Services->Cold Storage Monitoring      
  
User-added image