harbor的安装

官方文档
https://goharbor.io/docs/2.5.0/install-config/download-installer/

一、下载harbor包 放入/opt 解压 复制配置文件并编辑

下载地址
https://github.com/goharbor/harbor/releases

[root@harbor-01 harbor]# ll
total 594388
-rw-r--r-- 1 root root      3361 Aug 18  2021 common.sh
-rw-r--r-- 1 root root 608611132 Aug 18  2021 harbor.v2.3.2.tar.gz
-rw-r--r-- 1 root root      7838 Jul  8 17:28 harbor.yml
-rw-r--r-- 1 root root      7840 Aug 18  2021 harbor.yml.tmpl
-rwxr-xr-x 1 root root      2500 Aug 18  2021 install.sh
-rw-r--r-- 1 root root     11347 Aug 18  2021 LICENSE
-rwxr-xr-x 1 root root      1881 Aug 18  2021 prepare
[root@harbor-01 harbor]# cp harbor.yml.tmpl harbor.yml
[root@harbor-01 harbor]# vim harbor.yml

修改配置文件
hostname: 192.168.234.201

# http related config
http:
  # port for http, default is 80. If https enabled, this port will redirect to https port
  port: 80

harbor_admin_password: 123456

配置文件其他部分暂时不用改

二、解决安装harbor所需的环境并安装harbor

[root@harbor-01 harbor]# ./install.sh

[Step 0]: checking if docker is installed ...

Note: docker version: 20.10.17

[Step 1]: checking docker-compose is installed ...
✖ Need to install docker-compose(1.18.0+) by yourself first and run this script again.
[root@harbor-01 harbor]#

安装docker和docker-compose

docker的安装

docker官方文档(我用的centos)
https://docs.docker.com/engine/install/centos/
安装步骤
#复制安装

 yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine
 yum install -y yum-utils
 yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo
yum install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin

查看docker的状态

docker-compose的安装

因为安装docker的时候安装了docker-compose
所以只需要docker compose的可执行程序
下载地址
https://github.com/docker/compose/releases/tag/v2.6.1
下载docker-compose-linux-x86_64 二进制没有执行权限

[root@harbor-01 harbor]# cp docker-compose-linux-x86_64 /usr/sbin/docker-compose
[root@harbor-01 harbor]# cp docker-compose-linux-x86_64 /usr/bin/docker-compose
[root@harbor-01 harbor]# chmod a+x /usr/sbin/docker-compose /usr/bin/docker-compose

http的设置修改私有仓库

vim /usr/lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd -H fd://  --containerd=/run/containerd/containerd.sock --insecure-registry 192.168.234.51

或者
# cat /etc/docker/daemon.json
{
  "insecure-registries": ["192.168.234.51"]
}

启动docker并开机启动

[root@harbor-01 harbor]# systemctl daemon-reload 
[root@harbor-01 harbor]# systemctl start docker 
[root@harbor-01 harbor]# systemctl enable docker

增加扫描器、Helm仓库及notary功能

要使用 Notary 进行安装,您必须将 Harbor 配置为使用 HTTPS。

Harbor v2.1 及之前的版本内置了 Clair 镜像扫描器,在 v2.2 中,Harbor使用了 Aqua Trivy 作为缺省扫描器。

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

安装harbor

查看harbor

登录harbor