docker基础:私库系列:再探Harbor:(2) 架构与组件说明

2023-12-30 03:40

本文主要是介绍docker基础:私库系列:再探Harbor:(2) 架构与组件说明,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

上篇文章了解到了如何使用新的版本的harbor,这篇文章来了解一下harbor架构的组成和运行时各个组件的使用方式。

架构

这里写图片描述

容器信息

[root@liumiao harbor]# docker-compose psName                     Command               State                                Ports                               
------------------------------------------------------------------------------------------------------------------------------
harbor-adminserver   /harbor/start.sh                 Up                                                                       
harbor-db            /usr/local/bin/docker-entr ...   Up      3306/tcp                                                         
harbor-jobservice    /harbor/start.sh                 Up                                                                       
harbor-log           /bin/sh -c /usr/local/bin/ ...   Up      127.0.0.1:1514->10514/tcp                                        
harbor-ui            /harbor/start.sh                 Up                                                                       
nginx                nginx -g daemon off;             Up      0.0.0.0:443->443/tcp, 0.0.0.0:4443->4443/tcp, 0.0.0.0:80->80/tcp 
redis                docker-entrypoint.sh redis ...   Up      6379/tcp                                                         
registry             /entrypoint.sh serve /etc/ ...   Up      5000/tcp                                                         
[root@liumiao harbor]# 

具体说明

组件说明实现
Proxy用于转发用户的请求到registry/ui/token service的反向代理nginx:使用nginx官方镜像进行配置
Registry镜像的push/pull命令实施功能registry:使用registry官方镜像
Database保存项目/用户/角色/复制策略等信息到数据库中harbor-db:Mariadb的官方镜像用于保存harbor的数据库信息
Core Service: UI/token/webhook用户进行镜像操作的界面实现,通过webhook的机制保证镜像状态的变化harbor能够即使了解以便进行日志更新等操作,而项目用户角色则通过token的进行镜像的push/pull等操作harbor-ui等
Job services镜像复制,可以在harbor实例之间进行镜像的复制或者同步等操作harbor-jobservice
Log collector负责收集各个镜像的日志信息进行统一管理harbor-log:缺省安装下日志的保存场所为/var/log/harbor

proxy

proxy就是使用nginx作为反向代理,而整个的核心则在于nginx的设定文件,通过如下的设定文件可以清楚的看到harbor所解释的将各个其他组件集成在一起的说明内容,而实际的实现也基本上就是靠nginx的设定。

[root@liumiao harbor]# ls
LICENSE  common                    docker-compose.notary.yml  ha          harbor.v1.5.2.tar.gz  open_source_license
NOTICE   docker-compose.clair.yml  docker-compose.yml         harbor.cfg  install.sh            prepare
[root@liumiao harbor]# cat common/config/nginx/nginx.conf 
worker_processes auto;events {worker_connections 1024;use epoll;multi_accept on;
}http {tcp_nodelay on;# this is necessary for us to be able to disable request buffering in all casesproxy_http_version 1.1;upstream registry {server registry:5000;}upstream ui {server ui:8080;}log_format timed_combined '$remote_addr - ''"$request" $status $body_bytes_sent ''"$http_referer" "$http_user_agent" ''$request_time $upstream_response_time $pipe';access_log /dev/stdout timed_combined;server {listen 80;server_tokens off;# disable any limits to avoid HTTP 413 for large image uploadsclient_max_body_size 0;location / {proxy_pass http://ui/;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;# When setting up Harbor behind other proxy, such as an Nginx instance, remove the below line if the proxy already has similar settings.proxy_set_header X-Forwarded-Proto $scheme;proxy_buffering off;proxy_request_buffering off;}location /v1/ {return 404;}location /v2/ {proxy_pass http://ui/registryproxy/v2/;proxy_set_header Host $http_host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;# When setting up Harbor behind other proxy, such as an Nginx instance, remove the below line if the proxy already has similar settings.proxy_set_header X-Forwarded-Proto $scheme;proxy_buffering off;proxy_request_buffering off;}location /service/ {proxy_pass http://ui/service/;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;# When setting up Harbor behind other proxy, such as an Nginx instance, remove the below line if the proxy already has similar settings.proxy_set_header X-Forwarded-Proto $scheme;proxy_buffering off;proxy_request_buffering off;}location /service/notifications {return 404;}}
}
[root@liumiao harbor]# 

database

可以看到使用的是MariaDB 10.2.14, harbor的数据库名称为registry

[root@liumiao harbor]# docker exec -it harbor-db sh
sh-4.3# mysql -uroot -pliumiaopw
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 21
Server version: 10.2.14-MariaDB Source distributionCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| registry           |
+--------------------+
4 rows in set (0.00 sec)MariaDB [(none)]>

数据库表的信息进行确认后可以看到,当前版本的这种使用方式下,数据库的表有如下 20张表左右

MariaDB [(none)]> use registry;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -ADatabase changed
MariaDB [registry]> show tables;
+-------------------------------+
| Tables_in_registry            |
+-------------------------------+
| access                        |
| access_log                    |
| alembic_version               |
| clair_vuln_timestamp          |
| harbor_label                  |
| harbor_resource_label         |
| img_scan_job                  |
| img_scan_overview             |
| project                       |
| project_member                |
| project_metadata              |
| properties                    |
| replication_immediate_trigger |
| replication_job               |
| replication_policy            |
| replication_target            |
| repository                    |
| role                          |
| user                          |
| user_group                    |
+-------------------------------+
20 rows in set (0.00 sec)MariaDB [registry]>

Log collector

harbor中的日志缺省会在如下目录下进行汇集和管理

[root@liumiao harbor]# ls /var/log/harbor
adminserver.log  jobservice.log  mysql.log  proxy.log  redis.log  registry.log  ui.log
[root@liumiao harbor]# 

docker-compose.yml

[root@liumiao harbor]# cat docker-compose.yml 
version: '2'
services:log:image: vmware/harbor-log:v1.5.2container_name: harbor-log restart: alwaysvolumes:- /var/log/harbor/:/var/log/docker/:z
      - ./common/config/log/:/etc/logrotate.d/:z
    ports:- 127.0.0.1:1514:10514
    networks:- harbor
  registry:image: vmware/registry-photon:v2.6.2-v1.5.2container_name: registryrestart: alwaysvolumes:- /data/registry:/storage:z
      - ./common/config/registry/:/etc/registry/:z
    networks:- harbor
    environment:- GODEBUG=netdns=cgo
    command:["serve", "/etc/registry/config.yml"]depends_on:- log
    logging:driver: "syslog"options:  syslog-address: "tcp://127.0.0.1:1514"tag: "registry"mysql:image: vmware/harbor-db:v1.5.2container_name: harbor-dbrestart: alwaysvolumes:- /data/database:/var/lib/mysql:z
    networks:- harbor
    env_file:- ./common/config/db/env
    depends_on:- log
    logging:driver: "syslog"options:  syslog-address: "tcp://127.0.0.1:1514"tag: "mysql"adminserver:image: vmware/harbor-adminserver:v1.5.2container_name: harbor-adminserverenv_file:- ./common/config/adminserver/env
    restart: alwaysvolumes:- /data/config/:/etc/adminserver/config/:z
      - /data/secretkey:/etc/adminserver/key:z
      - /data/:/data/:z
    networks:- harbor
    depends_on:- log
    logging:driver: "syslog"options:  syslog-address: "tcp://127.0.0.1:1514"tag: "adminserver"ui:image: vmware/harbor-ui:v1.5.2container_name: harbor-uienv_file:- ./common/config/ui/env
    restart: alwaysvolumes:- ./common/config/ui/app.conf:/etc/ui/app.conf:z
      - ./common/config/ui/private_key.pem:/etc/ui/private_key.pem:z
      - ./common/config/ui/certificates/:/etc/ui/certificates/:z
      - /data/secretkey:/etc/ui/key:z
      - /data/ca_download/:/etc/ui/ca/:z
      - /data/psc/:/etc/ui/token/:z
    networks:- harbor
    depends_on:- log
      - adminserver
      - registry
    logging:driver: "syslog"options:  syslog-address: "tcp://127.0.0.1:1514"tag: "ui"jobservice:image: vmware/harbor-jobservice:v1.5.2container_name: harbor-jobserviceenv_file:- ./common/config/jobservice/env
    restart: alwaysvolumes:- /data/job_logs:/var/log/jobs:z
      - ./common/config/jobservice/config.yml:/etc/jobservice/config.yml:z
    networks:- harbor
    depends_on:- redis
      - ui
      - adminserver
    logging:driver: "syslog"options:  syslog-address: "tcp://127.0.0.1:1514"tag: "jobservice"redis:image: vmware/redis-photon:v1.5.2container_name: redisrestart: alwaysvolumes:- /data/redis:/data
    networks:- harbor
    depends_on:- log
    logging:driver: "syslog"options:  syslog-address: "tcp://127.0.0.1:1514"tag: "redis"proxy:image: vmware/nginx-photon:v1.5.2container_name: nginxrestart: alwaysvolumes:- ./common/config/nginx:/etc/nginx:z
    networks:- harbor
    ports:- 80:80
      - 443:443
      - 4443:4443
    depends_on:- mysql
      - registry
      - ui
      - log
    logging:driver: "syslog"options:  syslog-address: "tcp://127.0.0.1:1514"tag: "proxy"
networks:harbor:external: false[root@liumiao harbor]# 

使用注意事项:自定义端口号

在前一篇文章的例子中我们使用默认的80口作为harbor的端口,如果希望进行更改(比如改为8848),按照如下步骤进行修改即可

步骤详细说明
Step 1修改docker-compose.yml中80:80端口映射,改为8848:80.(https方式修改8848:443)
Step 2修改hostname信息,将端口号带上,改为192.168.163.128:8848
Step 3停止harbor:docker-compose down
Step 4执行prepare更新设定: ./prepare
Step 5启动harbor:docker-compose up -d

设定内容

可以通过查看数据库的properties或者api/systeminfo来确认harbor设定项目的详细信息

properties

[root@liumiao harbor]# docker exec -it harbor-db sh
sh-4.3# mysql -uroot -pliumiaopw
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 153
Server version: 10.2.14-MariaDB Source distributionCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]> use registry
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -ADatabase changed
MariaDB [registry]> select * from properties;
+----+--------------------------------+----------------------------------------------+
| id | k                              | v                                            |
+----+--------------------------------+----------------------------------------------+
|  1 | cfg_expiration                 | 5                                            |
|  2 | project_creation_restriction   | everyone                                     |
|  3 | uaa_client_secret              | <enc-v1>cBvRPcG+p3oNVnJh8VM+SjvlcEsKYg==     |
|  4 | clair_db_host                  | postgres                                     |
|  5 | token_service_url              | http://ui:8080/service/token                 |
|  6 | mysql_password                 | <enc-v1>HDqd+PbHcG9EWK9DF3RzM43fTtPvCjdvyQ== |
|  7 | uaa_endpoint                   | uaa.mydomain.org                             |
|  8 | max_job_workers                | 50                                           |
|  9 | sqlite_file                    |                                              |
| 10 | email_from                     | admin <sample_admin@mydomain.com>            |
| 11 | ldap_base_dn                   | ou=people,dc=mydomain,dc=com                 |
| 12 | clair_db_port                  | 5432                                         |
| 13 | mysql_port                     | 3306                                         |
| 14 | ldap_search_dn                 |                                              |
| 15 | clair_db_username              | postgres                                     |
| 16 | email_insecure                 | false                                        |
| 17 | database_type                  | mysql                                        |
| 18 | ldap_filter                    |                                              |
| 19 | with_notary                    | false                                        |
| 20 | admin_initial_password         | <enc-v1>4ZEvd/GfBYSdF9I6PfeI/XIvfGhPITaD3w== |
| 21 | notary_url                     | http://notary-server:4443                    |
| 22 | auth_mode                      | db_auth                                      |
| 23 | ldap_group_search_scope        | 2                                            |
| 24 | ldap_uid                       | uid                                          |
| 25 | email_username                 | sample_admin@mydomain.com                    |
| 26 | mysql_database                 | registry                                     |
| 27 | reload_key                     |                                              |
| 28 | clair_url                      | http://clair:6060                            |
| 29 | ldap_group_search_filter       | objectclass=group                            |
| 30 | email_password                 | <enc-v1>h18ptbUM5oJwtKOzjJ4X5LOiPw==         |
| 31 | email_ssl                      | false                                        |
| 32 | ldap_timeout                   | 5                                            |
| 33 | uaa_client_id                  | id                                           |
| 34 | registry_storage_provider_name | filesystem                                   |
| 35 | self_registration              | true                                         |
| 36 | email_port                     | 25                                           |
| 37 | ui_url                         | http://ui:8080                               |
| 38 | token_expiration               | 30                                           |
| 39 | email_identity                 |                                              |
| 40 | clair_db                       | postgres                                     |
| 41 | uaa_verify_cert                | true                                         |
| 42 | ldap_verify_cert               | true                                         |
| 43 | ldap_group_attribute_name      | cn                                           |
| 44 | mysql_host                     | mysql                                        |
| 45 | read_only                      | false                                        |
| 46 | ldap_url                       | ldaps://ldap.mydomain.com                    |
| 47 | ext_endpoint                   | http://192.168.163.128                       |
| 48 | ldap_group_base_dn             | ou=group,dc=mydomain,dc=com                  |
| 49 | with_clair                     | false                                        |
| 50 | admiral_url                    | NA                                           |
| 51 | ldap_scope                     | 2                                            |
| 52 | registry_url                   | http://registry:5000                         |
| 53 | jobservice_url                 | http://jobservice:8080                       |
| 54 | email_host                     | smtp.mydomain.com                            |
| 55 | ldap_search_password           | <enc-v1>F2QZkeEPTQPsJ9KNsBWcXA==             |
| 56 | mysql_username                 | root                                         |
| 57 | clair_db_password              | <enc-v1>IGBg3NxvT7qCYGIB+zizax+GojoM7ao2VQ== |
+----+--------------------------------+----------------------------------------------+
57 rows in set (0.00 sec)MariaDB [registry]> 

api/systeminfo

[root@liumiao harbor]# curl http://localhost/api/systeminfo 
{"with_notary": false,"with_clair": false,"with_admiral": false,"admiral_endpoint": "NA","auth_mode": "db_auth","registry_url": "192.168.163.128","project_creation_restriction": "everyone","self_registration": true,"has_ca_root": false,"harbor_version": "v1.5.2-8e61deae","next_scan_all": 0,"registry_storage_provider_name": "filesystem","read_only": false
}[root@liumiao harbor]# 

这篇关于docker基础:私库系列:再探Harbor:(2) 架构与组件说明的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/551599

相关文章

java脚本使用不同版本jdk的说明介绍

《java脚本使用不同版本jdk的说明介绍》本文介绍了在Java中执行JavaScript脚本的几种方式,包括使用ScriptEngine、Nashorn和GraalVM,ScriptEngine适用... 目录Java脚本使用不同版本jdk的说明1.使用ScriptEngine执行javascript2.

vue解决子组件样式覆盖问题scoped deep

《vue解决子组件样式覆盖问题scopeddeep》文章主要介绍了在Vue项目中处理全局样式和局部样式的方法,包括使用scoped属性和深度选择器(/deep/)来覆盖子组件的样式,作者建议所有组件... 目录前言scoped分析deep分析使用总结所有组件必须加scoped父组件覆盖子组件使用deep前言

基于Qt Qml实现时间轴组件

《基于QtQml实现时间轴组件》时间轴组件是现代用户界面中常见的元素,用于按时间顺序展示事件,本文主要为大家详细介绍了如何使用Qml实现一个简单的时间轴组件,需要的可以参考下... 目录写在前面效果图组件概述实现细节1. 组件结构2. 属性定义3. 数据模型4. 事件项的添加和排序5. 事件项的渲染如何使用

MySQL中my.ini文件的基础配置和优化配置方式

《MySQL中my.ini文件的基础配置和优化配置方式》文章讨论了数据库异步同步的优化思路,包括三个主要方面:幂等性、时序和延迟,作者还分享了MySQL配置文件的优化经验,并鼓励读者提供支持... 目录mysql my.ini文件的配置和优化配置优化思路MySQL配置文件优化总结MySQL my.ini文件

更改docker默认数据目录的方法步骤

《更改docker默认数据目录的方法步骤》本文主要介绍了更改docker默认数据目录的方法步骤,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一... 目录1.查看docker是否存在并停止该服务2.挂载镜像并安装rsync便于备份3.取消挂载备份和迁

Redis分布式锁使用及说明

《Redis分布式锁使用及说明》本文总结了Redis和Zookeeper在高可用性和高一致性场景下的应用,并详细介绍了Redis的分布式锁实现方式,包括使用Lua脚本和续期机制,最后,提到了RedLo... 目录Redis分布式锁加锁方式怎么会解错锁?举个小案例吧解锁方式续期总结Redis分布式锁如果追求

Docker集成CI/CD的项目实践

《Docker集成CI/CD的项目实践》本文主要介绍了Docker集成CI/CD的项目实践,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学... 目录一、引言1.1 什么是 CI/CD?1.2 docker 在 CI/CD 中的作用二、Docke

如何在一台服务器上使用docker运行kafka集群

《如何在一台服务器上使用docker运行kafka集群》文章详细介绍了如何在一台服务器上使用Docker运行Kafka集群,包括拉取镜像、创建网络、启动Kafka容器、检查运行状态、编写启动和关闭脚本... 目录1.拉取镜像2.创建集群之间通信的网络3.将zookeeper加入到网络中4.启动kafka集群

结构体和联合体的区别及说明

《结构体和联合体的区别及说明》文章主要介绍了C语言中的结构体和联合体,结构体是一种自定义的复合数据类型,可以包含多个成员,每个成员可以是不同的数据类型,联合体是一种特殊的数据结构,可以在内存中共享同一... 目录结构体和联合体的区别1. 结构体(Struct)2. 联合体(Union)3. 联合体与结构体的

关于SpringBoot的spring.factories文件详细说明

《关于SpringBoot的spring.factories文件详细说明》spring.factories文件是SpringBoot自动配置机制的核心部分之一,它位于每个SpringBoot自动配置模... 目录前言一、基本结构二、常见的键EnableAutoConfigurationAutoConfigu