Add Google Artifact Registry as a Docker Registry

Google is trying to migrate customers from Container Registry(GCR) to the Artifact Registry(GAR). Currently, Harness does not support GAR natively as an Artifact Source Provider. We can get Harness to use GAR as a Docker Registry, with a few simple steps.

To get this to work, you will need

  1. An Artifact Registry repo in the Google Cloud Platform (GCP). Quick start instructions for setup Docker with an Artifactory Registry can be found at https://cloud.google.com/artifact-registry/docs/docker/quickstart

  2. To set up a Service Account in GCP. The instructions can be found at https://cloud.google.com/artifact-registry/docs/docker/authentication#json-key


After you have adding an Image in GAR. It will look something like this,

If you have setup a JSON key it will look something like this,

Screen Shot 2021-02-03 at 4.09.29 PM

From the CLI, (I am using BASH) you will need to convert the content to bash64

base64 -i inputfile -o outputfile

Go to the Harness Secret Manager, and add a new Encrypted Text Secret. Copy the content from the outputfile and paste it into the value field.

Screen Shot 2021-02-03 at 4.16.59 PM

Go to the Artifact Servers Page and let’s create a new Docker registry.

  • The Docker Registry URL should be the location of the Repo from the Artifact Registry that was set up.
  • For Authentication using a Service Account Key, the username is required and has two values
​​_json_key

or

_json_key_base64
  • The username should match the key type. In the example below _json_key_base64
  • The password should be the one that you have just saved to the Secrets Manager.

Screen Shot 2021-02-03 at 4.20.19 PM

If you test this, and the credentials and the Registry URL are all valid, it will pass.


Next setup your Artifact Source in a Service,

  1. The Source Server should match the Artifact Service Provider that you just set up above.
  2. The Docker Image Name should match the path to the Image from the GAR that you had set up.
  3. Click Submit and it will be saved.

Screen Shot 2021-02-03 at 4.24.13 PM

In the Service Page Click on Artifact History and you should be able to verify the complete the set up by Manually Select An Artifact.

The Artifact should be populated with the Tag from when you originally set up the GAR. (The first screenshot shows the quickstart-image with a tag of tag1.

Screen Shot 2021-02-03 at 4.28.38 PM

That is everything that you need to set up GAR as a Docker Registry in Harness.

1 Like