Install Harbor 2.8 on Centos

news2024/11/17 14:51:38

目录

Node & System/Software Lists

Architecture Overview of Harbor

Install Harbor 2.8

Harbor Installation Prerequisites

Install Docker and Docker Compose

Install Harbor

Pull and Push image from Harbor

Reference documentation 


Node & System/Software Lists

HOSTNAME

IPNODE TYPECONFIG
master1192.168.1.100harbor server4vCPU4G
SystemVersion

kernel
3.10.0-1160.el7.x86_64
centosCentOS Linux release 7.9.2009 (Core)
Software NameVersion
docker24.0.2
docker composev2.18.1
harborv2.8.1

Architecture Overview of Harbor

With Harbor V2.0, users can manage images, manifest lists, Helm charts, CNABs, OPAs among others which all adhere to the OCI image specification.You can read more here[1].

Install Harbor 2.8

Here we start to install Harbor 2.8 on the target host.following below steps and get Harold installed:

  1. Harbor Installation Prerequisites
  2. Install Docker and Docker Compose
  3. Install Harbor
  4. Pull and Push image from Harbor

Harbor Installation Prerequisites

Harbor is deployed as several Docker containers. You can therefore deploy it on any Linux distribution that supports Docker. The target host requires Hardware,Software,Network ports show like below.

Hardware

ResourceMinimumRecommended
CPU2 CPU4 CPU
Mem4 GB8 GB
Disk40 GB160 GB

Software 

SoftwareVersionDescription
Docker EngineVersion 17.06.0-ce+ or higherFor installation instructions, see Docker Engine documentation
Docker Composedocker-compose (v1.18.0+) or docker compose v2 (docker-compose-plugin)For installation instructions, see Docker Compose documentation
OpenSSLLatest is preferredUsed to generate certificate and keys for Harbor

Network ports

PortProtocolDescription
443HTTPSHarbor portal and core API accept HTTPS requests on this port.
4443HTTPSConnections to the Docker Content Trust service for Harbor. Only required if Notary is enabled. 
80HTTPHarbor portal and core API accept HTTP requests on this port. 

Install Docker and Docker Compose

You can copy and run all there shell commands and get docker components and docker-compose:

sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo systemctl start docker
sudo systemctl enable docker
sudo curl -SL https://github.com/docker/compose/releases/download/v2.18.1/docker-compose-sudo linux-x86_64 -o /usr/bin/docker-compose
sudo chmod +x /usr/bin/docker-compose

Install Harbor

Copying and running all the bellow shells:

mkdir ~/harbor && cd ~/harbor
wget https://github.com/goharbor/harbor/releases/download/v2.8.1/harbor-offline-installer-v2.8.1.tgz
tar zxf harbor-offline-installer-v2.8.1.tgz-C /usr/local/

The harbor.yml.tmpl in this folder and we need copy and turn to harbor.yml which is harbor server read this name by default.Replace the hostname and comment out the https line temporary.Then run `./install.sh` to install harbor. 

[root@master1 harbor]# ls
common.sh  harbor.v2.8.1.tar.gz  harbor.yml.tmpl  install.sh  LICENSE  prepare
[root@master1 harbor]# cp harbor.yml.tmpl harbor.yml
[root@master1 harbor]# vim harbor.yml
..........
hostname: harbor_node01.example.com		//Replace hostname to your hostip or hostname
.........
#https:									//Comment out the https line
  # 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@master1 harbor]# ./install.sh

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

Note: docker version: 24.0.2

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

Note: Docker Compose version v2.18.1

[Step 2]: loading Harbor images ...
Loaded image: goharbor/registry-photon:v2.8.1
Loaded image: goharbor/notary-server-photon:v2.8.1
Loaded image: goharbor/harbor-core:v2.8.1
Loaded image: goharbor/harbor-jobservice:v2.8.1
Loaded image: goharbor/harbor-exporter:v2.8.1
Loaded image: goharbor/trivy-adapter-photon:v2.8.1
Loaded image: goharbor/prepare:v2.8.1
Loaded image: goharbor/redis-photon:v2.8.1
Loaded image: goharbor/nginx-photon:v2.8.1
Loaded image: goharbor/notary-signer-photon:v2.8.1
Loaded image: goharbor/harbor-portal:v2.8.1
Loaded image: goharbor/harbor-log:v2.8.1
Loaded image: goharbor/harbor-db:v2.8.1
Loaded image: goharbor/harbor-registryctl:v2.8.1


[Step 3]: preparing environment ...

[Step 4]: preparing harbor configs ...
prepare base dir is set to /usr/local/harbor
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/portal/nginx.conf
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


Note: stopping existing Harbor instance ...


[Step 5]: starting Harbor ...
[+] Building 0.0s (0/0)                                                                                                                                                                     
[+] Running 10/10
 ✔ Network harbor_harbor        Created                                                                                                                                                0.1s 
 ✔ Container harbor-log         Started                                                                                                                                                1.7s 
 ✔ Container registryctl        Started                                                                                                                                                2.1s 
 ✔ Container harbor-portal      Started                                                                                                                                                2.8s 
 ✔ Container registry           Started                                                                                                                                                2.8s 
 ✔ Container harbor-db          Started                                                                                                                                                2.8s 
 ✔ Container redis              Started                                                                                                                                                2.8s 
 ✔ Container harbor-core        Started                                                                                                                                                3.6s 
 ✔ Container harbor-jobservice  Started                                                                                                                                                5.1s 
 ✔ Container nginx              Started                                                                                                                                                5.1s 
✔ ----Harbor has been installed and started successfully.----

Note: After updating harbor.yml,running the prepare script to populate the configuration.And 

vim harbor.yml
sudo ./prepare
sudo docker-compose up -d

To reconfigure Harbor to install Notary and Trivy, include all of the components in the prepare command. 

sudo ./prepare --with-notary --with-trivy

 We use docker-compose to manage harbor like bellow. For more enter `docker-compose --help`

[root@master1 harbor]# docker-compose ls
NAME                STATUS              CONFIG FILES
harbor              running(9)          /usr/local/harbor/docker-compose.yml
[root@master1 harbor]# docker-compose ps
NAME                IMAGE                                COMMAND                  SERVICE             CREATED             STATUS                    PORTS
harbor-core         goharbor/harbor-core:v2.8.1          "/harbor/entrypoint.…"   core                22 hours ago        Up 11 minutes (healthy)   
harbor-db           goharbor/harbor-db:v2.8.1            "/docker-entrypoint.…"   postgresql          22 hours ago        Up 11 minutes (healthy)   
harbor-jobservice   goharbor/harbor-jobservice:v2.8.1    "/harbor/entrypoint.…"   jobservice          22 hours ago        Up 11 minutes (healthy)   
harbor-log          goharbor/harbor-log:v2.8.1           "/bin/sh -c /usr/loc…"   log                 22 hours ago        Up 11 minutes (healthy)   127.0.0.1:1514->10514/tcp
harbor-portal       goharbor/harbor-portal:v2.8.1        "nginx -g 'daemon of…"   portal              22 hours ago        Up 11 minutes (healthy)   
nginx               goharbor/nginx-photon:v2.8.1         "nginx -g 'daemon of…"   proxy               22 hours ago        Up 11 minutes (healthy)   0.0.0.0:80->8080/tcp, :::80->8080/tcp
redis               goharbor/redis-photon:v2.8.1         "redis-server /etc/r…"   redis               22 hours ago        Up 11 minutes (healthy)   
registry            goharbor/registry-photon:v2.8.1      "/home/harbor/entryp…"   registry            22 hours ago        Up 11 minutes (healthy)   
registryctl         goharbor/harbor-registryctl:v2.8.1   "/home/harbor/start.…"   registryctl         22 hours ago        Up 11 minutes (healthy)   
[root@master1 harbor]# docker-compose images
CONTAINER           REPOSITORY                    TAG                 IMAGE ID            SIZE
harbor-core         goharbor/harbor-core          v2.8.1              075ed731ac18        165MB
harbor-db           goharbor/harbor-db            v2.8.1              01ca249e7dc2        174MB
harbor-jobservice   goharbor/harbor-jobservice    v2.8.1              977ee6bff288        141MB
harbor-log          goharbor/harbor-log           v2.8.1              145a69b937ca        134MB
harbor-portal       goharbor/harbor-portal        v2.8.1              6c2b21221aca        134MB
nginx               goharbor/nginx-photon         v2.8.1              cea1bb2450ee        127MB
redis               goharbor/redis-photon         v2.8.1              cb8b735b33ba        128MB
registry            goharbor/registry-photon      v2.8.1              c125efcb6c2a        79.1MB
registryctl         goharbor/harbor-registryctl   v2.8.1              c141d82ffd0a        141MB
[root@master1 harbor]# docker-compose stop
[+] Stopping 9/9
 ✔ Container nginx              Stopped                                                                                                                                                0.7s 
 ✔ Container harbor-jobservice  Stopped                                                                                                                                                0.6s 
 ✔ Container registryctl        Stopped                                                                                                                                               10.3s 
 ✔ Container harbor-portal      Stopped                                                                                                                                                0.3s 
 ✔ Container harbor-core        Stopped                                                                                                                                                0.2s 
 ✔ Container harbor-db          Stopped                                                                                                                                                0.3s 
 ✔ Container registry           Stopped                                                                                                                                                0.3s 
 ✔ Container redis              Stopped                                                                                                                                                0.3s 
 ✔ Container harbor-log         Stopped                                                                                                                                               10.2s 
[root@master1 harbor]# docker-compose start
[+] Running 9/9
 ✔ Container harbor-log         Started                                                                                                                                                0.6s 
 ✔ Container harbor-portal      Started                                                                                                                                                0.8s 
 ✔ Container registryctl        Started                                                                                                                                                1.1s 
 ✔ Container redis              Started                                                                                                                                                0.7s 
 ✔ Container harbor-db          Started                                                                                                                                                0.9s 
 ✔ Container registry           Started                                                                                                                                                0.9s 
 ✔ Container harbor-core        Started                                                                                                                                                0.4s 
 ✔ Container harbor-jobservice  Started                                                                                                                                                0.7s 
 ✔ Container nginx              Started                                                                                                                                                0.8s 

Use the browser to enter "http://hostip:80"(for me is http://192.168.1.100:80 to access it.

The default username and password are admin/Harbor12345

Pull and Push image from Harbor

Push

 Push an image refer three steps:

  1. set docker-harbor insecure-registary(or set .cert file)
  2. docker login harbor (required this login user have push permissions)
  3. docker tag and docker push(tag format like harbor-host:ip/project name/imagename:v)

Here is a sample of push a image named busybox:latest. 

[root@localhost ~]# vim /etc/docker/daemon.json
{
  "insecure-registries": ["192.168.1.100:80","0.0.0.0"]
}
[root@master1 harbor]# docker pull busybox:latest
[root@master1 harbor]# docker images
REPOSITORY                      TAG       IMAGE ID       CREATED       SIZE
busybox                         latest    8135583d97fe   12 days ago   4.86MB
[root@master1 harbor]# docker tag busybox:latest 192.168.1.100:80/library/busybox:v0.1
[root@master1 harbor]# docker images
REPOSITORY                         TAG       IMAGE ID       CREATED       SIZE
192.168.1.100:80/library/busybox   v0.1      8135583d97fe   12 days ago   4.86MB
busybox                            latest    8135583d97fe   12 days ago   4.86MB
[root@master1 harbor]# docker login -u admin -p Harbor12345 http://192.168.1.100:80
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded
[root@master1 harbor]# docker push 192.168.1.100:80/library/busybox:v0.1
The push refers to repository [192.168.1.100:80/library/busybox]
9547b4c33213: Pushed 
v0.1: digest: sha256:5cd3db04b8be5773388576a83177aff4f40a03457a63855f4b9cbe30542b9a43 size: 528

Pull 

 Pull an image refer three steps:

  1. set docker-harbor insecure-registary(or set .cert file)
  2. docker login harbor(required this login user have pull permissions)
  3. docker pull

Here are two methods to pull an imgae from Harbor.One is set configuration of "registry-mirrors' and pull an image via unfull name which means no need to enter all addresses and specify labels.Two is pull an image via specify image name and tag.

//method1:
[root@master1 harbor]# vim /etc/docker/daemon.json
{
 "registry-mirrors": ["http://192.168.1.100:80"],
 "insecure-registries": ["192.168.1.100:80","0.0.0.0"]
}

[root@master1 harbor]# docker pull busybox
Using default tag: latest
latest: Pulling from library/busybox
325d69979d33: Pull complete 
Digest: sha256:560af6915bfc8d7630e50e212e08242d37b63bd5c1ccf9bd4acccf116e262d5b
Status: Downloaded newer image for busybox:latest
docker.io/library/busybox:latest
//or
[root@master1 harbor]# docker pull busybox:v0.1
v0.1: Pulling from library/busybox
Digest: sha256:5cd3db04b8be5773388576a83177aff4f40a03457a63855f4b9cbe30542b9a43
Status: Downloaded newer image for busybox:v0.1
docker.io/library/busybox:v0.1


//method2:
[root@master1 harbor]# docker pull 192.168.1.100:80/library/busybox:v0.1
v0.1: Pulling from library/busybox
325d69979d33: Pull complete 
Digest: sha256:5cd3db04b8be5773388576a83177aff4f40a03457a63855f4b9cbe30542b9a43
Status: Downloaded newer image for 192.168.1.100:80/library/busybox:v0.1
192.168.1.100:80/library/busybox:v0.1

 You can copy command to get image address like below:

Delete 

Login into harbor-webui and operate it if you want delete image.

Reference documentation 

[1] Architecture Overview of Harbor · goharbor/harbor Wiki · GitHub

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/604772.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

每日一道面试题之java 中 IO 流分为几种?

IO流是什么? 流是数据在数据源(文件)和程序(内存)之间经历的路径。 这样解释似乎是很抽象不易理解的,因此我们拿生活中的例子来说,我们可以把流看成流动的自来水,打开水阀,自来水就会通过水管从水源流到各个用户家中…

华为OD机试真题 Java 实现【求最小公倍数】【牛客练习题】

一、题目描述 正整数A和正整数B 的最小公倍数是指 能被A和B整除的最小的正整数值,设计一个算法,求输入A和B的最小公倍数。 数据范围:1≤a,b≤100000 。 二、输入描述 输入两个正整数A和B。 三、输出描述 输出A和B的最小公倍数。 四、解…

卓望数码前端一面

卓望数码前端一面 原文网址:https://www.nowcoder.com/discuss/409361218459234304?sourceSSRsearch 1.css中flex布局有哪些常见的属性 display:flex 首先让一个容器为flex布局应该写 display:flex flex-direction flex有两个关键的轴,分别是主轴…

chatgpt赋能python:Python列表倒序排序

Python列表倒序排序 Python是一种高级编程语言,被广泛用于各种领域的应用程序开发中,包括数据科学和机器学习。Python语言自带许多强大的编程工具,其中列表是其中最基础的数据结构之一。它可以让程序员整理和管理大量的数据,在实…

7.Nginx优化

文章目录 Nginx优化Nginx隐藏版本号修改Nginx的用户和组用户配置Nginx网页缓存时间日志分割配置Nginx连接超时、连接保持修改Nginx的进程数配置Nginx网页压缩设置防盗链 Nginx优化 Nginx隐藏版本号 隐藏Nginx版本号,避免安全漏洞泄漏Nginx隐藏版本号的方法 修改配…

天气预报信息获取程序--可以使用

一、优化了,输入城市代码,获取城市信息 # codingutf-8 import requests import re import csv import datetimeclass WeatherForecast(object):def __init__(self,city_code,start_year,end_year,end_month):self.city_codecity_codeself.start_yearsta…

Linux安装rinetd实现端口转发

在Linux系统中大多数情况选择用iptables来实现端口转发,iptables虽然强大,但配置不便,而且新手容易出错。在此分享另一个TCP/UDP端口转发工具rinetd,rinetd体积小巧,配置也很简单。 这篇文章以CentOS 7为例&#xff0…

职场的尽头,是编制?

作者| Mr.K 编辑| Emma 来源| 技术领导力(ID:jishulingdaoli) 本来以为“上岸”是年轻人的专利,没想到这两天却从一位42岁的朋友那里,听到了他老人家上岸的消息。这位朋友曾在阿里任职多年,从去年下半年就开始和一所大学接洽&am…

Visual C++ 6.0环境开发PACS影像系统的技术指标和精准算法

一、技术指标 •图像文件格式:DCM、JPG、BMP、TIF等 •可支持显示属性设置:24/32位真彩;256位色(黑白) •可支持监视器分辨率:1024﹡768;1280﹡1024;1600&…

chatgpt赋能python:Python删除非数字字符

Python删除非数字字符 Python是一种流行的编程语言,主要用于数据科学、人工智能、Web开发和自动化等领域。在数据处理和清洗中,Python非常强大且易于使用,而Python删除非数字字符是一个非常常见的操作。在本文中,我们将介绍如何用…

parser.add_argument详解

接上一篇:写一个python文件,在shell脚本中运行 1.来了解下 parser.add_argument函数的参数 可以看下下面的一个参数例子 def get_args():parser argparse.ArgumentParser()parser.add_argument(-b, --batch_size, typeint, default64)parser.add_argu…

java-函数式接口和Stream流

java-函数式接口和Stream流 一、函数式接口 1.1函数式接口概述 概念 有且仅有一个抽象方法的接口 如何检测一个接口是不是函数式接口 FunctionalInterface 放在接口定义的上方:如果接口是函数式接口,编译通过;如果不是,编译失败…

K8S系列文章之基础理论篇

第一部分:理解控制器 简介:当我们尝试去理解 Kubernetes 集群工作原理的时候,控制器肯定是一个难点。这是因为 控制器有很多,具体实现大相径庭;且控制器的实现用到了一些较为晦涩的机制,不易理解。但 是&a…

2023轻松斩获5家大厂offer后的面试总结!

2023年能这么轻松地斩获5家大厂offer,其实这些功劳都要归功于阿里团队的这份软件测试核心知识文档,小编今天在此分享出来,也希望能帮助更多的小伙伴拿到更多高薪的offer; 内容涉及:测试理论、Linux基础、MySQL基础、W…

【小张和Oracle数据库】Java两年半练习生裁员后竟然找到了一份DBA的工作?

一、引言 大家好,我叫张小念(小名念念),家里人都叫宝儿。 一个java两年半的练习生,经历了起起伏伏的疫情时代,终于在java一行也算是入了门。 但是,计划永远赶不上变化, 有一天经…

Makerbase SimpleFOC ESP32 例程3 I²C双编码器测试(AS5600)

Makerbase SimpleFOC ESP32 例程3 IC双编码器测试(AS5600) 第一部分 硬件介绍 1.1 硬件清单 序号品名数量1ESP32 FOC V1.0 主板12YT2804电机2312V电源适配器14USB 线156pin杜邦线2 注意:YT2804是改装的云台无刷电机,带有AS5600编码器,可实现360连续运…

Makerbase SimpleFOC ESP32 例程2 双电机开环位置测试

Makerbase SimpleFOC ESP32 例程2 双电机开环位置测试 第一部分 硬件介绍 1.1 硬件清单 序号品名数量1ESP32 FOC V1.0 主板12YT2804电机2312V电源适配器14USB 线1 注意:YT2804是改装的云台无刷电机,带有AS5600编码器,可实现360连续运转。 主要参数如…

区间预测 | MATLAB实现基于QRCNN-GRU-Multihead-Attention多头注意力卷积门控循环单元多变量时间序列区间预测

区间预测 | MATLAB实现基于QRCNN-GRU-Multihead-Attention多头注意力卷积门控循环单元多变量时间序列区间预测 目录 区间预测 | MATLAB实现基于QRCNN-GRU-Multihead-Attention多头注意力卷积门控循环单元多变量时间序列区间预测效果一览基本介绍模型描述程序设计参考资料 效果一…

菱形图案打印、水仙花数、买汽水

目录 菱形图案打印 上三角 下三角 拓展:带空格直角三角形图案 代码一 代码二 水仙花数 拓展:变种水仙花数 买汽水 代码一 代码二 妙用汽水瓶 菱形图案打印 题目要求 其实呢这道题很多人想到直接用printf()进行输出,我想说的是&#…

开源:小狐狸GPT付费AI-v2.0.0 H5和小程序端增加使用手册

小狐狸GPT付费AI体验系统、系统版本更新至1.2.0,源码为小程序、H5、WEB版本,购买含更新,独立版;开源、开源、开源、可二开!!200包含H5、web的vue全开源,最新版更新了:H5和小程序端增…