1、Harbor介紹
Harbor是Vmvare中國團隊開發的開源registry倉庫,相比docker官方擁有更豐富的權限權利和完善的架構設計,適用大規模docker集群部署提供倉庫服務。
2、安裝環境(自行准備docker環境)
系統:centos7
docker版本:17.09 客戶端和服務器版本一致
compose:1.18
Harbor版本:1.3
3、環境准備
1)Harbor是通過docker的compose項目部署的,需要安裝compose,幸好compost 在git上提供了安裝指令:
curl -L https://github.com/docker/compose/releases/download/1.18.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose chmod +x /usr/local/bin/docker-compose #設置執行權限
docker-compose --version #查看安裝是否程成功
這是2條命令,先執行curl再執行chmod指令,下載過程可能會出現網絡問題,多嘗試幾次即可。
安裝截圖:
軟件git網址:https://github.com/docker/compose/releases
2)Harbor軟件安裝
harbor軟件網址:https://github.com/vmware/harbor/releases
此頁面提供源碼安裝和二進制安裝下載地址,不建議方式
鏡像網址:http://harbor.orientsoft.cn/
此頁面只提供離線下載安裝包,建議此種方式,在線安裝容易出現科學上網問題。
#下載離線安裝軟件 wget http://harbor.orientsoft.cn/harbor-v1.3.0-rc4/harbor-offline-installer-v1.3.0-rc4.tgz #解壓文件 tar -zxf harbor-offline-installer-v1.3.0-rc4.tgz
#解壓后的文件夾是harbor
解壓完成后:修改配置文件harbor.conf,如果是測試環境基本不用什么更改配置,主要就是hostname
[root@c7test_master harbor]# vim harbor.cfg ## Configuration file of Harbor #The IP address or hostname to access admin UI and registry service. #DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients. #主機地址,不可以設置為127或者localhost
hostname = 10.10.90.105 #The protocol for accessing the UI and token/notification service, by default it is http. #It can be set to https if ssl is enabled on nginx. ui_url_protocol = http #The password for the root user of mysql db, change this before any production use.
#mysql密碼 db_password = root123 #Maximum number of job workers in job service max_job_workers = 3 #Determine whether or not to generate certificate for the registry's token. #If the value is on, the prepare script creates new root cert and private key #for generating token to access the registry. If the value is off the default key/cert will be used. #This flag also controls the creation of the notary signer's cert. customize_crt = on #The path of cert and key files for nginx, they are applied only the protocol is set to https ssl_cert = /data/cert/server.crt ssl_cert_key = /data/cert/server.key #The path of secretkey storage secretkey_path = /data #Admiral's url, comment this attribute, or set its value to NA when Harbor is standalone admiral_url = NA #The password of the Clair's postgres database, only effective when Harbor is deployed with Clair. #Please update it before deployment, subsequent update will cause Clair's API server and Harbor unable to access Clair's database. clair_db_password = password #Log files are rotated log_rotate_count times before being removed. If count is 0, old versions are removed rather than rotated. log_rotate_count = 50 #Log files are rotated only if they grow bigger than log_rotate_size bytes. If size is followed by k, the size is assumed to be in kilobytes. #If the M is used, the size is in megabytes, and if G is used, the size is in gigabytes. So size 100, size 100k, size 100M and size 100G #are all valid. log_rotate_size = 200M #NOTES: The properties between BEGIN INITIAL PROPERTIES and END INITIAL PROPERTIES #only take effect in the first boot, the subsequent changes of these properties #should be performed on web ui #************************BEGIN INITIAL PROPERTIES************************ #Email account settings for sending out password resetting emails. #Email server uses the given username and password to authenticate on TLS connections to host and act as identity. #Identity left blank to act as username. email_identity = email_server = smtp.mydomain.com email_server_port = 25 email_username = sample_admin@mydomain.com email_password = abc email_from = admin <sample_admin@mydomain.com> email_ssl = false email_insecure = false ##The initial password of Harbor admin, only works for the first time when Harbor starts. #It has no effect after the first launch of Harbor. #Change the admin password from UI after launching Harbor.
#這里是web登錄頁面的密碼,可以更改 harbor_admin_password = Harbor12345 ##By default the auth mode is db_auth, i.e. the credentials are stored in a local database. #Set it to ldap_auth if you want to verify a user's credentials against an LDAP server. auth_mode = db_auth #The url for an ldap endpoint. ldap_url = ldaps://ldap.mydomain.com #A user's DN who has the permission to search the LDAP/AD server. #If your LDAP/AD server does not support anonymous search, you should configure this DN and ldap_search_pwd. #ldap_searchdn = uid=searchuser,ou=people,dc=mydomain,dc=com #the password of the ldap_searchdn #ldap_search_pwd = password #The base DN from which to look up a user in LDAP/AD ldap_basedn = ou=people,dc=mydomain,dc=com #Search filter for LDAP/AD, make sure the syntax of the filter is correct. #ldap_filter = (objectClass=person) # 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 ldap_uid = uid #the scope to search for users, 1-LDAP_SCOPE_BASE, 2-LDAP_SCOPE_ONELEVEL, 3-LDAP_SCOPE_SUBTREE ldap_scope = 3 #Timeout (in seconds) when connecting to an LDAP Server. The default value (and most reasonable) is 5 seconds. ldap_timeout = 5 #Turn on or off the self-registration feature self_registration = on #The expiration time (in minute) of token created by token service, default is 30 minutes token_expiration = 30 #The flag to control what users have permission to create projects #The default value "everyone" allows everyone to creates a project. #Set to "adminonly" so that only admin user can create project. project_creation_restriction = everyone #The follow configurations are for Harbor HA mode only #the address of the mysql database. db_host = mysql #The port of mysql database host db_port = 3306 #The user name of mysql database db_user = root #************************END INITIAL PROPERTIES************************ #The following attributes only need to be set when auth mode is uaa_auth uaa_endpoint = uaa.mydomain.org uaa_clientid= id uaa_clientsecret= secret uaa_ca_root= /path/to/uaa_ca.pem #############
啟動harbor,修改完配置文件就可以執行該目錄下的install.sh文件即可,程序會自動啟動相關鏡像,因為harbor是用你鏡像進行安裝的。
[root@c7test_master harbor]# ./install.sh
安裝截圖:
檢測環境及下載harbor相關鏡像,鏡像比較多,耐心等待。
安裝完成:
運行的容器:
訪問地址:http://10.10.90.105
登錄密碼是配置文件中的harbor_admin_password = Harbor12345
3)有關使用其實無非就是創建倉庫,上傳鏡像等操作
常見問題:
1、docker login報錯Error response from daemon: Get https://10.10.90.105/v2/: dial tcp 10.10.90.105:443: getsockopt: connection refused
解決方案:修改docekr參數
文件:/usr/lib/systemd/system/docker.service
修改完成后 執行:
[root@c7test_master ~]# systemctl daemon-reload
[root@c7test_master ~]# systemctl start docker
再次重啟我們的harbor,進入解壓的目錄並執行start會自動編排
查看是否啟動成功:
嘗試login:
login成功!!!!!!!!