部署高可用Harbor仓库和使用

DevOps

2020-06-03

92

0

 第一步:(前提已经运行docker)

下载harbor二进制文件:https://github.com/goharbor/harbor/releases 

[root@10-41-52-186 ~]# wget https://github.com/goharbor/harbor/releases/download/v2.0.0/harbor-offline-installer-v2.0.0.tgz

第二步:安装 docker compose
命令:
sudo curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
然后把下载的docker-compose 设置可执行权限
命令:chmod +x /usr/local/bin/docker-compose
 
第三步:解压缩
[root@10-41-52-186 ~]# tar zxvf harbor-offline-installer-v2.0.0.tgz
[root@10-41-52-186 ~]# cd harbor/
[root@10-41-52-186 harbor]# ll
total 491056
-rw-r--r-- 1 root root 3361 May 11 18:47 common.sh
-rw-r--r-- 1 root root 502808042 May 11 18:48 harbor.v2.0.0.tar.gz
-rw-r--r-- 1 root root 7816 May 11 18:47 harbor.yml.tmpl
-rwxr-xr-x 1 root root 2523 May 11 18:47 install.sh
-rw-r--r-- 1 root root 11347 May 11 18:47 LICENSE
-rwxr-xr-x 1 root root 1856 May 11 18:47 prepare
第四步:修改配置文件
[root@10-41-52-186 harbor]# cp harbor.yml.tmpl harbor.yml
[root@10-41-52-186 harbor]# cat harbor.yml
第五步:部署安装
[root@10-41-52-186 harbor]# ./prepare
 
Successfully called func: create_root_cert
Generated configuration file: /compose_location/docker-compose.yml
Clean up the input dir
[root@10-41-52-186 harbor]#
 安装中。。。
[root@10-41-52-186 harbor]# ./install.sh
 
[Step 0]: checking if docker is installed ...
 
[Step 1]: checking docker-compose is installed ...
 
[Step 2]: loading Harbor images ...
[Step 3]: preparing environment ...
[Step 4]: preparing harbor configs ...
[Step 5]: starting Harbor ...
 
✔ ----Harbor has been installed and started successfully.----
[root@10-41-52-186 harbor]#
 
可见,已经安装完成,进行登陆验证。
 
登陆完成,进行配置harbor项目和用户。
 
HA高可用,再安装一台harbor,并验证harbor登陆
创建一个项目名与主harbor一致,
如新建nginx

在主harbor服务器配置同步测试:

点击复制规则:

主harbor编辑同步策略:

 

主harbor查看镜像同步状态:

从harbor查看镜像:

 

推送命令
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Docker 推送命令
[root@test79-1 jks-dk]# docker images   #查看镜像
REPOSITORY TAG IMAGE ID CREATED SIZE
goharbor/chartmuseum-photon v2.0.0 4db8d6aa63e9 3 weeks ago 127MB
goharbor/redis-photon v2.0.0 c89ea2e53cc0 3 weeks ago 72.2MB
goharbor/trivy-adapter-photon v2.0.0 6122c52b7e48 3 weeks ago 103MB
goharbor/clair-adapter-photon v2.0.0 dd2210cb7f53 3 weeks ago 62MB
#把已下载好的镜像拷贝到harbor上
[root@test79-1 jks-dk]# docker tag goharbor/chartmuseum-photon:v2.0.0 172.16.174.142/s_admin/c-p:v2.0.0
Login Succeeded
[root@test79-1 jks-dk]#
[root@test79-1 jks-dk]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
goharbor/chartmuseum-photon v2.0.0 4db8d6aa63e9 3 weeks ago 127MB
172.16.174.142/s_admin/c-p v2.0.0 4db8d6aa63e9 3 weeks ago 127MB
goharbor/redis-photon v2.0.0 c89ea2e53cc0 3 weeks ago 72.2MB
[root@test79-1 jks-dk]# docker push 172.16.174.142/s_admin/c-p:v2.0.0
The push refers to repository [172.16.174.142/s_admin/c-p]
7f7c81a33722: Pushed
4b801e4d76d7: Pushed
a181769f3c52: Pushed
eef8d67e9248: Pushed
935e17d700d1: Pushed
dbaf2c918102: Pushed
v2.0.0: digest: sha256:9845a24d6c0575f4fee760a083b1c63f3f1bc122ea18bb753a00701d577006c3 size: 1578
[root@test79-1 jks-dk]# 

发表评论

全部评论:0条

lmy233

努力工作学习生活的人呐~~

联系方式

神圣之子仅供学习交流
E-mail:limengyu233@163.com
github:https://github.com/lmy01