Harbor 企业级 Registry 服务器

软件简介

Harbor 是由 VMware 公司中国团队为企业用户设计的 Registry server 开源项目,包括了权限管理 (RBAC)、LDAP、审计、管理界面、自我注册、HA 等企业必需的功能,同时针对中国用户的特点,设计镜像复制和中文支持等功能。

使用注意事项

HTTP与HTTPS

由于私有环境没有https通讯证书,所以已下部署均是http协议。docker默认是不支持http的,需要做如下修改。

[root@cloud docker]# vi /etc/docker/daemon.json

将其中insecure-registries地址换成自己环境真实的即可。

{
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2",
"storage-opts": [
"overlay2.override_kernel_check=true"
],
"registry-mirrors": [
"https://docker.mirrors.ustc.edu.cn",
"https://registry.docker-cn.com"
],
"insecure-registries": [
"xxx.xxx.xxx.xxx:8082"
],
"graph":"/data/dockerlib"
}

部署

部署前工作

Harbor官方文档

Harbor下载地址

关闭防火墙和 selinux

[root@localhost harbor]# systemctl disable --now firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost harbor]# systemctl stop --now firewalld
[root@localhost harbor]# cat /etc/selinux/config

SELINUX=disabled // 修改这一行
// 修改完之后重启

[root@localhost harbor]# reboot
[root@localhost harbor]# setenforce 0
setenforce: SELinux is disabled

下载 harbor包

配置docker加速器

[root@localhost ~]# vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://kgdsiwq8.mirror.aliyuncs.com"]
}


// 重新加载docker服务


[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl restart docker
// 查看加速器配置情况


[root@localhost ~]# docker info
......以上省略
Experimental: false
Insecure Registries:
127.0.0.0/8
Registry Mirrors:
https://kgdsiwq8.mirror.aliyuncs.com/ // 加速器配置成功
Live Restore Enabled: false

单节点部署

(其中hostname可以直接配置为IP地址)

// 解压 harbor包到 /usr/local/ 目录下
[root@localhost ~]# tar xf harbor-offline-installer-v2.6.1.tgz -C /usr/local/
[root@localhost ~]# cd /usr/local/
[root@localhost local]# ls
bin games include lib64 sbin src
etc harbor lib libexec share
[root@localhost local]# cd harbor/
[root@localhost harbor]# ls
LICENSE harbor.v2.6.1.tar.gz install.sh
common.sh harbor.yml.tmpl prepare
// 设置主机名
[root@localhost harbor]# hostnamectl set-hostname node01
[root@localhost harbor]# bash
[root@node1 harbor]# hostname
node01
[root@node01 harbor]# cp harbor.yml.tmpl harbor.yml
[root@node01 harbor]# vim harbor.yml
# DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients.
hostname: node01 // 添加主机名
# https related config
#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 // 注释
harbor_admin_password: Harbor12345 // 默认的登录密码
// 以上这些需要修改,其余保持默认
// 添加主机映射
[root@localhost harbor]# vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.91.137 node01
// 测试能否ping通 node01 主机
[root@localhost harbor]# ping node01
PING node1.example.com (192.168.91.137) 56(84) bytes of data.
64 bytes from node1.example.com (192.168.91.137): icmp_seq=1 ttl=64 time=0.044 ms
64 bytes from node1.example.com (192.168.91.137): icmp_seq=2 ttl=64 time=0.033 ms
//加载离线镜像
[root@localhost harbor]# docker load -i harbor.v2.6.1.tar.gz
[root@localhost harbor]# ./prepare
// 启动脚本进行安装
[root@localhost harbor]# ./install.sh
[Step 0]: checking if docker is installed ...
Note: docker version: 20.10.12
[Step 1]: checking docker-compose is installed ...
Note: docker-compose version: 1.29.2
[Step 2]: loading Harbor images ...
......安装过程省略
----Harbor has been installed and started successfully.----
// 安装完成会自动启动很多容器


[root@node1 harbor]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3daa18aedde3 goharbor/harbor-jobservice:v2.3.5 "/harbor/entrypoint.…" 5 seconds ago Up 4 seconds (health: starting) harbor-jobservice
67cda2a01e08 goharbor/nginx-photon:v2.3.5 "nginx -g 'daemon of…" 5 seconds ago Up 4 seconds (health: starting) 0.0.0.0:80->8080/tcp, :::80->8080/tcp nginx
388f512bcfe1 goharbor/harbor-core:v2.3.5 "/harbor/entrypoint.…" 6 seconds ago Up 4 seconds (health: starting) harbor-core
b4e7fefa599e goharbor/harbor-db:v2.3.5 "/docker-entrypoint.…" 7 seconds ago Up 5 seconds (health: starting) harbor-db
9201662bba92 goharbor/redis-photon:v2.3.5 "redis-server /etc/r…" 7 seconds ago Up 5 seconds (health: starting) redis
42368cf0e78b goharbor/registry-photon:v2.3.5 "/home/harbor/entryp…" 7 seconds ago Up 5 seconds (health: starting) registry
ed564a1e593b goharbor/harbor-registryctl:v2.3.5 "/home/harbor/start.…" 7 seconds ago Up 5 seconds (health: starting) registryctl
daa189f31bc3 goharbor/harbor-portal:v2.3.5 "nginx -g 'daemon of…" 7 seconds ago Up 5 seconds (health: starting) harbor-portal
8ac96968e301 goharbor/harbor-log:v2.3.5 "/bin/sh -c /usr/loc…" 7 seconds ago Up 6 seconds (health: starting) 127.0.0.1:1514->10514/tcp harbor-log


// 安装完成之后会多两个文件,一个common,一个docker-compose.yml


[root@localhost harbor]# ls /usr/local/harbor/
LICENSE docker-compose.yml harbor.yml.tmpl
common harbor.v2.3.5.tar.gz install.sh
common.sh harbor.yml prepare
[root@node1 harbor]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:22 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 [::]:22 [::]:*
LISTEN 0 128 [::]:80 [::]:*

4.5 harbor网页操作

使用系统账号登录

http://xxx.xxx.xxx.xxx:8082/harbor/projects admin/Harbor12345

仓库管理功能

定义Registry 实例,可以是公网的也可以是私有的,比如网易163的https://hub.c.163.com

和docker HUB

添加完成后,点击测试连接即可。

项目功能

项目可以作为私有的镜像仓库管理,也可以代理共有环境的镜像信息。推送私有环境的镜像,也需要先建立项目方可。如下展示的是将公共镜像私有化。

  1. 公共镜像打tag

docker tag grafana/grafana:9.2.1 xxx.xxx.xxx.xxx:8082/abu/grafana:9.2.1

  1. 查看镜像

[root@cloud docker]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
10.21.5.30:8081/abu/centos user d8506ac3842d 20 hours ago 193MB
centos user d8506ac3842d 20 hours ago 193MB
grafana/grafana 9.2.1 46e73c2b7a35 3 days ago 347MB

  1. 镜像推送

[root@cloud docker]# docker push xxx.xxx.xxx.xxx:8082/abu/grafana:9.2.1
The push refers to repository [xxx.xxx.xxx.xxx:8082/abu/grafana]
7cb09c9a4372: Pushed
f0be059d864b: Pushed
ef88b45a119f: Pushed
3b2b7c569a4c: Pushed
839b0b40ab56: Pushed
adff21d3bcca: Pushed
1e2c29677398: Pushed
8675ede87d30: Pushed
34d5ebaa5410: Pushed
9.2.1: digest: sha256:33be3c2d3f457192a284777e24ae6bd264598896451c01ec2c7f329da4707af2 size: 2203

  1. 管理态

harbor网页可以看到abu状态想多了一个镜像信息。

代理镜像

新建项目时选择镜像代理即可,项目名称很重要,需要在平常使用的镜像前缀加上。

未使用代理的时候

[root@cloud docker]# docker pull bitnami/prometheus:latest
latest: Pulling from bitnami/prometheus
0796bf144e3f: Pull complete
f2e46fdc7dbf: Pull complete
16a37524c720: Pull complete
71419d3ad358: Pull complete
a2ed6d2d4643: Pull complete
b3a121d40da9: Pull complete
2ee758bc629a: Pull complete
af7e41fdf0e4: Pull complete
Digest: sha256:145fa39d958e0546b1c154bb82215cec753c7268ba447b093d2490a556d73bd3
Status: Downloaded newer image for bitnami/prometheus:latest
docker.io/bitnami/prometheus:latest

使用harbor代理共有环境

[root@bogon cedar]# docker pull xxx.xxx.xxx.xxx:8082/dockerhub/bitnami/prometheus:latest
latest: Pulling from dockerhub/bitnami/prometheus
1d8866550bdd: Pull complete
7a956b97b95f: Pull complete
Digest: sha256:35d02ae6b542d7980df579f21953431e61bf096f05d74496361d8cd80a046461
Status: Downloaded newer image for xxx.xxx.xxx.xxx:8082/dockerhub/bitnami/prometheus:latest
xxx.xxx.xxx.xxx:8082/dockerhub/bitnami/prometheus:latest

展开阅读全文

页面更新:2024-03-04

标签:俄文   离线   企业级   加速器   注释   仓库   证书   功能   环境   服务器   项目   用户

1 2 3 4 5

上滑加载更多 ↓
推荐阅读:
友情链接:
更多:

本站资料均由网友自行发布提供,仅用于学习交流。如有版权问题,请与我联系,QQ:4156828  

© CopyRight 2008-2024 All Rights Reserved. Powered By bs178.com 闽ICP备11008920号-3
闽公网安备35020302034844号

Top