docker基礎:私庫系列:再探Harbor:(2) 架構與元件說明
上篇文章瞭解到瞭如何使用新的版本的harbor,這篇文章來了解一下harbor架構的組成和執行時各個元件的使用方式。
架構
容器資訊
[[email protected] harbor]# docker-compose ps
Name 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
[ [email protected] 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的設定。
[[email protected] 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
[[email protected] 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 cases
proxy_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 uploads
client_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;
}
}
}
[[email protected] harbor]#
database
可以看到使用的是MariaDB 10.2.14, harbor的資料庫名稱為registry
[[email protected] 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 distribution
Copyright (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 -A
Database 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
[[email protected] harbor]# cat docker-compose.yml
version: '2'
services:
log:
image: vmware/harbor-log:v1.5.2
container_name: harbor-log
restart: always
volumes:
- /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.2
container_name: registry
restart: always
volumes:
- /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.2
container_name: harbor-db
restart: always
volumes:
- /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.2
container_name: harbor-adminserver
env_file:
- ./common/config/adminserver/env
restart: always
volumes:
- /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.2
container_name: harbor-ui
env_file:
- ./common/config/ui/env
restart: always
volumes:
- ./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.2
container_name: harbor-jobservice
env_file:
- ./common/config/jobservice/env
restart: always
volumes:
- /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.2
container_name: redis
restart: always
volumes:
- /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.2
container_name: nginx
restart: always
volumes:
- ./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
[[email protected] 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
[[email protected] 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 distribution
Copyright (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 -A
Database 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 <[email protected]> |
| 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 | [email protected] |
| 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:(7) 使用restapi對專案進行增刪改查
在上篇文章中介紹了Harbor的RestApi,這篇具體以專案的增刪改查作為例子來進行說明。 前提假定 假定Harbor運行於本機localhost的32031埠 專案查詢 查詢全部專案 curl -X GET “http://localhost:32031/
docker基礎:私庫系列:再探Harbor:(8)對映象tag進行操作(for zz)
harbor使用了docker的registry,docker的registry所提供的api使用起來並不方便,harbor提供了使用/repositories/{repo_name}/tags可以對映象的tag進行重新設定,非常方便,當然也可以通過docker cli方式使用docke
docker基礎:私庫系列:再探Harbor:(2) 架構與元件說明
上篇文章瞭解到瞭如何使用新的版本的harbor,這篇文章來了解一下harbor架構的組成和執行時各個元件的使用方式。 架構 容器資訊 [[email protected] harbor]# docker-compose ps
EasyHook庫系列使用教程之四鉤子的啟動與停止
ros clu 簡單 line IT data- exclusive 線程 調用 此文的產生花費了大量時間對EasyHook進行深入了解同一時候參考了大量文檔
騰訊:3億人次實戰演習驗證異地容災架構與快速排程能力
作者介紹: 李光 現就職於騰訊SNG社交網路運營部,負責SNG移動類產品的業務運維,同時也負責運營平臺規劃與運維產品運營推廣工作 前言 社交網路事業群擁有眾多海量規模的業務,在海量的運營壓力下,伺服器裝置的數量也突破了10w大關,並有序的分佈在全國不同的IDC中實現異地容災的高可用架構。 但正因為社
收官之作:利用Microsoft Teams構建中大型社群的技術架構與運營經驗
這是我在 精彩又一年:Microsoft Teams技術社群2018年度回顧和展望 活動上面的主題分享,我用Microsoft Teams技術社群的實踐經驗,給大家整理和分享了技術架構和一些運營經驗。 Microsoft Teams 設計用來作為團隊協作的中樞,它不僅能很
基於docker-registry 私有映象庫安裝視覺化工具Harbor中遇到的問題
學習過程中要參考博文:https://blog.csdn.net/aixiaoyang168/article/details/73549898 問題:頁面80埠可以訪問,但是命令列admin/paw 不能訪問報 443: getsockopt: connection ref
Docker系列:02.Docker基礎使用
基礎 posit 什麽 2.0 objective 占用 宿主機 des .com 02.Docker基礎使用 獲取鏡像: docker pull ubuntu 查找鏡像:docker search ubuntu 查看鏡像:docker images 刪除鏡像:docke
【 專欄 】- DevOps系列之:映象私庫
DevOps系列之:映象私庫 容器化是DevOps推動中一個重要的趨勢,這個專欄中將會介紹流行的映象私庫管理工具以及專案實踐經驗。
Docker系列(二):docker基礎命令
docker的部署安裝(Linux kernel至少3.8以上): yum install docker docker1.8安裝:(下面 是兩個命令) # cat >/etc/yum.repos.d/docker.repo<<-EOF [dockerrep
【雲星資料---Apache Flink實戰系列(精品版)】:Apache Flink實戰基礎004--flink特性:類庫和API示例
三、類庫和API 1.流處理程式 flink的 DataStream API在流處理的業務場景下,支援多種資料轉換,支援使用者自定義狀態的操作,支援靈活的視窗操作! 示例程式:
Android開發系列(十七):讀取assets文件夾下的數據庫文件
pack 取數 code ada tracking 編寫 數據庫 sdn where 在做Android應用的時候,不可避免要用到數據庫。可是當我們把應用的apk部署到真機上的時候,已經創建好的數據庫及其裏邊的數據是不能隨著apk一起安裝到真機上的。 (PS:這篇
Flask中之數據庫框架和模型類四:再述SQLAlchemy配置和基本操作之增刪改查
模糊 offset odi com app ack 字符 add () from flask import Flask from flask_sqlalchemy import SQLAlchemy app = Flask(__name__) #設置連接數據庫的URL
TensorFlow系列專題(二):機器學習基礎
歡迎大家關注我們的網站和系列教程:http://www.tensorflownews.com/,學習更多的機器學習、深度學習的知識! 目錄: 資料預處理 歸一化 標準化 離散化 二值化 啞編碼
TensorFlow系列專題(一):機器學習基礎
歡迎大家關注我們的網站和系列教程:http://www.tensorflownews.com/,學習更多的機器學習、深度學習的知識! 一.人工智慧發展 1956年的8月,美國達特茅斯學院(Dartmouth College)舉行了一次研討會,這次會議由約翰[圖片上傳失敗...(ima
python基礎教程_學習筆記18:標準庫:一些最愛——shelve
變量綁定 工作 關閉 mes 名稱 tis 標準 times data- 版權聲明:本文為博主原創文章,未經博主同意不得轉載。 https://blog.csdn.net/signjing/article/details/3602998
Docker基礎篇3:容器管理
1、建立容器常用選項 1.1、建立容器常用指令 【建立容器常用指令】 【建立容器是限制資源】 1.2、建立容器應用 【執行一個容器】 [[email protected]_190_147_centos ~]# docker container
Docker基礎篇2:映象管理
1、映象簡介 簡單說,Docker映象是一個不包含Linux核心而又精簡的Linux作業系統。 映象不是一個單一的檔案,而是有多層構成。我們可以通過docker history <ID/NAME> 檢視映象中各層內容及大小,每
Docker基礎篇1:簡介及安裝
1、Docker簡介 Docker是一個開源的應用容器引擎,使用Go語言開發,基於Linux核心的cgroup,namespace,Union FS等技術,對應用程序進行封裝隔離,並且獨立於宿主機與其他程序,這種執行時封裝的狀態稱為容器。Docker理念
Java基礎系列(四十三):集合之Vector&Stack
Vector 簡介 Vector是一種實現了動態陣列的集合,何為動態陣列呢?即長度可以自動增長的陣列,它是執行緒同步的,也就是說同一時刻只有一個執行緒可以寫Vector,可以避免多執行緒同時寫引起的不一致性,但是比較消耗資源。接下來,我們來看Vector的原始碼。 原始碼