harbor单机安装

Harbor 是一个企业级 Registry 服务。它对开源的 Docker Registry 服务进行了扩展,添加了更多企业用户需要的功能。Harbor 被设计用于部署一套组织内部使用的私有环境,这个私有 Registry 服务对于非常关心安全的组织来说是十分重要的。另外,私有 Registry 服务可以通过避免从公域网下载镜 像而提高企业生产力。这对于没有良好的 Internet 连接状态,使用 Docker Container 的用户是一个福音。

  • 基于角色的访问控制:用户与 Docker 镜像仓库通过“项目”进行组织管理,一个用户可以对多个镜像仓库在同一命名空间(project)里有不同的权限。

  • 图形化用户界面:用户可以通过浏览器来浏览,检索当前 Docker 镜像仓库,管理项目和命名空间。

  • 审计管理:所有针对镜像仓库的操作都可以被记录追溯,用于审计管理。

  • 国际化:基于英文与中文语言进行了本地化。可以增加更多的语言支持。

  • RESTful API - RESTful API:提供给管理员对于 Harbor 更多的操控, 使得与其它管理软件集成变得更容易。

环境

OS:ubuntu server 16.04

python2.7

docker 1.10.0+

docker-compose 1.7.1+


服务器端配置

下载安装包

   
   
  1. wget https://github.com/vmware/harbor/releases/download/0.5.0/harbor-online-installer-0.5.0.tgz

harbor 主要的安装文件harbor.cfg、install.sh、prepare

harbor.cfg用于配置安装安装选项

install.sh主要用于环境检查并根据harbor.cfg调用prepare生成harbor相关组件的配置文件及docker-compose.yml


创建字签名ssl证书
   
   
  1. openssl req \
  2.  -newkey rsa:4096 -nodes -sha256 -keyout harbor.xxx.com.key \
  3.  -x509 -days 3650 -out harbor.xxx.com.crt
    
    
  1. Generating a 4096 bit RSA private key
  2. .................................++
  3. ............................++
  4. unable to write 'random state'
  5. writing new private key to 'harbor.xxx.com.key'
  6. -----
  7. You are about to be asked to enter information that will be incorporated
  8. into your certificate request.
  9. What you are about to enter is what is called a Distinguished Name or a DN.
  10. There are quite a few fields but you can leave some blank
  11. For some fields there will be a default value,
  12. If you enter '.', the field will be left blank.
  13. -----
  14. Country Name (2 letter code) [AU]:CN
  15. State or Province Name (full name) [Some-State]:Beijing
  16. Locality Name (eg, city) []:Beijing
  17. Organization Name (eg, company) [Internet Widgits Pty Ltd]:xxx
  18. Organizational Unit Name (eg, section) []:xxx
  19. Common Name (e.g. server FQDN or YOUR name) []:harbor.xxx.com
  20. Email Address []:


配置harbor.cfg文件

    
    
  1. ## Configuration file of Harbor
  2. #The IP address or hostname to access admin UI and registry service.
  3. #DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients.
  4. hostname = harbor.xxx.com
  5. #The protocol for accessing the UI and token/notification service, by default it is http.
  6. #It can be set to https if ssl is enabled on nginx.
  7. ui_url_protocol = https
  8. #Email account settings for sending out password resetting emails.
  9. #Email server uses the given username and password to authenticate on TLS connections to host and act as identity.
  10. #Identity left blank to act as username.
  11. email_identity = true
  12. email_server = smtp.xxx.com
  13. email_server_port = 25
  14. email_username = xxx@xxx.com
  15. email_password = xxxx
  16. email_from = admin <xxx@xxx.com>
  17. email_ssl = false
  18. ##The initial password of Harbor admin, only works for the first time when Harbor starts.
  19. #It has no effect after the first launch of Harbor.
  20. #Change the admin password from UI after launching Harbor.
  21. harbor_admin_password = Harbor12345
  22. ##By default the auth mode is db_auth, i.e. the credentials are stored in a local database.
  23. #Set it to ldap_auth if you want to verify a user's credentials against an LDAP server.
  24. auth_mode = db_auth
  25. #The url for an ldap endpoint.
  26. ldap_url = ldaps://ldap.mydomain.com
  27. #A user's DN who has the permission to search the LDAP/AD server.
  28. #If your LDAP/AD server does not support anonymous search, you should configure this DN and ldap_search_pwd.
  29. #ldap_searchdn = uid=searchuser,ou=people,dc=mydomain,dc=com
  30. #the password of the ldap_searchdn
  31. #ldap_search_pwd = password
  32. #The base DN from which to look up a user in LDAP/AD
  33. ldap_basedn = ou=people,dc=mydomain,dc=com
  34. #Search filter for LDAP/AD, make sure the syntax of the filter is correct.
  35. #ldap_filter = (objectClass=person)
  36. # The attribute used in a search to match a user, it could be uid, cn, email, sAMAccountName or other attributes depending on your LDAP/AD  
  37. ldap_uid = uid
  38. #the scope to search for users, 1-LDAP_SCOPE_BASE, 2-LDAP_SCOPE_ONELEVEL, 3-LDAP_SCOPE_SUBTREE
  39. ldap_scope = 3
  40. #The password for the root user of mysql db, change this before any production use.
  41. db_password = root123
  42. #Turn on or off the self-registration feature
  43. self_registration = on
  44. #Determine whether the UI should use compressed js files.
  45. #For production, set it to on. For development, set it to off.
  46. use_compressed_js = on
  47. #Maximum number of job workers in job service  
  48. max_job_workers = 3
  49. #The expiration time (in minute) of token created by token service, default is 30 minutes
  50. token_expiration = 30
  51. #Determine whether the job service should verify the ssl cert when it connects to a remote registry.
  52. #Set this flag to off when the remote registry uses a self-signed or untrusted certificate.
  53. verify_remote_cert = on
  54. #Determine whether or not to generate certificate for the registry's token.
  55. #If the value is on, the prepare script creates new root cert and private key
  56. #for generating token to access the registry. If the value is off, a key/certificate must
  57. #be supplied for token generation.
  58. customize_crt = on
  59. #Information of your organization for certificate
  60. crt_country = CN
  61. crt_state = State
  62. crt_location = CN
  63. crt_organization = organization
  64. crt_organizationalunit = organizational unit
  65. crt_commonname = example.com
  66. crt_email = example@example.com
  67. #The flag to control what users have permission to create projects
  68. #Be default everyone can create a project, set to "adminonly" such that only admin can create project.
  69. project_creation_restriction = everyone
  70. #The path of cert and key files for nginx, they are applied only the protocol is set to https
  71. ssl_cert = /data/cert/harbor.leju.com.crt
  72. ssl_cert_key = /data/cert/harbor.leju.com.key

主要配置项

hostname = harbor.xxx.com 用于配置ui以及registry访问主机名,必须与dns或hosts一致

ui_url_protocol = https 如果想通过https访问registry此项需要注意

复制签名到ssl_cert ssl_cert_key配置项相应位置

    
    
  1. cp harbor.xxx.com.crt harbor.xxx.com.key /data/cert/

执行install.sh完成安装

    
    
  1. sudo ./install.sh

客户端配置

修改/etc/hosts,添加如下内容
#resistry_server_ip  registry_domain_name
10.207.2.27  harbor.xxx.com
操作系统层面信任证书

ubuntu

scp develop@10.207.2.27:/home/develop/harbor/harbor.xxx.com.crt  /usr/local/share/ca-certificates/
update-ca-certificates

centos

scp develop@10.207.2.27:/home/develop/harbor/harbor.leju.com.crt  /etc/pki/ca-trust/source/anchors/
update-ca-trust
重新启动docker service
systemctl restart docker
首次使用需要登陆registry
docker login registry.xxx.com

Username: youruser    
Password: yourpassword
Email:


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值