Harbor部署

  1. harbor

无论是使用Docker-distribution去自建仓库,还是通过官方镜像跑容器的方式去自建仓库,通过前面的演示我们可以发现其是非常的简陋的,还不如直接使用官方的Docker Hub去管理镜像来得方便,至少官方的Docker Hub能够通过web界面来管理镜像,还能在web界面执行搜索,还能基于Dockerfile利用Webhooks和Automated Builds实现自动构建镜像的功能,用户不需要在本地执行docker build,而是把所有build上下文的文件作为一个仓库推送到github上,让Docker Hub可以从github上去pull这些文件来完成自动构建。但无论官方的Docker Hub有多强大,它毕竟是在国外,所以速度是最大的瓶颈,我们很多时候是不可能去考虑使用官方的仓库的,但是上面说的两种自建仓库方式又十分简陋,不便管理,所以后来就出现了一个被 CNCF 组织青睐的项目,其名为Harbor。

  1. harbor简介

Harbor是由VMWare在Docker Registry的基础之上进行了二次封装,加进去了很多额外程序,而且提供了一个非常漂亮的web界面。

Project Harbor是一个开源的可信云本地注册项目,用于存储、标记和扫描上下文。
Harbor扩展了开源Docker分发版,增加了用户通常需要的功能,如安全、身份和管理。
Harbor支持高级特性,如用户管理、访问控制、活动监视和实例之间的复制。

harbor的功能

功能:

  • 多租户内容签名和验证
  • 安全性和脆弱性分析
  • 审计日志记录
  • 身份集成和基于角色的访问控制
  • 实例之间的映像复制
  • 可扩展的API和图形用户界面
  • 国际化(目前为中英文)

  • docker compose

Harbor在物理机上部署是非常难的,而为了简化Harbor的应用,Harbor官方直接把Harbor做成了在容器中运行的应用,而且这个容器在Harbor中依赖类似redis、mysql、pgsql等很多存储系统,所以它需要编排很多容器协同起来工作,因此VMWare Harbor在部署和使用时,需要借助于Docker的单机编排工具(Docker compose)来实现。

Compose是一个用于定义和运行多容器Docker应用程序的工具。使用Compose,您可以使用一个YAML文件来配置应用程序的服务。然后,使用一个命令创建并启动配置中的所有服务。

  1. harbor部署
[root@slave ~]# dnf list all|grep docker-compose
docker-compose-plugin.x86_64                                      2.6.0-3.el8                                                docker-ce-stable
[root@slave ~]#
[root@slave ~]# hostnamectl set-hostname client
[root@slave ~]# bash
[root@client ~]# cd /etc/yum.repos.d/
[root@client yum.repos.d]# ls
CentOS-Stream-AppStream.repo         CentOS-Stream-RealTime.repo
CentOS-Stream-BaseOS.repo            docker-ce.repo
CentOS-Stream-Debuginfo.repo         epel-modular.repo
CentOS-Stream-Extras.repo            epel-playground.repo
CentOS-Stream-HighAvailability.repo  epel-testing-modular.repo
CentOS-Stream-Media.repo             epel-testing.repo
CentOS-Stream-PowerTools.repo        epel.repo
[root@client yum.repos.d]# scp docker-ce.repo 192.168.29.140:/etc/yum.repos.d/
The authenticity of host '192.168.29.140 (192.168.29.140)' can't be established.

ECDSA key fingerprint is SHA256:tGhqSo3u9wWuDd+55Xaw4UgDdkolb4FOhqKtT398KTA.

Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.29.140' (ECDSA) to the list of known hosts.

root@192.168.29.140's password:
docker-ce.repo                         100% 2261     2.8MB/s   00:00
[root@client yum.repos.d]#
打开另一台主机192.168.29.140
[root@master ~]# hostnamectl set-hostname harbor
[root@master ~]# bash
[root@harbor ~]# cd /etc/yum.repos.d/
[root@harbor yum.repos.d]# ls
CentOS-Base.repo  epel-modular.repo          epel-testing.repo
docker-ce.repo    epel-testing-modular.repo  epel.repo
[root@harbor yum.repos.d]# dnf -y install docker-ce
......

  python3-setools-4.3.0-2.el8.x86_64
  slirp4netns-1.1.8-1.module_el8.5.0+890+6b136101.x86_64

Complete!

[root@harbor yum.repos.d]# cd
[root@harbor ~]# ls -a
.               anaconda-ks.cfg
..              apr-1.7.0
.bash_history   apr-1.7.0.tar.gz
.bash_logout    apr-util-1.6.1
.bash_profile   apr-util-1.6.1.tar.gz
.bashrc         httpd-2.4.54
.config         httpd-2.4.54.tar.gz
.cshrc          mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz
.mysql_history  pass
.tcshrc         php-7.4.30
.viminfo        php-7.4.30.tar.xz
.wget-hsts
[root@harbor ~]# DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}
[root@harbor ~]# mkdir -p $DOCKER_CONFIG/cli-plugins
[root@harbor ~]# ls -a
.               .wget-hsts
..              anaconda-ks.cfg
.bash_history   apr-1.7.0
.bash_logout    apr-1.7.0.tar.gz
.bash_profile   apr-util-1.6.1
.bashrc         apr-util-1.6.1.tar.gz
.config         httpd-2.4.54
.cshrc          httpd-2.4.54.tar.gz
.docker         mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz
.mysql_history  pass
.tcshrc         php-7.4.30
.viminfo        php-7.4.30.tar.xz
[root@harbor ~]# ls .docker/
cli-plugins
[root@harbor ~]# curl -SL https://github.com/docker/compose/releases/download/v2.7.0/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose
[root@harbor cli-plugins]# ls
docker-compose
[root@harbor cli-plugins]# pwd
/root/.docker/cli-plugins
[root@harbor cli-plugins]#systemctl enable --now docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.

 [root@harbor cli-plugins]# chmod +x docker-compose
[root@harbor cli-plugins]# ll
total 25188
-rwxr-xr-x 1 root root 25792512 Aug 11 19:27 docker-compose
[root@harbor cli-plugins]# ln -s /root/.docker/cli-plugins/docker-compose  /usr/bin
[root@harbor cli-plugins]# cd
[root@harbor ~]# which docker-compose
/usr/bin/docker-compose
[root@harbor ~]# docker compose version
Docker Compose version v2.7.0
[root@harbor ~]# ls /usr/local/
bin  etc  games  include  lib  lib64  libexec  sbin  share  src
[root@harbor ~]# ls
anaconda-ks.cfg
apr-1.7.0
apr-1.7.0.tar.gz
apr-util-1.6.1
apr-util-1.6.1.tar.gz
harbor-offline-installer-v2.5.3.tgz
httpd-2.4.54
httpd-2.4.54.tar.gz
mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz
pass
php-7.4.30
php-7.4.30.tar.xz
[root@harbor ~]# tar xf harbor-offline-installer-v2.5.3.tgz -C /usr/local/
[root@harbor ~]# cd /usr/local/
[root@harbor local]# ls
apache  apr-util  etc    harbor   lib    libexec  php7  share
apr     bin       games  include  lib64  mysql    sbin  src
[root@harbor local]# cd harbor/
[root@harbor harbor]# ls
LICENSE    harbor.v2.5.3.tar.gz  install.sh
common.sh  harbor.yml.tmpl       prepare

[root@harbor harbor]# hostnamectl set-hostname harbor.example.com
[root@harbor harbor]# bash
[root@harbor harbor]# hostname
harbor.example.com
[root@harbor harbor]# cp harbor.yml.tmpl harbor.yml
[root@harbor harbor]# vim harbor.yml
hostname: harbor.example.com

#https:(注释这一栏)
  # https port for harbor, default is 443
  # port: 443(注释这一栏)
The path of cert and key files for nginx
  #certificate: /your/certificate/path(注释这一栏)
  #private_key: /your/private/key/path(注释这一栏)
[root@harbor harbor]# ls
LICENSE    harbor.v2.5.3.tar.gz  harbor.yml.tmpl  prepare
common.sh  harbor.yml            install.sh
[root@harbor harbor]# ./install.sh

[Step 0]: checking if docker is installed ...

Note: docker version: 20.10.17

[Step 1]: checking docker-compose is installed ...

Note: docker-compose version: 2.7.0
......

 ? Container nginx              Started                                         5.1s
 ? Container harbor-jobservice  Started                                         5.0s
? ----Harbor has been installed and started successfully.----
[root@harbor harbor]# ss -antl
State    Recv-Q   Send-Q      Local Address:Port       Peer Address:Port   Process
LISTEN   0        128             127.0.0.1:9000            0.0.0.0:*
LISTEN   0        128             127.0.0.1:1514            0.0.0.0:*
LISTEN   0        128               0.0.0.0:80              0.0.0.0:*
LISTEN   0        128               0.0.0.0:22              0.0.0.0:*
LISTEN   0        128                  [::]:80                 [::]:*
LISTEN   0        128                  [::]:22                 [::]:*
[root@harbor harbor]#

Harbor部署
Harbor部署

使用Harbor的注意事项:

  • 在客户端上传镜像时一定要记得执行docker login进行用户认证,否则无法直接push
  • 在客户端使用的时候如果不是用的https则必须要在客户端的/etc/docker/daemon.json配置文件中配置insecure-registries参数
  • 数据存放路径应在配置文件中配置到一个容量比较充足的共享存储中
  • Harbor是使用docker-compose命令来管理的,如果需要停止Harbor也应用docker-compose stop来停止,其他参数请–help

  • Harbor应用

`bash
[root@harbor ~]# hostname
harbor.example.com
[root@client ~]# ping harbor.example.com
ping: harbor.example.com: Name or service not known
[root@client ~]# vim /etc/hosts
192.168.29.140 harbor.example.com
[root@client ~]# ping harbor.example.com
PING harbor.example.com (192.168.29.140) 56(84) bytes of data.

64 bytes from harbor.example.com (192.168.29.140): icmp_seq=1 ttl=64 time=1.47 ms
64 bytes from harbor.example.com (192.168.29.140): icmp_seq=2 ttl=64 time=0.245 ms
64 bytes from harbor.example.com (192.168.29.140): icmp_seq=3 ttl=64 time=4.33 ms
^C

Original: https://www.cnblogs.com/marymary/p/16578408.html
Author: 溜溜威
Title: Harbor部署

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/581541/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

  • Python 获取字典中的第一个键

    提供两种方法: 使用 list 将字典的 key 转换成列表,然后取第一个元素 [0]。如果想要最后一个 key 的话,就取最后一个元素 [-1]。 >>> my…

    Linux 2023年6月7日
    070
  • ASP.NET Core 2.2 : 二十二. 多样性的配置方式

    大多数应用都离不开配置,本章将介绍ASP.NET Core中常见的几种配置方式及系统内部实现的机制。(ASP.NET Core 系列目录) 说到配置,第一印象可能就是”…

    Linux 2023年6月7日
    0102
  • 更新yum 源下载报错

    entos7.9 更换yum 源 为阿里云的之后,下载软件包报错 Failed connect to mirrors.aliyuncs.com:80; Connection tim…

    Linux 2023年6月14日
    079
  • SpringBoot-swagger

    SpringBoot整合swagger SpringBoot-swagger 13.1 导入相关依赖 io.springfox springfox-swagger-ui 2.9.2…

    Linux 2023年6月14日
    086
  • 【电台谈心】2022罗翔老师回答毕业生的4个问题

    罗翔老师:谢谢这位同学的问题。我回想起自己找工作的经历,其实也是 一地鸡毛。本科毕业的时候,也没有多少招聘会。我只有一个单位,一个单位地去找。少数几家单位让你进去了,聊了聊又觉得你…

    Linux 2023年6月13日
    0106
  • CentOS7安装redis并配置外网可访问(局域网可参考)

    1、安装gcc编辑器 安装redis需要依赖gcc环境,执行如下命令安装: yum install -y gcc 如果机器没有…

    Linux 2023年5月28日
    098
  • CSS解决父级边框坍塌的问题

    首先在父级标签内添加如下 标签 然后在CSS中对该标签进行如下修饰: #clear{ clear:both; margin:0px; padding: 0px; } 优点:简单。缺…

    Linux 2023年6月13日
    091
  • 如何隐藏shell脚本内容

    从事 Linux 开发的同学,经常需要编写 shell 脚本,有时脚本中会涉及到一些敏感内容,比如一些 IP 地址,用户名以及密码等,或者脚本中有一些关键的代码, 所有这些内容你都…

    Linux 2023年6月13日
    089
  • jmeter 安装与环境变量配置

    安装jmeter首先要安装与jmeter版本兼容的JDK,安装完成JDK后才能安装jmeter,JDK可以自行在官网下载或者通过360软件管家进行下载。 1、下载安装JDK 安装完…

    Linux 2023年6月8日
    088
  • USB转多串口产品设计

    在部分应用场合下需要为计算机或其他主机扩展多个串口,常见的扩展方式有USB转多串、PCI/PCIe转多串、蓝牙和以太网等网络转多串口。现在大多数台式计算机和笔记本电脑出于轻型化需要…

    Linux 2023年6月7日
    083
  • chmod 报错 changing permissions of ‘xxx’: Operation not permitted

    chmod的底层实现是 chattr命令,用此命的功能更为强大,甚至可以锁定文件,即使root用户也操作不了此文件。 先使用lsattr查看文件属性 `bashlsattr tem…

    Linux 2023年6月13日
    089
  • Linux netstat:查看网络状态

    netstat 主要用于网络监控,在进程管理方面也很重要。它的输出分为两大部分,分别是网络和系统自己的进程相关性部分。 netstat [-atunlp] -a 列出目前系统上所有…

    Linux 2023年6月13日
    089
  • redis 使用lua 生成流水号

    在实际的业务场景中,我们会用到流水号。之前的流水号做法是,使用redis的全局锁。然后对数据库进行更新,数据库更新 这个也会有一些问题,比如对于同一个流水号,多个线程去更新,由于事…

    Linux 2023年5月28日
    084
  • supervisord 进程管理利器

    Supervisor概述 ​ supervisor是一个 Client/Server模式的系统,允许用户在类unix操作系统上监视和控制多个进程,或者可以说是多个程序。superv…

    Linux 2023年5月27日
    090
  • 代码规范浅谈

    代码规范这东西网上很容易百度到一堆,除了天下文章一大抄的问题,另外,多数只给了结果,原因没有充分说明,或者非常的纠结于大写小写,一个函数可以写几行的细节。感觉有点容易让新人误入歧途…

    Linux 2023年6月13日
    089
  • 复杂任务中,流程的解耦设计

    做事不能急,得一步异步的来; 一、业务场景 在系统开发的过程中,必然存在耗时极高的动作,是基于请求响应模式无法解决的问题,通常会采用解耦的思维,并基于异步或者事件驱动的方式去调度整…

    Linux 2023年6月14日
    069
亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球