centos7搭建harbor镜像仓库

来源:互联网 发布:糜烂网络上是什么意思 编辑:程序博客网 时间:2024/05/17 15:21

一、环境依赖

 Python 2.7或以上 Docker 1.10或以上 Docker Compose 1.6.0或以上

二、安装过程:(centos7 自带Python 2.7,并我自己安装了docker 1.13)

1、安装pip

wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-1.4.2.tar.gztar -vxf setuptools-1.4.2.tar.gz cd setuptools-1.4.2python2.7 setup.py installeasy_install-2.7 pip

2、安装docker compose

pip install docker-composedocker-compose --version

3、在线安装harbor

3.1下载相关gz包

链接地址: https://github.com/vmware/harbor/releases

3.2:解压

tar xvf harbor-online-installer-0.5.0.tgz

3.3:修改配置文件

cd harbor harbor.cfg内容hostname:目标主机的主机名,用于访问UI和注册表服务。它应该是目标计算机的IP地址或完全限定域名(FQDN),例如192.168.1.10或reg.yourdomain.com。不要使用localhost或127.0.0.1用于主机名 - 注册表服务需要由外部客户端访问!ui_url_protocol:(http或https。默认为http)用于访问UI和令牌/通知服务的协议。默认情况下,这是http。要设置https协议,请参阅使用HTTPS访问配置Harbor。电子邮件设置:Harbor需要这些参数才能向用户发送“密码重置”电子邮件,并且只有在需要该功能时才需要。还有,千万注意,在默认情况下SSL连接是没有启用-如果你的SMTP服务器需要SSL,但不支持STARTTLS,那么你应该通过设置启用SSL email_ssl = TRUE。email_server = smtp.mydomain.comemail_server_port = 25email_username = sample_admin@mydomain.comemail_password = abcemail_from = admin \<sample_admin@mydomain.com\>email_ssl = falseharbour_admin_password:管理员的初始密码。此密码仅在港口首次发布时生效。之后,将忽略此设置,并且应在UI中设置管理员的密码。请注意,默认用户名/密码为admin / Harbor12345。auth_mode:使用的认证类型。默认情况下,它是db_auth,即凭据存储在数据库中。对于LDAP认证,请将其设置为ldap_auth。ldap_url:LDAP端点URL(例如ldaps://ldap.mydomain.com)。 仅当auth_mode设置为ldap_auth时使用。ldap_searchdn:具有搜索LDAP / AD服务器(例如uid=admin,ou=people,dc=mydomain,dc=com)的权限的用户的DN 。ldap_search_pwd:由指定的用户的密码ldap_searchdn。ldap_basedn:查找用户的基本DN,例如ou=people,dc=mydomain,dc=com。 仅当auth_mode设置为ldap_auth时使用。ldap_filter:用于查找用户的搜索过滤器,例如(objectClass=person)。ldap_uid:用于在LDAP搜索期间匹配用户的属性,可以是uid,cn,电子邮件或其他属性。ldap_scope:用于搜索用户的范围,1-LDAP_SCOPE_BASE,2-LDAP_SCOPE_ONELEVEL,3-LDAP_SCOPE_SUBTREE。默认值为3。db_password:用于db_auth的MySQL数据库的根密码。更改此密码以用于任何生产使用!self_registration:(on或off。默认为on)启用/禁用用户注册自己的能力。禁用时,新用户只能由管理员用户创建,只有管理员用户才能在Harbor中创建新用户。 注意:当auth_mode设置为ldap_auth时,将始终禁用自注册功能,并且将忽略此标志。use_compressed_js:(on或off。默认为on)对于生产使用,将此标志设置为on。在开发模式下,将其设置为off,以便可以单独修改js文件。max_job_workers:(缺省值为3)作业服务中的最大复制worker数。对于每个图像复制作业,工作程序将存储库的所有标记同步到远程目标。增加此数量允许系统中更多的并发复制作业。但是,由于每个工人消耗一定量的网络/ CPU / IO资源,请根据主机的硬件资源仔细选择此属性的值。token_expiration:令牌服务创建的令牌的过期时间(以分钟为单位),默认为30分钟。verify_remote_cert:(on或off。默认为on)此标志确定当Harbor与远程注册表实例通信时是否验证SSL / TLS证书。将此属性设置为关闭将绕过SSL / TLS验证,这通常在远程实例具有自签名或不受信任的证书时使用。customize_crt:(on或off。默认为on)当此属性打开时,prepare脚本创建用于生成/验证注册表令牌的私钥和根证书。以下属性:crt_country,crt_state,crt_location,crt_organization,crt_organizationalunit,crt_commonname,crt_email用作生成密钥的参数。当密钥和根证书由外部源提供时,将此属性设置为off。后端存储配置(这块其实就是对registry进行配置)vim common/templates/registry/config.yml看到没,这块其实就是去改registry的配置文件。然后具体想怎么改,就看你心情了。改完了然后docker compse就把这玩意C进去了。version: 0.1log:  level: debug  fields:service: registrystorage:cache:    layerinfo: inmemoryfilesystem:    rootdirectory: /storagemaintenance:    uploadpurging:        enabled: falsedelete:    enabled: truehttp:addr: :5000secret: placeholderdebug:    addr: localhost:5001auth:  token:issuer: registry-token-issuerrealm: $ui_url/service/tokenrootcertbundle: /etc/registry/root.crtservice: token-service

3.4 安装和启动

./install.sh注意事项:    A、这个脚本有点操蛋,1、ldap相关不能注释掉,不用也不能注释掉 2、hostname =reg.xx.com默认的不能有,注释掉也不行哦。    B、在线安装需要去拉镜像 vmware/harbor-ui:0.5.0 一般会很慢,可以换成国内的来拉,我换成了daocloud,结果快乐很多。    看下直接结果:(因为之前安装没有配国内的,所以链接超时,我陪了daocloud后,又重新执行了一遍)[Step 0]: checking installation environment ...Note: docker version: 1.13.0Note: docker-compose version: 1.11.2[Step 1]: preparing environment ...loaded secret keyClearing the configuration file: ./common/config/ui/envClearing the configuration file: ./common/config/ui/app.confClearing the configuration file: ./common/config/ui/private_key.pemClearing the configuration file: ./common/config/db/envClearing the configuration file: ./common/config/jobservice/envClearing the configuration file: ./common/config/jobservice/app.confClearing the configuration file: ./common/config/registry/config.ymlClearing the configuration file: ./common/config/registry/root.crtClearing the configuration file: ./common/config/nginx/nginx.confGenerated configuration file: ./common/config/nginx/nginx.confGenerated configuration file: ./common/config/ui/envGenerated configuration file: ./common/config/ui/app.confGenerated configuration file: ./common/config/registry/config.ymlGenerated configuration file: ./common/config/db/envGenerated configuration file: ./common/config/jobservice/envGenerated configuration file: ./common/config/jobservice/app.confGenerated configuration file: ./common/config/ui/private_key.pemGenerated configuration file: ./common/config/registry/root.crtThe configuration files are ready, please use docker-compose to start the service.[Step 2]: checking existing instance of Harbor ...[Step 3]: starting Harbor ...Pulling log (vmware/harbor-log:0.5.0)...0.5.0: Pulling from vmware/harbor-log93b3dcee11d6: Pull complete5c14e4bdfb0b: Pull completee4dee8a574ca: Pull complete64897311fadc: Pull complete9b18f82d0181: Pull completeDigest: sha256:81db268fa32ed35274f88f0e9f6e8c8fe36fdfe3247a7c75cef3d526814755adStatus: Downloaded newer image for vmware/harbor-log:0.5.0Pulling ui (vmware/harbor-ui:0.5.0)...0.5.0: Pulling from vmware/harbor-ui93b3dcee11d6: Already existsa91de92f52f5: Pull complete341612b46e3b: Pull completec1a53f812656: Pull complete9a9aa413559a: Pull completee1b377650dfc: Pull completebe5517028022: Pull complete726f4e0b4799: Pull complete08639f4ec97a: Pull completeDigest: sha256:677776af19c774f665565486ef0ec3ab37e55c6738a471942e3ea841b3e1821cStatus: Downloaded newer image for vmware/harbor-ui:0.5.0Pulling mysql (vmware/harbor-db:0.5.0)...0.5.0: Pulling from vmware/harbor-db43c265008fae: Pull completed7abd54d3b34: Pull complete92b527830a1b: Pull complete44839710d611: Pull complete3828a16bed5c: Pull completefb91763f6b4e: Pull complete892bfb27c685: Pull complete02874ec7a2dc: Pull complete861c1296cc0d: Pull completed611998d5598: Pull complete09037dc5a941: Pull complete448973dd2180: Pull completec0a51ede01de: Pull complete54c4b53ba168: Pull completeDigest: sha256:4bc45566b8aab9288e76ac8a36e604aecf05ba9b25e22f5a9cd5e9686978b78bStatus: Downloaded newer image for vmware/harbor-db:0.5.0Pulling jobservice (vmware/harbor-jobservice:0.5.0)...0.5.0: Pulling from vmware/harbor-jobservice93b3dcee11d6: Already existsa91de92f52f5: Already existscdeb4de41efe: Pull completece3594a70659: Pull completeDigest: sha256:9c2d927f6e59fafcc930a5f738d713bde7d101cecd4e110a570a7b499d69ff68Status: Downloaded newer image for vmware/harbor-jobservice:0.5.0Pulling registry (library/registry:2.5.0)...2.5.0: Pulling from library/registrye110a4a17941: Pull complete2ee5ed28ffa7: Pull completed1562c23a8aa: Pull complete06ba8e23299f: Pull complete802d2a9c64e8: Pull completeDigest: sha256:1b68f0d54837c356e353efb04472bc0c9a60ae1c8178c9ce076b01d2930bcc5dStatus: Downloaded newer image for registry:2.5.0Pulling proxy (nginx:1.11.5)...1.11.5: Pulling from library/nginx386a066cd84a: Pull complete7bdb4b002d7f: Pull complete49b006ddea70: Pull completeDigest: sha256:9038d5645fa5fcca445d12e1b8979c87f46ca42cfb17beb1e5e093785991a639Status: Downloaded newer image for nginx:1.11.5Creating harbor-logCreating registryCreating harbor-dbCreating harbor-uiCreating nginxCreating harbor-jobservice✔ ----Harbor has been installed and started successfully.----Now you should be able to visit the admin portal at http://172.19.136.155. For more details, please visit https://github.com/vmware/harbor .

3.5访问页面

这里写图片描述


小笨驴在吃草的时候创建了微信公众号,为方便更多觅食的“小笨驴”,为大家准备了大量的免费基础教学资料以及技术解决方案,还会定时发布一些好的技术文章,当然也会扯扯蛋、谈谈人生、呵呵,希望我们这群乐于分享技术的“小笨驴”团队越来越大!(技术干货分享群qq:128015753)


这里写图片描述

0 0
原创粉丝点击