[离线安装 Harbor v2 | AtomPi's Blog](https://blog.atompi.com/2020/08/03/%E7%A6%BB%E7%BA%BF%E5%AE%89%E8%A3%85%20Harbor%20v2/) 默认用户名: admin 默认密码:Harbor12345 Harbor12345 ### 开始部署 * 下载离线安装程序 下载地址: `https://github.com/vmware/harbor/releases` 选择: `harbor-offline-installer-.tgz` * 压安装包 | ``` # tar -xf harbor-offline-installer-xxx.tgz ``` * 配置 Harbor 配置文件模板为: `harbor.yml.tmpl` 复制模板文件,并命名为 `harbor.yml` 在 `harbor.yml` 中有两类参数:必需参数和可选参数。 * 必选参数:需要在配置文件中设置这些参数。如果用户在 `harbor.yml` 中更新它们并运行 `install.sh` 脚本以重新安装 Harbor ,它们将生效。 * 可选参数:这些参数对于更新是可选的,即用户可以将它们保留为默认值,并在启动 Harbour 后在 Web UI 上更新它们。如果它们设置在 `harbor.yml` 中,它们只会在第一次启动 Harbour 时生效。后续在 Web UI 中的更新将忽略 `harbor.yml` 中这些参数。 *在这里,我只列出部分必选参数的配置,具体参数说明见文章末尾处给出的官方安装文档连接* 1. 必选参数: * `hostname`: 访问 harbor 的域名,可以使用主机 IP ,但建议使用域名 `hostname = reg.atompi.com` * `http / https`: 访问 harbor 的 url 协议,若只使用 `http` ,则注释掉 `https` 项即可(如下),若启用 `https` 请参考 [Configuring Harbor with HTTPS Access](https://goharbor.io/docs/2.0.0/install-config/configure-https/) | ``` # http related config http: # port for http, default is 80. If https enabled, this port will redirect to https port port: 80 # https related config #https: # https port for harbor, default is 443 #port: 443 # The path of cert and key files for nginx #certificate: /your/certificate/path #private_key: /your/private/key/path ``` * `harbor_admin_password`: 超级管理员用户 `admin` 的登录密码 * `database.password`: 数据库 root 用户密码,用于指定 Harbor 默认数据库 root 用户密码,生产环境建议修改这个值为复杂密码 | ``` database: # The password for the root user of Harbor DB. Change this before any production use. password: root123 ``` * `data_volume`: 由于 Harbor 所有组件都使用 docker 容器化部署,所以需要将容器数据持久化到宿主机目录,该配置项就是指定持久化目录的挂载点,建议在某目录下创建 `harbor` 文件夹,并作为挂载点,便于统一管理和迁移。 | ``` data_volume: /data/harbor ``` ### 执行 install.sh 开始安装 默认情况下,不带任何参数的 `install.sh` 脚本只安装 Harbor 主服务,如果需要安装其他附加服务,可带指定参数安装,可安装的附加服务有: | ``` Harbor with Notary ( --with-notary ):一个允许任何人信任任意数据集合的项目,用于运行和与可信集合交互。 Harbor with Clair (--with-clair): Docker 镜像安全漏洞扫描工具 Harbor with Chart Repository Service (--with-chartmuseum): Helm 包管理工具 ``` 这里我们安装带 Helm 包管理的 Harbor | ``` sudo ./install.sh --with-chartmuseum ``` ### 登录 harbor 并配置 Docker “insecure-registries” * Web UI 地址: `http://reg.atompi.com` * docker login 修改 docker daemon 配置文件 `/etc/docker/daemon.json` ,添加如下配置项: | ``` { "insecure-registries": ["reg.atompi.com"] } ``` docker 登录 registry ``` # docker login reg.atompi.com ```