其他分享
首页 > 其他分享> > Docker之分布式仓库Harbor部署

Docker之分布式仓库Harbor部署

作者:互联网

一  Harbor介绍

1.1 Harbor介绍

Harbor是一个用于存储和分发docker镜像的企业级Registry服务器,由VMware开源,其通过添加一些企业必需的功能特性,例如安全、标识和管理等,扩展了开源Docker Distrubution,作为一个企业级私有Registry服务器,Harbor提供了更好的性能和安全。提升了用户使用Registry构建和运行环境传输镜像的效率。Harbor支持安装在多个Registry节点的镜像资源复制,镜像全部保存在私有Registry中,确保数据和知识产权在公司内部网络中管理,另外,Harbor也提供了高级的安全特性,诸如用户管理,访问控制和活动审计等。

vmware 官方开源服务:https://vmware.github.io

harbor 官方github地址:https://github.com/goharbor/harbor

harbor 官方网址: https://goharbor.io

harbor 官方文档: https://goharbor.io

github文档:https://goharbor.io/docs/2.4.0/

1.2 Harbor功能官方介绍

1.3 Harbor组成

二 环境准备

2.1 部署规划

类型 IP 主机名称 备注
harbor-01 192.168.75.157 node01  

2.2 时间同步

root@node01:~# apt -y install chrony
root@node01:~# systemctl enable chrony
root@node01:~# systemctl restart chrony

2.3 安装docker

点击查看代码
root@node01:~# apt-get -y install apt-transport-https ca-certificates curl software-properties-common
root@node01:~# curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
root@node01:~# add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
root@node01:~# apt update
root@node01:~# apt-get -y install docker-ce
root@node01:/opt# docker version
Client: Docker Engine - Community
 Version:           20.10.10
 API version:       1.41
 Go version:        go1.16.9
 Git commit:        b485636
 Built:             Mon Oct 25 07:42:59 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
Engine:
Version: 20.10.10
API version: 1.41 (minimum version 1.12)
Go version: go1.16.9
Git commit: e2f740d
Built: Mon Oct 25 07:41:08 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.4.11
GitCommit: 5b46e404f6b9f661a205e28d59c982d3634148f8
runc:
Version: 1.0.2
GitCommit: v1.0.2-0-g52b36a2
docker-init:
Version: 0.19.0
GitCommit: de40ad0

2.4 安装docker-compose

root@node02:/opt# wget https://github.com/docker/compose/releases/download/v2.1.0/docker-compose-linux-x86_64
root@node02:/opt# mv docker-compose-linux-x86_64 /usr/local/sbin/docker-compose
root@node02:/opt# chmod +x /usr/local/sbin/docker-compose
root@node02:/opt# docker-compose -v
Docker Compose version v2.1.0

三 harbor安装

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

安装文档:https://github.com/goharbor/harbor/blob/master/docs/install-config/_index.md

3.1 下载harbor安装包

3.1.1 下载离线安装包

推荐使用离线安装包

root@node01:~# cd /opt/
root@node01:/opt# wget https://github.com/goharbor/harbor/releases/download/v1.10.9/harbor-offline-installer-v1.10.9.tgz

3.1.2 下载在线安装包

 不推荐在线安装

root@node01:~# cd /opt/
root@node01:/opt# wet https://github.com/goharbor/harbor/releases/download/v1.10.9/harbor-online-installer-v1.10.9.tgz

3.2 配置harbor

3.2.1 解压harbor

root@node01:/opt# tar xf harbor-offline-installer-v1.10.9.tgz -C /usr/local/
root@node01:~# ls -l /usr/local/harbor/
total 585880
-rw-r--r-- 1 root root     11347 Oct 28 13:24 LICENSE
-rw-r--r-- 1 root root      3398 Oct 28 13:24 common.sh
-rw-r--r-- 1 root root 599900167 Oct 28 13:25 harbor.v1.10.9.tar.gz
-rw-r--r-- 1 root root      5882 Oct 28 13:24 harbor.yml
-rwxr-xr-x 1 root root      2284 Oct 28 13:24 install.sh
-rwxr-xr-x 1 root root      1749 Oct 28 13:24 prepare

3.2.2 编辑配置文件

官方配置文档:https://goharbor.io/docs/1.10/install-config/

root@node01:~# vim /usr/local/harbor/harbor.yml 
hostname: 192.168.75.157    #修改此行,指向当前主机IP或FQDN  
http:
  # port for http, default is 80. If https enabled, this port will redirect to https port
  port: 80

#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: Harbor12345
database:
  # The password for the root user of Harbor DB. Change this before any production use.
  password: root123
  # The maximum number of connections in the idle connection pool. If it <=0, no idle connections are retained.
  max_idle_conns: 50
  # The maximum number of open connections to the database. If it <= 0, then there is no limit on the number of open connections.
  # Note: the default number of connections is 100 for postgres.
  max_open_conns: 100
data_volume: /data/harbor

3.2.3 运行安装脚本

运行install.sh, 注意运行时加上--with-clair 选项,启动clair镜像扫描功能。
ChartMuseum是一个用Go(Golang)编写的开源Helm Chart Repository服务器。

点击查看代码
root@node01:~# mkdir -pv /data/harbor
root@node01:~# mkdir -pv /var/log/harbor
root@node01:~# /usr/local/harbor/install.sh  --with-clair --with-chartmuseum

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

Note: docker version: 20.10.10

[Step 1]: checking docker-compose is installed ...

Note: docker-compose version: 2.1.0

[Step 2]: loading Harbor images ...
Loaded image: goharbor/harbor-core:v1.10.9
Loaded image: goharbor/harbor-jobservice:v1.10.9
Loaded image: goharbor/notary-signer-photon:v1.10.9
Loaded image: goharbor/nginx-photon:v1.10.9
Loaded image: goharbor/chartmuseum-photon:v1.10.9
Loaded image: goharbor/registry-photon:v1.10.9
Loaded image: goharbor/clair-photon:v1.10.9
Loaded image: goharbor/clair-adapter-photon:v1.10.9
Loaded image: goharbor/prepare:v1.10.9
Loaded image: goharbor/harbor-portal:v1.10.9
Loaded image: goharbor/harbor-db:v1.10.9
Loaded image: goharbor/notary-server-photon:v1.10.9
Loaded image: goharbor/harbor-log:v1.10.9
Loaded image: goharbor/harbor-registryctl:v1.10.9
Loaded image: goharbor/redis-photon:v1.10.9

[Step 3]: preparing environment ...

[Step 4]: preparing harbor configs ...
prepare base dir is set to /usr/local/harbor
/usr/src/app/utils/configs.py

标签:node01,goharbor,Harbor,config,harbor,Docker,root,docker,分布式
来源: https://www.cnblogs.com/wangguishe/p/15466771.html