VK Cloud logo
Updated atMarch 27, 2024   02:33 PM

Installing and configuring Harbor

In this article, we will look at how to install and configure Harbor repository repositories. After that, you can configure application auto-deployment to a Kubernetes cluster.

Installing the Harbor repository repository

Before installing Harbor:

  1. Install and configure Docker.
  2. Install and configure GitLab.

Harbor is installed as a Docker image using the online installer.

To install the Harbor repositories:

  1. Download the online installer script and unzip it:
1root@ubuntu-std3-2-4-40gb:~# wget https://github.com/goharbor/harbor/releases/download/v1.9.3/harbor-online-installer-v1.9.3.tgz
2root@ubuntu-std3-2-4-40gb:~# tar -zxvf harbor-online-installer-v1.9.3.tgz
  1. In the resulting harbor folder, configure the harbor.yml file:
1hostname: <SERVER_DNS_NAME>
2http:
3    # port for http, default is 80. If https enabled, this port will redirect to https port
4    port: 8080
5# https related config
6    https:
7# # https port for harbor, default is 443
8    port: 8443
9# # The path of cert and key files for nginx
10    certificate: /opt/gitlab/config/ssl/<SERVER_DNS_NAME>.crt
11    private_key: /opt/gitlab/config/ssl/<SERVER_DNS_NAME>.key
12# The default data volume
13data_volume: /opt/harbor

And:

  • The hostname is the same as the GitLab name because the deployment is done on the server that hosts GitLab.
  • Non-standard HTTP and HTTPS ports are used, as the standard ones are used by the GitLab web interface.
  • Uses the LetsEncrypt certificate and key that was created when you set up GitLab.
  1. Run the install.sh script:
1root@ubuntu-std3-2-4-40gb:~/harbor# ./install.sh
2
3[Step 0]: checking installation environment ...
4Note: docker version: 19.03.5
5Note: docker-compose version: 1.25.0
6
7[Step 1]: preparing environment ...
8[Step 2]: starting Harbor ...
9Creating harbor-log ... done
10Creating registryctl ... done
11Creating redis ... done
12Creating harbor-db ... done
13Creating harbor portal ... done
14Creating registry ... done
15Creating harbor-core ... done
16Creating nginx ... done
17Creating harbor-jobservice ... done
18
19✔ ----Harbor has been installed and started successfully.----

Harbor launched.

Setting up the repository repository Harbor

  1. Log in to Harbor.

Since we are using non-standard ports, the URL will look like this:

https://<SERVER_DNS_NAME>:8443

The default login is admin. The primary password is set in the harbor.yml file (default is Harbor12345).

  1. Change the password for the admin user. To do this, click on admin in the upper right corner and select Change Password:

  1. Specify the current and new passwords:

  1. Create a user under which GitLab will work with Harbor. To do this, select Users on the left:

  1. Specify the data of the new user:

  1. Create a new project that will contain the built images from GitLab. To do this, select Projects on the left:

  1. Enter the details of the new project:

  1. Add a user to the project:

  1. Specify a name and role for the user:

Now set up auto-deployment of the application to the Kubernetes cluster.