安装harbor仓库

1.安装docker-compose
 curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
 chmod +x /usr/local/bin/docker-compose
 ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
 docker-compose --version
 wget http://36.134.8.95:8001/harbor2.0.tar.gz
 tar xf harbor2.0.tar.gz -C /data/scripts/
 cd /data/scripts/harbor
 cp harbor.yml.tmpl harbor.yml
[root@zhyly-test-003 harbor]#  egrep -v '^$|^#| #' harbor.yml   #更改配置文件
hostname: 192.168.2.28 
http:
  port: 8090
harbor_admin_password: 12345
database:
  password: root123
  max_idle_conns: 100
  max_open_conns: 900
data_volume: /data/harbor
trivy:
  ignore_unfixed: false
  skip_update: false
  insecure: false
jobservice:
  max_job_workers: 10
notification:
  webhook_job_max_retry: 10
chart:
  absolute_url: disabled
log:
  level: info
  local:
    rotate_count: 50
    rotate_size: 200M
    location: /var/log/harbor
_version: 2.3.0
proxy:
  http_proxy:
  https_proxy:
  no_proxy:
  components:
    - core
    - jobservice
    - trivy

 mkdir /data/harbor  #创建数据目录
 ./install.sh        #安装
 ss -lntup |grep 8090 #检查端口



2.配置nginx代理
[root@zhyly-pre-003 4-layer-conf.d]# tail -10 zhylydev.conf 
#代理zhyly的harbor服务
upstream zhyly-harbor {
    server 192.168.2.28:8090;
    }

    server {
        listen  30009;
            proxy_pass zhyly-harbor;
            }
            
[root@zhyly-pre-003 4-layer-conf.d]# ss -lntup |grep 30009
tcp    LISTEN     0      511       *:30009                 *:*                   users:(("nginx",pid=25017,fd=6),("nginx",pid=25016,fd=6),("nginx",pid=25015,fd=6),("nginx",pid=25014,fd=6),("nginx",pid=8730,fd=6))

#浏览器访问:36.134.185.184:30009/   admin  12345  添加需要用到的镜像仓库


K8S节点修改/etc/docker/daemon.json并reload docker #注意是reload 不要restart,会导致K8S容器重启,造成服务不可用,把当前pod使用的镜像推送到新的harbor,避免重启之后拉取镜像失败

systemctl reload docker

docker login 仓库地址 
登录harbor仓库,(系统会保存登录信息)
posted @ 2022-11-02 10:02  安生丶  阅读(38)  评论(0编辑  收藏  举报