harbor的镜像复制功能使用教程
環(huán)境
192.168.0.83是harbor01, 192.168.0.84是harbor02
每個(gè)harbor的域名是 harbor.youwoyouqu.io
進(jìn)行復(fù)制時(shí),harbor02會(huì)通過配置的主機(jī)名去認(rèn)證,去拉鏡像,所以在harbor中需要有這個(gè)域名的解析記錄。
基于之前搭建的harbor
解壓
scp harbor-offline-installer-v2.2.0.tgz 192.168.0.84: tar xvf harbor-offline-installer-v2.2.0.tgz -C /opt/復(fù)制配置
scp /opt/harbor/harbor.yml 192.168.0.84:/opt/harbor/ scp -rp /opt/cert/ 192.168.0.84:/opt啟動(dòng)
cd /opt/harbor ./install.sh編輯docker-compose.yaml
#在每個(gè)container_name: 同級(jí)添加可以解析harbor.yml的host字段的域名的dnsdns:- 192.168.0.77 # 此處添加能解析harbor.yml中的host的域名的dns docker-compose kill docker-compose rm -f docker-compose up -d界面配置復(fù)制
haproxy下線84
88 listen harbor-44389 bind 192.168.0.249:44390 mode tcp91 server 192.168.0.83 192.168.0.83:443 check inter 3s fall 2 rise 5 92 #server 192.168.0.84 192.168.0.84:443 check inter 3s fall 2 rise 5 root@haproxy01:~# systemctl restart haproxy84拉83
配置拉單個(gè)庫
復(fù)制管理 - 添加規(guī)則,由于之前83已經(jīng)有生產(chǎn)運(yùn)行一段時(shí)間的鏡像,所以先拉過來。
注意:先測試?yán)粋€(gè)庫,并且觸發(fā)為手動(dòng)
手工觸發(fā)復(fù)制
點(diǎn)162查看進(jìn)程,由于網(wǎng)速較快,已經(jīng)看到完成一個(gè)。
配置拉所有庫
手工
先讓觸發(fā)為手動(dòng),后期同步完了,再修改定時(shí),不然在同步周期內(nèi)同步不完,會(huì)一直啟動(dòng)進(jìn)程
現(xiàn)在才配置自動(dòng)
83拉84
一樣的新建倉庫,添加一個(gè)復(fù)制規(guī)則
compose配置
配置83的docker-compose和84一致
root@harbor01:~# scp 192.168.0.84:/opt/harbor/docker-compose.yml /opt/harbor/ root@harbor01:~# cd /opt/harbor/ root@harbor01:/opt/harbor# docker-compose kill root@harbor01:/opt/harbor# docker-compose rm -f Going to remove harbor-jobservice, nginx, harbor-core, redis, registry, registryctl, harbor-db, harbor-portal, harbor-log Removing harbor-jobservice ... done Removing nginx ... done Removing harbor-core ... done Removing redis ... done Removing registry ... done Removing registryctl ... done Removing harbor-db ... done Removing harbor-portal ... done Removing harbor-log ... done root@harbor01:/opt/harbor# docker-compose up -dhaproxy切換鏡像倉庫為84
88 listen harbor-443 89 bind 192.168.0.249:443 90 mode tcp 91 #server 192.168.0.83 192.168.0.83:443 check inter 3s fall 2 rise 5 92 server 192.168.0.84 192.168.0.84:443 check inter 3s fall 2 rise 5 root@haproxy01:~# systemctl restart haproxy正常推鏡像
root@master01:/data/weizhixiu/yaml/prometheus# docker push harbor.youwoyouqu.io/pub/grafana:7.4.3 The push refers to repository [harbor.youwoyouqu.io/pub/grafana] 31e37bf28d35: Layer already exists 0448b810b7f3: Layer already exists 0835354182ac: Layer already exists 8f0f1539b4c9: Layer already exists ff51b7928895: Layer already exists af0dc88d00a2: Layer already exists b76036dc8ce6: Layer already exists cb381a32b229: Layer already exists 7.4.3: digest: sha256:0baac55c486161598f0d263cd5c148cb45beeff0a311c7ee82800f7250fd4338 size: 2004網(wǎng)頁復(fù)制
添加規(guī)則
測試推送鏡像
haproxy指向
指向84
驗(yàn)證83沒有鏡像 pub/test
推送至鏡像
root@master01:/data/weizhixiu/yaml/prometheus# docker tag harbor.youwoyouqu.io/pub/grafana:7.4.3 harbor.youwoyouqu.io/pub/test:20210324 root@master01:/data/weizhixiu/yaml/prometheus# docker push harbor.youwoyouqu.io/pub/test:20210324 The push refers to repository [harbor.youwoyouqu.io/pub/test] 31e37bf28d35: Mounted from pub/grafana 0448b810b7f3: Mounted from pub/grafana 0835354182ac: Mounted from pub/grafana 8f0f1539b4c9: Mounted from pub/grafana ff51b7928895: Mounted from pub/grafana af0dc88d00a2: Mounted from pub/grafana b76036dc8ce6: Mounted from pub/grafana cb381a32b229: Mounted from pub/grafana 20210324: digest: sha256:0baac55c486161598f0d263cd5c148cb45beeff0a311c7ee82800f7250fd4338 size: 2004驗(yàn)證84倉庫
驗(yàn)證83倉庫
會(huì)有一定延遲,這個(gè)是因?yàn)橥绞?min一次的原因
配置haproxy
主備haproxy
由于推送有延遲,所以不建議直接負(fù)載均衡,所以haproxy上面使用主備即可
listen harbor-443 bind 192.168.0.249:443mode tcp + server 192.168.0.83 192.168.0.83:443 check inter 3s fall 2 rise 5 backupserver 192.168.0.84 192.168.0.84:443 check inter 3s fall 2 rise 5 root@haproxy01:~# systemctl restart haproxyrr輪循
這個(gè)harbor同步有一定延遲,直接負(fù)載均衡有可能在構(gòu)建鏡像推送數(shù)據(jù)后,在slave同步master完成前, 負(fù)載均衡的效果會(huì)有訪問不到資源的情況,一般推送鏡像后,就是更新kubernetes api, 各個(gè)kubelet,就算拉不到鏡像,一會(huì)會(huì)重新嘗試?yán)R像,所以不存在問題的。
listen harbor-443 bind 192.168.0.249:443mode tcpserver 192.168.0.83 192.168.0.83:443 check inter 3s fall 2 rise 5 server 192.168.0.84 192.168.0.84:443 check inter 3s fall 2 rise 5 root@haproxy01:~# systemctl restart haproxy參考鏈接:
http://blog.mykernel.cn/2021/03/24/harbor%E4%B8%BB%E4%BB%8E%E5%A4%8D%E5%88%B6/
https://blog.csdn.net/weixin_43557605/article/details/91653129
https://blog.csdn.net/weixin_43557605/article/details/91653129
總結(jié)
以上是生活随笔為你收集整理的harbor的镜像复制功能使用教程的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Ansible WebUI工具之Sema
- 下一篇: Django REST Framewor