Ubuntu

How to Install Harbor Image Registry in Ubuntu 20.04

Today the Harbor image registry is widely used for storing container images. It has an extensible API and web UI supports content signing and validation for the images. Harbor images can be replicated across multiple harbor instances.

This article will explain how to install harbor in the stable version of Ubuntu 20.04.

Prerequisites

  1. Domain mapped to A record to get letsencrypt certificate. ( If you have your own certificate no need this)
  2. Internet connection to the server.
  3. Latest version of docker and docker-compose installed.

Configuration

First of all update your package repository,

$ sudo apt update

Harbor can be accessed in a secure environment using TLS encryption. For this, we are going to generate a letsencrypt certificate. You need to install the certbot package to get the certificate.

( If you are going to use your own certificate then exclude the step )

$ sudo apt install certbot -y

Now generate a certificate, use your domain name and email.

( If you are going to use your own certificate then exclude the step )

$ sudo certbot certonly --standalone -d "harbor.yourdomain.com" --preferred-challenges http --agree-tos -n -m "[email protected]" --keep-until-expiring

By default certificate are generated in /etc/letsencrypt/live/harbor.yourdoain.com/

Let’s begin to download the harbor package. Copy the following script and paste it in your terminal. It will download the latest version of harbor.

$ curl -s https://api.github.com/repos/goharbor/harbor/releases/latest | grep browser_download_url | cut -d '"' -f 4 | grep '\.tgz$' | wget -i -

Extract the content using the following command.

$ tar zxvf harbor-offline-installer-v*.tgz

You will get a harbor directory, change to it.

$ cd harbor

You can see the installation script file and other configurations. An example of configuration is given in a temp file. Just copy it to the harbor.yml file.

$ cp harbor.yml.tmpl harbor.yml

Open the harbor.yml file and make necessary changes like harbor your hostname, http and https port, certificate path and admin dashboard password. If you have your own certificate then make sure they are in the path you defined.

$ vim harbor.yml

Also in the same file you can configure database password, maximum number of connections and volume to store your images. Save the file finally.

Now, run the install script as shown below. The notary and chartmuseu are optional.

Notary helps to digitally sign images using keys that verify content and publish them securely. Chartmuseum provides helm chart repositories.

$ sudo ./install.sh --with-notary --with-chartmuseum

After the installation finished. Confirm by listing the port below.

$ sudo ss -tulpan | grep -i list

Also verify that there is some content in your data volume. And see log directory.

$ ls /data
$ ls /var/log/harbor/

Harbor web access

Now you can access the harbor web. Type https://harbor.yourdomain.com

To access harbor web use the credential you defined in above harbor.yml configuration.

Harbor dashboard

The dashboard is really nice and easy to use. You can create project and send your image to store and use it in the deployment.

Conclusion

This article shows you how to install harbor in Ubuntu. The process is the same for all the Debian family of linux. Hope you enjoy it.

Similar Posts