日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

harbor的镜像复制功能使用教程

發布時間:2025/1/21 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 harbor的镜像复制功能使用教程 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

環境

192.168.0.83是harbor01, 192.168.0.84是harbor02

每個harbor的域名是 harbor.youwoyouqu.io

進行復制時,harbor02會通過配置的主機名去認證,去拉鏡像,所以在harbor中需要有這個域名的解析記錄。

基于之前搭建的harbor

解壓

scp harbor-offline-installer-v2.2.0.tgz 192.168.0.84: tar xvf harbor-offline-installer-v2.2.0.tgz -C /opt/

復制配置

scp /opt/harbor/harbor.yml 192.168.0.84:/opt/harbor/ scp -rp /opt/cert/ 192.168.0.84:/opt

啟動

cd /opt/harbor ./install.sh

編輯docker-compose.yaml

#在每個container_name: 同級添加可以解析harbor.yml的host字段的域名的dnsdns:- 192.168.0.77 # 此處添加能解析harbor.yml中的host的域名的dns docker-compose kill docker-compose rm -f docker-compose up -d

界面配置復制

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 haproxy

84拉83

配置拉單個庫

復制管理 - 添加規則,由于之前83已經有生產運行一段時間的鏡像,所以先拉過來。

注意:先測試拉一個庫,并且觸發為手動

手工觸發復制

點162查看進程,由于網速較快,已經看到完成一個。

配置拉所有庫

手工

先讓觸發為手動,后期同步完了,再修改定時,不然在同步周期內同步不完,會一直啟動進程

現在才配置自動

83拉84

一樣的新建倉庫,添加一個復制規則

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 -d

haproxy切換鏡像倉庫為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

網頁復制

添加規則

測試推送鏡像

haproxy指向

指向84

驗證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

驗證84倉庫

驗證83倉庫

會有一定延遲,這個是因為同步是1min一次的原因

配置haproxy

主備haproxy

由于推送有延遲,所以不建議直接負載均衡,所以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 haproxy

rr輪循

這個harbor同步有一定延遲,直接負載均衡有可能在構建鏡像推送數據后,在slave同步master完成前, 負載均衡的效果會有訪問不到資源的情況,一般推送鏡像后,就是更新kubernetes api, 各個kubelet,就算拉不到鏡像,一會會重新嘗試拉鏡像,所以不存在問題的。

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

總結

以上是生活随笔為你收集整理的harbor的镜像复制功能使用教程的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。