harbor

harbor2.0安装文档

2025-01-06  本文已影响0人  彩色的炮灰

写在前面

Harbor 教程:https://www.hxstrive.com/subject/harbor/3126.htm

harbor默认管理员账号:admin
harbor默认管理员密码:Harbor12345

准备

1、更新yum repo,使用阿里云源。

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

image.png
curl -o /etc/yum.repos.d/CentOS-Base.repo http:``//[mirrors.aliyun.com/repo/Centos-7.repo](http://mirrors.aliyun.com/repo/Centos-7.repo)

image.png image.png image.png

开始安装Harbor ,安装方式有两种:

1、从 Harbor 官方网站(https://github.com/goharbor/harbor/releases)下载合适版本的 Harbor 离线安装包。例如,下载 harbor-offline-installer-v1.10.19.tgz,如下图:

image.png

1、登录服务器,今入/opt 目录。

wget https://github.com/goharbor/harbor/releases/download/v2.0.0/harbor-offline-installer-v2.0.0.tgz

image.png image.png

3、由于 Harbor 是基于 Docker 和 Docker Compose 的,所以需要先安装它们:

sudo yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

image.png
sudo yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin

image.png
<pre>{
    "registry-mirrors": [ "https://docker.m.daocloud.io" ]
}

systemctl restart docker    #重启docker服务
systemctl enable docker      #配置开机自启

4、安装 docker-compose

[root@localhost docker]# sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
100 60.8M  100 60.8M    0     0  58552      0  0:18:09  0:18:09 --:--:-- 71641

<pre>[root@localhost bin]# sudo chmod +x /usr/local/bin/docker-compose</pre>

<pre>[root@localhost ~]# docker-compose --version
Docker Compose version v2.29.7

5、解压harbor安装包:

[root@localhost opt]# tar -xvzf harbor-offline-installer-v2.0.0.tgz 
harbor/harbor.v2.0.0.tar.gz
harbor/prepare
harbor/LICENSE
harbor/install.sh
harbor/common.sh
harbor/harbor.yml.tmpl

6、配置harobr

[root@localhost harbor]# cp harbor.yml.tmpl harbor.yml

7、安装 Harbor
执行 prepare 脚本
在 Harbor 安装过程中,prepare 脚本是一个非常重要的步骤。它主要用于生成配置文件和证书等相关操作。这个脚本会根据 harbor.yml 配置文件中的内容,为 Harbor 的部署做前置准备工作。例如:

[root@localhost harbor]# ./prepare
prepare base dir is set to /opt/harbor
Unable to find image 'goharbor/prepare:v2.0.0' locally
v2.0.0: Pulling from goharbor/prepare
836b6c765c93: Pull complete 
7d2118468cd6: Pull complete 
ec361edd3da3: Pull complete 
96018abb76c1: Pull complete 
93a6102d0a5d: Pull complete 
5ee1acfc0e3d: Pull complete 
2b88cfa69516: Pull complete 
5081e058f91e: Pull complete 
Digest: sha256:529596e839c481354f9652b3f598b0aa634c57015840d047295dc65a27ffd880
Status: Downloaded newer image for goharbor/prepare:v2.0.0
WARNING:root:WARNING: HTTP protocol is insecure. Harbor will deprecate http protocol in the future. Please make sure to upgrade to https
Generated configuration file: /config/log/logrotate.conf
Generated configuration file: /config/log/rsyslog_docker.conf
Generated configuration file: /config/nginx/nginx.conf
Generated configuration file: /config/core/env
Generated configuration file: /config/core/app.conf
Generated configuration file: /config/registry/config.yml
Generated configuration file: /config/registryctl/env
Generated configuration file: /config/registryctl/config.yml
Generated configuration file: /config/db/env
Generated configuration file: /config/jobservice/env
Generated configuration file: /config/jobservice/config.yml
Generated and saved secret to file: /data/secret/keys/secretkey
Successfully called func: create_root_cert
Generated configuration file: /compose_location/docker-compose.yml
Clean up the input dir

没有抛出错误信息,脚本执行成功。

8、执行 install 脚本

Harbor 的 install.sh 脚本是 Harbor 安装过程的核心脚本。它主要负责协调各个组件的安装和配置过程,将 Harbor 从一个未安装的状态转变为一个可以正常运行的服务。例如:

[图片上传失败...(image-326065-1736219367989)]

[图片上传失败...(image-5f9653-1736219367989)]

如果你看见了“✔ ----Harbor has been installed and started successfully.----”提示信息,恭喜 harbor 安装成功了。

image.png

9、验证安装

[root@localhost harbor]# docker ps
CONTAINER ID   IMAGE                                COMMAND                  CREATED              STATUS                        PORTS                                   NAMES
cf46c586e77e   goharbor/harbor-jobservice:v2.0.0    "/harbor/entrypoint.…"   About a minute ago   Up About a minute (healthy)                                           harbor-jobservice
c8c3975a3282   goharbor/nginx-photon:v2.0.0         "nginx -g 'daemon of…"   About a minute ago   Up About a minute (healthy)   0.0.0.0:80->8080/tcp, :::80->8080/tcp   nginx
744350d97f9e   goharbor/harbor-core:v2.0.0          "/harbor/entrypoint.…"   About a minute ago   Up About a minute (healthy)                                           harbor-core
c4775a51d596   goharbor/harbor-db:v2.0.0            "/docker-entrypoint.…"   About a minute ago   Up About a minute (healthy)   5432/tcp                                harbor-db
5734fa2f4160   goharbor/registry-photon:v2.0.0      "/home/harbor/entryp…"   About a minute ago   Up About a minute (healthy)   5000/tcp                                registry
76c74bfd888a   goharbor/redis-photon:v2.0.0         "redis-server /etc/r…"   About a minute ago   Up About a minute (healthy)   6379/tcp                                redis
c5dc3de65384   goharbor/harbor-portal:v2.0.0        "nginx -g 'daemon of…"   About a minute ago   Up About a minute (healthy)   8080/tcp                                harbor-portal
fc62007f988c   goharbor/harbor-registryctl:v2.0.0   "/home/harbor/start.…"   About a minute ago   Up About a minute (healthy)                                           registryctl
1296a7931f10   goharbor/harbor-log:v2.0.0           "/bin/sh -c /usr/loc…"   About a minute ago   Up About a minute (healthy)   127.0.0.1:1514->10514/tcp               harbor-log
[root@localhost harbor]# 

上面显示了所有 goharbor 相关的容器。

10、使用浏览器访问 http://xxx.xxx.102.15:80 地址,如下图:

image.png

11、账号密码

默认管理员账号:admin
默认管理员密码:Harbor12345


image.png

镜像上传:

1、新建项目【test-1】

image.png

2、点击镜像仓库,可以看到下载和推送命令。

image.png

3、创建用户
账号:test-1
密码:********

image.png

4、项目中添加成员

image.png

5、在本机配置harbor仓库http可信

6、登录私有镜像仓库

docker login xx.xx.102.15 -u test-1 -p *******
image.png

7、拉取公共镜像httpd

docker tag httpd:latest 172.16.102.15/test-1/httpd:latest
image.png
docker push 172.16.102.15/test-1/REPOSITORY[:TAG]
image.png

8、退出harbor私有镜像仓库登录

image.png
上一篇 下一篇

猜你喜欢

热点阅读