×


Install Harbor Image Registry on Ubuntu 20.04 - Best Method ?

Harbor is an open-source project that extends the Docker registry source code to provide an enterprise-class registry server. Harbor originates from from VMware and provides additional flexibility and security to Docker registries so that enterprises can create a repository for Docker images for use within their infrastructure. 

Nowadays, 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.

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform Open Source related Installation queries on Ubuntu Linux System.

In this context, we shall look into how to install harbor in the stable version of Ubuntu 20.04.


Harbor provides the following features: 

  • Integrated User Account and Authentication (UAA): Harbor can share UAA authentication with vCenter Server using vCenter Single Sign-On. 
  • Role-based access control (RBAC): Users and repositories are organized into projects. Users can have master or guest permissions depending on the permission of the namespace. 
  • Graphical user portal: Users can easily browse, search repositories, and manage projects. 
  • Auditing: All operations to repositories are tracked. 
  • Management with labels: Harbor provides labels at the project level. 
  • Identity integration and role-based access control (RBAC).
  • Graphical user interface.
  • Auditing of operations.
  • Management with labels.


How to Install Harbor Image Registry on Ubuntu ?

Before proceeding with this Installation task, we need to ensure that the following requirements are met to allow a successful Installation process:

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


Now, follow the steps given below.


1. Update System repository

First of all update your package repository:

$ sudo apt update


2. Install Certbot

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 this 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 this step ):

$ sudo certbot certonly --standalone -d "harbor.yourdomain.com" --preferred-challenges http --agree-tos -n -m "admin@yourdomain.com" --keep-until-expiring

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


3.  Download harbor package

Now, let's 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 -

Next, 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


4. Configure harbor

In harbor directory, 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

Next, 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. 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:

$ 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/


How to Access Harbor via the Web ?

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 is really nice and easy to use. You can create project and send your image to store and use it in the deployment.


[Need assistance in Installing Open Source Software on Linux System? We can help you. ]


Conclusion

This article covers how to install harbor on Ubuntu. The process is the same for all the other distribution of Linux. Harbor is a component of vSphere with Kubernetes. Harbor provides an enterprise-class registry service. 

Harbor is deployed in a dedicated system namespace on the Supervisor Cluster and is composed of several vSphere Pods. 

Image registries provide a centralized repository for an organization to store container images. 

Public image registries can be used to store container images. However, for security reasons, it is better to use an on-premises image registry. 

You use an on-premises image registry for the following purposes: 

Store container images securely. 

Control access to container images. 

vSphere with Kubernetes is integrated with Harbor and is also compatible with other container image registries. 


Harbor key features includes:

  • Security and vulnerability analysis.
  • Content signing and validation.
  • Extensible API and web UI.
  • Image replication.
  • Role-based access control.
  • Multitenant.


After Harbor installation has succeeded, access Harbor web console on https://registry_domain.

Then Login with:

  • Username: admin
  • Password: Set-in-harbor.yml