标签:secret 提示 收集 hub 执行 相关 source Kubernete ide
Harbor是一个用于存储和分发Docker镜像的企业级Registry服务器,通过添加一些企业必需的功能特性,例如安全、标识和管理等,扩展了开源Docker Distribution。作为一个企业级私有Registry服务器,Harbor提供了更好的性能和安全。提升用户使用Registry构建和运行环境传输镜像的效率。Harbor支持安装在多个Registry节点的镜像资源复制,镜像全部保存在私有Registry中,确保数据和知识产权在公司内部网络中管控。另外,Harbor也提供了高级的安全特性,诸如用户管理,访问控制和活动审计等。
Harbor官方网站:http://vmware.github.io/harbor/
Harbor源码地址:https://github.com/vmware/harbor
所有部署相关的文件都在harbor/Deploy目录下,需要说明的是,harbor的每个组件都是以Docker容器的形式构建的,可以使用Docker Compose来进行部署,当然,如果你的环境中使用了kubernetes,harbor也提供了kubernetes的配置文件。
harbor共有6个容器组成:
下面我以harbor 1.5.0版本作配置说明。
harbor的核心配置文件是harbor.cfg,路径在源码目录下的make目录下,示例配置如下:
# harbor的访问地址
hostname = hub.dz11.com
# 使用https协议
ui_url_protocol = https
# harbor的数据库密码
db_password = xxxxx
max_job_workers = 10
customize_crt = on
# 证书相关路径
ssl_cert = /data/certs/dz11.com.crt
ssl_cert_key = /data/certs/dz11.com.key
secretkey_path = /data
admiral_url = NA
# email相关配置
email_identity =
email_server = smtp.163.com
email_server_port = 25
email_username = yan_ruo_gu@163.com
email_password = yan_ruo_gu0711
email_from = admin <yan_ruo_gu@163.com>
email_ssl = false
# 登录harbor的管理员密码
harbor_admin_password = xxxxxx
# harbor的验证方式,支持db_auth和ldap_auth,这里使用的是ldap_auth,如果使用db_auth的话,直接将auth_mode修改为db_auth即可,ldap的配置不再需要。
auth_mode = ldap_auth
ldap_url = ldap://10.1.1.1:389
ldap_searchdn = CN=jenkins,OU=LDAP,OU=Dev-wh.xxx.com,DC=dev-wh,DC=xxx,DC=com
ldap_search_pwd = xxxx
ldap_basedn = OU=Dev-wh.xxx.com,DC=dev-wh,DC=xxx,DC=com
ldap_filter = (objectClass=person)
ldap_uid = 0
ldap_scope = 3
ldap_timeout = 5
self_registration = on
token_expiration = 30
project_creation_restriction = everyone
verify_remote_cert = on
harbor支持docker-compose和kubernetes的部署方式,我这里直接采用docker-compose作单机部署。docker-compose文件在源码中也有示例,也是在make目录下,名称为docker-compose.tpl,我们修改为docker-compose.yml,然后在对其稍作修改,如下:
version: ‘2‘
services:
log:
image: vmware/harbor-log:v1.5.0-chart-patch
container_name: harbor-log
restart: always
volumes:
- /var/log/harbor/:/var/log/docker/:z
- /etc/localtime:/etc/localtime
ports:
- 127.0.0.1:1514:10514
networks:
- harbor
registry:
image: vmware/registry:2.6.2-photon
container_name: registry
restart: always
volumes:
- /data/registry:/storage:z
- ./common/config/registry/:/etc/registry/:z
- /etc/localtime:/etc/localtime
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.0-chart-patch
container_name: harbor-db
restart: always
volumes:
- /data/database:/var/lib/mysql:z
- /etc/localtime:/etc/localtime
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.0-chart-patch
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
- /etc/localtime:/etc/localtime
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.0-chart-patch
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
- /data/secretkey:/etc/ui/key:z
- /data/ca_download/:/etc/ui/ca/:z
- /etc/localtime:/etc/localtime
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.0-chart-patch
container_name: harbor-jobservice
env_file:
- ./common/config/jobservice/env
restart: always
volumes:
- /data/job_logs:/var/log/jobs:z
- ./common/config/jobservice/app.conf:/etc/jobservice/app.conf:z
- /data/secretkey:/etc/jobservice/key:z
- /etc/localtime:/etc/localtime
networks:
- harbor
depends_on:
- ui
- adminserver
logging:
driver: "syslog"
options:
syslog-address: "tcp://127.0.0.1:1514"
tag: "jobservice"
proxy:
image: vmware/nginx-photon:v1.5.0-chart-patch
container_name: nginx
restart: always
volumes:
- ./common/config/nginx:/etc/nginx:z
- /etc/localtime:/etc/localtime
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
配置文件和docker-compose.yml文件都修改完成以后,执行./install.sh进行启动。
正常启动之后,配置完成。
可以通过如下方式访问: https://hub.dz11.com
需要说明的是,harbor支持http和https,但如果使用http的话,在拉取镜像的时候,会抛出仓库不受信任的异常。需要在所有的docker客户端的docker配置文件/etc/docker/daemon.json中添加如下配置:
{
"insecure-registries": ["http://hub.dz11.com"],
}
如果使用自签名的https证书,仍然会提示证书不受信任的问题。需要将自签名的ca证书发送到所有的docker客户端的指定目录。
关于使用自签名证书配置harbor的具体过程可以参考:https://github.com/WingkaiHo/docker-calico/blob/master/harbor/README.md
标签:secret 提示 收集 hub 执行 相关 source Kubernete ide
原文地址:https://www.cnblogs.com/breezey/p/9111894.html