github地址:
https://github.com/goharbor/harbor/blob/master/docs/installation_guide.md
硬件要求
软件要求
安装步骤
1、下载
地址:https://github.com/goharbor/harbor/releases
我这里选择离线下载,安装包比较大,时间稍微有点长
2、加压缩
tar zxf harbor-offline-installer-v1.6.1.tgz -C /usr/local/ cd /usr/local/
3、修改配置文件harbor.cfg
这里面有有必选项和可选项。
_version = 1.6.0 hostname = 192.168.179.130 ui_url_protocol = http max_job_workers = 3 customize_crt = on ssl_cert = /data/cert/server.crt ssl_cert_key = /data/cert/server.key secretkey_path = /data admiral_url = NA log_rotate_count = 50 log_rotate_size = 200M http_proxy = https_proxy = no_proxy = 127.0.0.1,localhost,ui,registry email_identity = email_server = smtp.mydomain.com email_server_port = 25 email_username = [email protected] email_password = abc email_from = admin <[email protected]> email_ssl = false email_insecure = false harbor_admin_password = Harbor12345 auth_mode = db_auth ldap_url = ldaps://ldap.mydomain.com ldap_basedn = ou=people,dc=mydomain,dc=com ldap_uid = uid ldap_scope = 2 ldap_timeout = 5 ldap_verify_cert = true ldap_group_basedn = ou=group,dc=mydomain,dc=com ldap_group_filter = objectclass=group ldap_group_gid = cn ldap_group_scope = 2 self_registration = on token_expiration = 30 project_creation_restriction = everyone db_host = postgresql db_password = root123 db_port = 5432 db_user = postgres redis_host = redis redis_port = 6379 redis_password = redis_db_index = 1,2,3 clair_db_host = postgresql clair_db_password = root123 clair_db_port = 5432 clair_db_username = postgres clair_db = postgres clair_updaters_interval = 12 uaa_endpoint = uaa.mydomain.org uaa_clientid = id uaa_clientsecret = secret uaa_verify_cert = true uaa_ca_cert = /path/to/ca.pem registry_storage_provider_name = filesystem registry_storage_provider_config = registry_custom_ca_bundle =
hostname改成生产环境域名或者IP。其他的根据自己的喜好更改,我都是默认
4、安装
执行./install.sh脚本即可。
Creating network "harbor_harbor" with the default driver Creating harbor-log ... done Creating registry ... done Creating harbor-adminserver ... done Creating redis ... done Creating harbor-db ... done Creating harbor-ui ... done Creating harbor-jobservice ... done Creating nginx ... done ✔ ----Harbor has been installed and started successfully.---- Now you should be able to visit the admin portal at http://192.168.179.130. For more details, please visit https://github.com/goharbor/harbor .
出现上面的提示表示安装完成。
5、访问 http:.//$hostname
使用默认的账号密码登录 admin/Harbor12345
登录后可以创建一个用户
使用创建的用户登录,并创建自定义的项目。
注意这里项目不是仓库,这里的项目可以创建多个仓库,如nginx,tomcat,mysql等等,它只是一个命名空间,我这里以环境创建了三个项目
修改docker客户端daemon.json配置文件,使docker客户端信任我们的harbor registry
{ "insecure-registries": ["192.168.179.130"] }
本地镜像打tag
docker tag 192.168.179.130/colby_httpd:v2.0-4 192.168.179.130/prod/colby_httpd:v1.0
使用创建的用户名登录docker harbor
[root@localhost harbor]# docker login 192.168.179.130 Username: colby Password: WARNING! Your password will be stored unencrypted in /root/.docker/config.json. Configure a credential helper to remove this warning. See https://docs.docker.com/engine/reference/commandline/login/#credentials-store Login Succeeded
推送镜像
# docker push 192.168.179.130/prod/colby_httpd:v1.0 The push refers to repository [192.168.179.130/prod/colby_httpd] 72ffebddfa9f: Pushed 8a788232037e: Pushed v1.0: digest: sha256:7d5610b23bc5575a3a46a7ddaa91ba6173dea4c775b613a010ea83c9b3dd7a7d size: 734