1
0
mirror of https://github.com/goharbor/harbor.git synced 2024-12-30 04:28:17 +01:00
harbor/docs/installation_guide.md
Stuart Clements 26905baca2
Doc updates for 1.10 ()
* Updated doc to include Limited Guest

* Added example for limited guest.

* Updated vulnerability scanning docs for 1.10.

* Updated GC docs to reflect new position in UI

* Updated project quota doc to reflect new position in UI

* Added some doc about tag immutability

* Fixed index

* Formatting

* Added new replication endpoints

* Added project quota webhook

* Review comments from Alex

* Clarified Clair requirement for additional scanners

* Some formatting and edits in vulnerability section

* Updated tag retention doc to reflect new UI

* Updated tag immutability to reflect new UI

* New screencaps

* Updated robot accounts doc for new UI and rewrote

* Formatting

* Updated webhooks doc for new UI

* Formatting

* Updated Logs doc for new UI

* Formatting

* New screencaps

* Added tag immutability to permissions document

* Corrected immutability permissions

* Added explanation for project quotas

* Fixed typo

* Linked to new compatibility list document

* Comments from Alex

* Comments from Steven and Wang

* Removed mention of the ellipsis in project menu

* Reverting some screencaps to remove ellipsis

* Reverted log screencaps to remove ellipsis

* Minor rewording

* Fixed caps

* More cap fixing

* Added info about self-registration, rewrote db auth doc

* Attempting to document *.asc key

* Added that negligible vulnerabilities are ignored, rewrote

* Formatting

* Added scanner permissions to table

* Clarified labelling and replication

* Rewrote replication docs

* Formatting

* Typo

* Rearranged content

* Updated ASC key docs

* formatting

* Minor rewording

* Rewrote LDAP section

* minor edits

* Added OIDC groups, rewrote OIDC docs

* formatting

* Mentioned memberof for OIDC.

* Comments from steven

* Added info about insecure registries

* Added tag immutability example

* Removed UAA from install guide

* Cleaned up headers

* More clean up of headers

* Recommended not to use UAA

* Added user-generated CLI secret

* Adding stray screencap
2019-12-12 18:35:30 +01:00

30 KiB

Harbor Installation and Configuration Guide

There are two possibilities when installing Harbor.

  • Online installer: The online installer downloads the Harbor images from Docker hub. For this reason, the installer is very small in size.

  • Offline installer: Use the offline installer if the host to which are are deploying Harbor does not have a connection to the Internet. The offline installer contains pre-built images so it is larger than the online installer.

You download the installers from the official release page.

This guide describes how to install and configure Harbor by using either the online or offline installer. The installation processes are almost the same.

If you are upgrading from a previous version of Harbor, you might need to update the configuration file and migrate your data to fit the database schema of the later version. For information about upgrading, see the Harbor Upgrade and Migration Guide.

In addition, the Harbor community created instructions describing how to deploy Harbor on Kubernetes. If you want to deploy Harbor to Kubernetes, see Harbor on Kubernetes.

Harbor Components

The table below lists the components that are deployed when you deploy Harbor.

Component Version
Postgresql 9.6.10-1.ph2
Redis 4.0.10-1.ph2
Clair 2.0.8
Beego 1.9.0
Chartmuseum 0.9.0
Docker/distribution 2.7.1
Docker/notary 0.6.1
Helm 2.9.1
Swagger-ui 3.22.1

Deployment Prerequisites for the Target Host

Harbor is deployed as several Docker containers. You can therefore deploy it on any Linux distribution that supports Docker. The target host requires Docker, and Docker Compose to be installed.

Hardware

The following table lists the minimum and recommended hardware configurations for deploying Harbor.

Resource Minimum Recommended
CPU 2 CPU 4 CPU
Mem 4 GB 8 GB
Disk 40 GB 160 GB

Software

The following table lists the software versions that must be installed on the target host.

Software Version Description
Docker engine version 17.06.0-ce+ or higher For installation instructions, see docker engine doc
Docker Compose version 1.18.0 or higher For installation instructions, see docker compose doc
Openssl latest is preferred Used to generate certificate and keys for Harbor

Network ports

Harbor requires that the following ports be open on the target host.

Port Protocol Description
443 HTTPS Harbor portal and core API accept HTTPS requests on this port. You can change this port in the configuration file.
4443 HTTPS Connections to the Docker Content Trust service for Harbor. Only required if Notary is enabled. You can change this port in the configuration file.
80 HTTP Harbor portal and core API accept HTTP requests on this port. You can change this port in the configuration file.

Installation Procedure

The installation procedure involves the following steps:

  1. Download the installer.
  2. Configure the harbor.yml file.
  3. Run the install.sh script with the appropriate options to install and start Harbor.

Download and Unpack the Installer

  1. Go to the Harbor releases page.

  2. Download either the online or offline installer for the version you want to install.

  3. Optionally download the corresponding *.asc file to verify that the package is genuine.

    The *.asc file is an OpenPGP key file. Perform the following steps to verify that the downloaded bundle is genuine.

    1. Obtain the public key for the *.asc file.

      gpg --keyserver hkps://keyserver.ubuntu.com --receive-keys 644FF454C0B4115C

      You should see the message public key "Harbor-sign (The key for signing Harbor build) <jiangd@vmware.com>" imported

    2. Verify that the package is genuine by running one of the following commands.

      • Online installer:
        gpg -v --keyserver hkps://keyserver.ubuntu.com --verify harbor-online-installer-version.tgz.asc
      • Offline installer:
        gpg -v --keyserver hkps://keyserver.ubuntu.com --verify harbor-offline-installer-version.tgz.asc

      The gpg command verifies that the signature of the bundle matches that of the *.asc key file. You should see confirmation that the signature is correct.

      gpg: armor header: Version: GnuPG v1
      gpg: assuming signed data in 'harbor-offline-installer-v1.10.0-rc2.tgz'
      gpg: Signature made Fri, Dec  6, 2019  5:04:17 AM WEST
      gpg:                using RSA key 644FF454C0B4115C
      gpg: using pgp trust model
      gpg: Good signature from "Harbor-sign (The key for signing Harbor build) <jiangd@vmware.com> [unknown]
      
  4. Use tar to extract the installer package:

    • Online installer:
      bash $ tar xvf harbor-online-installer-version.tgz
    • Offline installer:
      bash $ tar xvf harbor-offline-installer-version.tgz

Configure Harbor

You set system level parameters for Harbor in the harbor.yml file that is contained in the installer package. These parameters take effect when you run the install.sh script to install or reconfigure Harbor.

After the initial deployment and after you have started Harbor, you perform additional configuration in the Harbor Web Portal.

Required Parameters

The table below lists the parameters that must be set when you deploy Harbor. By default, all of the required parameters are uncommented in the harbor.yml file. The optional parameters are commented with #. You do not necessarily need to change the values of the required parameters from the defaults that are provided, but these parameters must remain uncommented. At the very least, you must update the hostname parameter.

IMPORTANT: Harbor does not ship with any certificates. In versions up to and including 1.9.x, by default Harbor uses HTTP to serve registry requests. This is acceptable only in air-gapped test or development environments. In production environments, always use HTTPS. If you enable Content Trust with Notary to properly sign all images, you must use HTTPS.

You can use certificates that are signed by a trusted third-party CA, or you can use self-signed certificates. For information about how to create a CA, and how to use a CA to sign a server certificate and a client certificate, see Configuring Harbor with HTTPS Access.

Required Parameters for Harbor Deployment
Parameter Sub-parameters Description and Additional Parameters
hostname None Specify the IP address or the fully qualified domain name (FQDN) of the target host on which to deploy Harbor. This is the address at which you access the Harbor Portal and the registry service. For example, 192.168.1.10 or reg.yourdomain.com. The registry service must be accessible to external clients, so do not specify localhost, 127.0.0.1, or 0.0.0.0 as the hostname.
https  

Use HTTPS to access the Harbor Portal and the token/notification service. Always use HTTPS in production environments and environments that are not air-gapped.

  port The port number for HTTPS. The default is 443.
  certificate The path to the SSL certificate.
  private_key The path to the SSL key.
harbor_admin_password None Set an initial password for the Harbor system administrator. This password is only used on the first time that Harbor starts. On subsequent logins, this setting is ignored and the administrator's password is set in the Harbor Portal. The default username and password are admin and Harbor12345.
database   Use a local PostgreSQL database. You can optionally configure an external database, in which case you can disable this option.
  password Set the root password for the local database. You must change this password for production deployments.
  max_idle_conns The maximum number of connections in the idle connection pool. If set to <=0 no idle connections are retained. The default value is 50. If it is not configured the value is 2.
  max_open_conns The maximum number of open connections to the database. If <= 0 there is no limit on the number of open connections. The default value is 100 for the max connections to the Harbor database. If it is not configured the value is 0.
data_volume None The location on the target host in which to store Harbor's data. You can optionally configure external storage, in which case disable this option and enable storage_service. The default is /data.
clair updaters_interval Set an interval for Clair updates, in hours. Set to 0 to disable the updates. The default is 12 hours.
jobservice max_job_workers The maximum number of replication workers in the job service. For each image replication job, a worker synchronizes all tags of a repository to the remote destination. Increasing this number allows more concurrent replication jobs in the system. However, since each worker consumes a certain amount of network/CPU/IO resources, set the value of this attribute based on the hardware resource of the host. The default is 10.
notification webhook_job_max_retry Set the maximum number of retries for web hook jobs. The default is 10.
chart absolute_url Set to enabled for Chart to use an absolute URL. Set to disabled for Chart to use a relative URL.
log   Configure logging.
  level Set the logging level to debug, info, warning, error, or fatal. The default is info.
  local Set the log retention parameters:
  • rotate_count: Log files are rotated rotate_count times before being removed. If count is 0, old versions are removed rather than rotated. The default is 50.
  • rotate_size: Log files are rotated only if they grow bigger than rotate_size bytes. Use k for kilobytes, M for megabytes, and G for gigabytes. 100, 100k, 100M and 100G are all valid values. The default is 200M.
  • location: Set the directory in which to store the logs. The default is /var/log/harbor.
  external_endpoint Enable this option to forward logs to a syslog server.
  • protocol: Transport protocol for the syslog server. Default is TCP.
  • host: The URL of the syslog server.
  • port: The port on which the syslog server listens
proxy   Configure proxies to be used by Clair, the replication jobservice, and Harbor. Leave blank if no proxies are required.
  http_proxy Configure an HTTP proxy, for example, http://my.proxy.com:3128.
  https_proxy Configure an HTTPS proxy, for example, http://my.proxy.com:3128.
  no_proxy Configure when not to use a proxy, for example, 127.0.0.1,localhost,core,registry.

Optional parameters

The following table lists the additional, optional parameters that you can set to configure your Harbor deployment beyond the minimum required settings. To enable a setting, you must uncomment it in harbor.yml by deleting the leading # character.

Optional Parameters for Harbor
Parameter Sub-Parameters Description and Additional Parameters
http   Do not use HTTP in production environments. Using HTTP is acceptable only in air-gapped test or development environments that do not have a connection to the external internet. Using HTTP in environments that are not air-gapped exposes you to man-in-the-middle attacks.
  port Port number for HTTP
external_url None Enable this option to use an external proxy. When enabled, the hostname is no longer used.
storage_service   By default, Harbor stores images and charts on your local filesystem. In a production environment, you might want to use another storage backend instead of the local filesystem. The parameters listed below are the configurations for the registry. See *Configuring Storage Backend* below for more information about how to configure a different backend.
  ca_bundle The path to the custom root CA certificate, which is injected into the trust store of registry and chart repository containers. This is usually needed if internal storage uses a self signed certificate.
  filesystem The default is filesystem, but you can set azure, gcs, s3, swift and oss. For information about how to configure other backends, see Configuring a Storage Backend below. Set maxthreads to limit the number of threads to the external provider. The default is 100.
  redirect Set disable to true when you want to disable registry redirect
external_database   Configure external database settings, if you disable the local database option. Harbor currently only supports POSTGRES.
  harbor

Configure an external database for Harbor data.

  • host: Hostname of the Harbor database.
  • port: Database port.
  • db_name: Database name.
  • username: Username to connect to the core Harbor database.
  • password: Password for the account you set in username.
  • ssl_mode: Enable SSL mode.
  • max_idle_conns: The maximum number of connections in the idle connection pool. If <=0 no idle connections are retained. The default value is 2.
  • max_open_conns: The maximum number of open connections to the database. If <= 0 there is no limit on the number of open connections. The default value is 0.
  clair Configure an external database for Clair.
  • host: Hostname of the Clair database
  • port: Database port.
  • db_name: Database name.
  • username: Username to connect to the Clair database.
  • password: Password for the account you set in username.
  • ssl_mode: Enable SSL mode.
  notary_signer Configure an external database for the Notary signer database
  • host: Hostname of the Notary signer database
  • port: Database port.
  • db_name: Database name.
  • username: Username to connect to the Notary signer database.
  • password: Password for the account you set in username.
  • ssl_mode: Enable SSL mode.
  notary_server
  • host: Hostname of the Notary server database.
  • port: Database port.
  • db_name: Database name.
  • username: Username to connect to the Notary server database.
  • password: Password for the account you set in username.
  • ssl_mode: Enable SSL mode.e
external_redis   Configure an external Redis instance.
  host Hostname of the external Redis instance.
  port Redis instance port.
  password Password to connect to the external Redis instance.
  registry_db_index Database index for Harbor registry.
  jobservice_db_index Database index for jobservice.
  chartmuseum_db_index Database index for Chart museum.

NOTE: The harbor.yml file includes options to configure a UAA CA certificate. This authentication mode is not recommended and is not documented.

Configuring a Storage Backend

By default Harbor uses local storage for the registry, but you can optionally configure the storage_service setting so that Harbor uses external storage. For information about how to configure the storage backend of a registry for different storage providers, see the Registry Configuration Reference in the Docker documentation. For example, if you use Openstack Swift as your storage backend, the parameters might resemble the following:

storage_service:
  ca_bundle:
  swift:
    username: admin
    password: ADMIN_PASS
    authurl: http://keystone_addr:35357/v3/auth
    tenant: admin
    domain: default
    region: regionOne
    container: docker_images"
  redirect:
    disable: false

Installing and starting Harbor

Once you have configured harbor.yml optionally set up a storage backend, you install and start Harbor by using the install.sh script. Note that it might take some time for the online installer to download all of the `Harbor images from Docker hub.

You can install Harbor in different configurations:

  • Just Harbor, without Notary, Clair, or Chart Repository Service
  • Harbor with Notary
  • Harbor with Clair
  • Harbor with Chart Repository Service
  • Harbor with two or all three of Notary, Clair, and Chart Repository Service

Default installation without Notary, Clair, or Chart Repository Service

The default Harbor installation does not include Notary or Clair service.

    $ sudo ./install.sh

If the installation succeeds, you can open a browser to visit the Harbor Portal at http://reg.yourdomain.com, changing reg.yourdomain.com to the hostname that you configured in harbor.yml. If you did not change them, the default administrator username and password are admin and Harbor12345.

Log in to the admin portal and create a new project, for example, myproject. You can then use docker commands to log in and push images to Harbor. By default, the registry server listens on port 80:

$ docker login reg.yourdomain.com
$ docker push reg.yourdomain.com/myproject/myrepo:mytag

Installation with Notary

To install Harbor with the Notary service, add the --with-notary parameter when you run install.sh:

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

Note: For installation with Notary, you must use Harbor with HTTPS.

For more information about Notary and Docker Content Trust, see Content Trust in the Docker documentation.

Installation with Clair

To install Harbor with Clair service, add the --with-clair parameter when you run install.sh:

    $ sudo ./install.sh --with-clair

For more information about Clair, see the Clair documentation.

Installation with Chart Repository Service

To install Harbor with chart repository service, add the --with-chartmuseum parameter when you run install.sh:

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

Installation with Notary, Clair, and Chart Repository Service

If you want to install all three of Notary, Clair and chart repository service, you must specify all of the parameters in the same command:

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

Connecting to Harbor via HTTP

IMPORTANT: If your installation of Harbor uses HTTP rather than HTTPS, you must add the option --insecure-registry to your client's Docker daemon. By default, the daemon file is located at /etc/docker/daemon.json.

For example, add the following to your daemon.json file:

{
"insecure-registries" : ["myregistrydomain.com:5000", "0.0.0.0"]
}

After you update daemon.json, you must restart both Docker Engine and Harbor.

  1. Restart Docker Engine.

    systemctl restart docker

  2. Stop Harbor.

    docker-compose down -v

  3. Restart Harbor.

    docker-compose up -d

Using Harbor

For information on how to use Harbor, see the Harbor User Guide .

Managing Harbor Lifecycle

You can use docker-compose to manage the lifecycle of Harbor. Some useful commands are listed below. You must run the commands in the same directory as docker-compose.yml.

Stop Harbor:

$ sudo docker-compose stop
Stopping nginx              ... done
Stopping harbor-portal      ... done
Stopping harbor-jobservice  ... done
Stopping harbor-core        ... done
Stopping registry           ... done
Stopping redis              ... done
Stopping registryctl        ... done
Stopping harbor-db          ... done
Stopping harbor-log         ... done

Restart Harbor after Stopping:

$ sudo docker-compose start
Starting log         ... done
Starting registry    ... done
Starting registryctl ... done
Starting postgresql  ... done
Starting core        ... done
Starting portal      ... done
Starting redis       ... done
Starting jobservice  ... done
Starting proxy       ... done

Reconfigure Harbor

To reconfigure Harbor, stop the existing Harbor instance and update harbor.yml. Then run prepare script to populate the configuration. Finally re-create and start the Harbor instance.

$ sudo docker-compose down -v
$ vim harbor.yml
$ sudo prepare
$ sudo docker-compose up -d

Other Commands

Remove Harbor's containers while keeping the image data and Harbor's database files on the file system:

$ sudo docker-compose down -v

Remove Harbor's database and image data for a clean re-installation:

$ rm -r /data/database
$ rm -r /data/registry

Managing the Harbor Lifecycle with Notary, Clair and Chart Repository Service

If you want to install Notary, Clair and chart repository service together, you should include all the components in the prepare commands:

$ sudo docker-compose down -v
$ vim harbor.yml
$ sudo prepare --with-notary --with-clair --with-chartmuseum
$ sudo docker-compose up -d

Please check the Docker Compose command-line reference for more on docker-compose.

Persistent Data and Log Files

By default, registry data is persisted in the host's /data/ directory. This data remains unchanged even when Harbor's containers are removed and/or recreated. You can edit the data_volume in harbor.yml file to change this directory.

In addition, Harbor uses rsyslog to collect the logs for each container. By default, these log files are stored in the directory /var/log/harbor/ on the target host. You can change the log directory in harbor.yml.

Configuring Harbor to Listen on a Customized Port

By default, Harbor listens on port 443(HTTPS) and 80(HTTP, if configured) for both Harbor portal and Docker commands. You can reconfigure the default ports in harbor.yml

Configure Harbor with an External Database

Currently, Harbor only supports PostgreSQL database. To user an external database, uncomment the external_database section in harbor.yml and fill the necessary information. You must create four databases for Harbor core, Clair, Notary server, and Notary signer. And the tables are generated automatically when Harbor starts up.

Manage User Settings

User settings are handled separately system settings. All user settings are configured in the Harbor portal or by HTTP requests at the command line. For information about using HTTP requests to configure user settings, see Configure User Settings at the Command Line to config user settings.

Performance Tuning

By default, Harbor limits the CPU usage of the Clair container to 150000 to avoid it using up all CPU resources. This is defined in the docker-compose.clair.yml file. You can modify this file based on your hardware configuration.

Troubleshooting

Harbor Doesn't Start or Functions Incorrectly

When Harbor does not function correctly, run the following commands to find out if all of Harbor's containers in UP status:

    $ sudo docker-compose ps
        Name                     Command               State                    Ports
  -----------------------------------------------------------------------------------------------------------------------------
  harbor-core         /harbor/start.sh                 Up
  harbor-db           /entrypoint.sh postgres          Up      5432/tcp
  harbor-jobservice   /harbor/start.sh                 Up
  harbor-log          /bin/sh -c /usr/local/bin/ ...   Up      127.0.0.1:1514->10514/tcp
  harbor-portal       nginx -g daemon off;             Up      80/tcp
  nginx               nginx -g daemon off;             Up      0.0.0.0:443->443/tcp, 0.0.0.0:4443->4443/tcp, 0.0.0.0:80->80/tcp
  redis               docker-entrypoint.sh redis ...   Up      6379/tcp
  registry            /entrypoint.sh /etc/regist ...   Up      5000/tcp
  registryctl         /harbor/start.sh                 Up

If a container is not in the Up state, check the log file for that container in /var/log/harbor. For example, if the harbor-core container is not running, look at the core.log log file.

Using nginx or Load Balancing

When setting up Harbor behind an nginx proxy or elastic load balancing, look for the following line in common/config/nginx/nginx.conf and, if the proxy already has similar settings, remove it from the sections location /, location /v2/ and location /service/.

proxy_set_header X-Forwarded-Proto $scheme;

Then re-deploy Harbor per the instructions in "Managing Harbor Lifecycle.