首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Kubernetes集群搭建之企业级环境中基于Harbor搭建自己的私有仓库

Kubernetes集群搭建之企业级环境中基于Harbor搭建自己的私有仓库

作者头像
程序员同行者
发布2019-03-15 15:09:15
7560
发布2019-03-15 15:09:15
举报
image
image

搭建背景


企业环境中使用Docker环境,一般出于安全考虑,业务使用的镜像一般不会从第三方公共仓库下载。那么就要引出今天的主题

企业级环境中基于Harbor搭建自己的安全认证仓库

介绍


名称:Harbor

官网:https://github.com/vmware/harbor

简介:Harbor是一个用于存储和分发Docker镜像的企业级Registry服务器,通过添加一些企业必需的功能特性,例如安全、标识和管理等,扩展了开源Docker Distribution。作为一个企业级私有Registry服务器,Harbor提供了更好的性能和安全。提升用户使用Registry构建和运行环境传输镜像的效率。Harbor支持安装在多个Registry节点的镜像资源复制,镜像全部保存在私有Registry中, 确保数据和知识产权在公司内部网络中管控。另外,Harbor也提供了高级的安全特性,诸如用户管理,访问控制和活动审计等。

部署Harbor


Harbor是基于Docker-Compose进行编排的,需要配合Docker和Docker-compose使用。Docker的安装可以看我的另一篇文章

下载Docker-Compose最新稳定版


[root@harbor-01 hub]# pwd/opt/hub[root@harbor-01 hub]# curl -L https://github.com/docker/compose/releases/download/1.23.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose

ps: 可能会报错Peer reports incompatible or unsupported protocol version.,升级下curl就行

添加可执行权限


[root@harbor-01 hub]# chmod +x /usr/local/bin/docker-compose

验证版本


[root@harbor-01 hub]# docker-compose -vdocker-compose version 1.23.2, build 1110ad01

解压安装包



[root@harbor-01 hub]# ls-rw-r--r-- 1 root root 541535889 Mar 4 18:52 harbor-offline-installer-v1.7.3.tgz[root@harbor-01 hub]# tar xf harbor-offline-installer-v1.7.3.tgz

修改配置


主要修改hostname字段配置

[root@harbor-01 hub]# cd harbor/[root@harbor-01 hub]# vim harbor.cfghostname = hub.test.tech # 本机外网IP或域名,该地址供用户通过UI进行访问,不要使用127.0.0.1ui_url_protocol = http # 用户访问私仓时使用的协议,默认时httpdb_password = root123    # 指定mysql数据库管理员密码harbor_admin_password:Harbor12345 # harbor的管理员账户密码

通过官方一键脚本安装


[root@harbor-01 hub]#./install.sh......[Step 4]: starting Harbor ...Creating network "harbor_harbor" with the default driverCreating harbor-log ... doneCreating harbor-db ... doneCreating registryctl ... doneCreating registry ... doneCreating harbor-adminserver ... doneCreating redis ... doneCreating harbor-core ... doneCreating harbor-portal ... doneCreating harbor-jobservice ... doneCreating nginx ... done✔ ----Harbor has been installed and started successfully.----Now you should be able to visit the admin portal at http://hub.test.tech. For more details, please visit https://github.com/goharbor/harbor .

测试登陆


[root@harbor-01 harbor]# docker login hub.test.techUsername: adminPassword: WARNING! Your password will be stored unencrypted in /root/.docker/config.json.Configure a credential helper to remove this warning. Seehttps://docs.docker.com/engine/reference/commandline/login/#credentials-storeLogin Succeeded

在windows上用域名访问需要绑定下hosts即可

image
image

默认账号密码 admin  Harbor12345

使用


我这里创建个mytest的公开项目做测试(不使用默认的library)。公开项目pull不需要登录,push需要登录

image
image

接下来我们试下推个镜像到Harbor的mytest项目中,这里我以公共镜像goharbor/nginx-photon:v1.7.3镜像为例 ,需要注意的是要往私有仓库推镜像就得打个tag才行 指明要推往哪个仓库并标注标签

注意:我这里使用的这个域名是自定义的,那么需要在需要上传下载镜像的机器上添加hosts绑定,因为我这没开启https所有也要修改docker配置

[root@harbor-01 ~]# cat /etc/docker/daemon.json {"insecure-registries": ["hub.test.tech"]}

重启docker即可

[root@harbor-01 harbor]# docker images|grep nginx-photongoharbor/nginx-photon v1.7.3 9d8222585538 3 weeks ago 35.6MB[root@hub harbor]# docker tag goharbor/nginx-photon:v1.7.3 hub.test.tech/mytest/nginx-photon:v1[root@harbor-01 harbor]# docker push hub.test.tech/mytest/nginx-photon:v1The push refers to repository [hub.test.tech/mytest/nginx-photon]f08bfdb20f6f: Pushed 8e45c790c209: Pushed v1: digest: sha256:03d473217d79c40c3b4e0d6015098f8d16364707980e12b5e7330ac76938d16a size: 739

可以看到push成功,我们去页面上看看

image
image

pull演示


点击镜像详情可以看到具体标签版本,鼠标放在"pull命令"图标上可以获取命令

image
image
[root@harbor-01 harbor]# docker pull hub.test.tech/mytest/nginx-photon:v1v1: Pulling from mytest/nginx-photonDigest: sha256:03d473217d79c40c3b4e0d6015098f8d16364707980e12b5e7330ac76938d16aStatus: Downloaded newer image for hub.test.tech/mytest/nginx-photon:v1

本篇介绍了Harbor的基本部署和使用,更多高级使用方法后续会分享。下一章介绍部署Etcd集群,敬请期待,谢谢!

往期文章一览

1、Kubernetes集群搭建之系统初始化配置篇

END

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019-03-10 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
容器镜像服务
容器镜像服务(Tencent Container Registry,TCR)为您提供安全独享、高性能的容器镜像托管分发服务。您可同时在全球多个地域创建独享实例,以实现容器镜像的就近拉取,降低拉取时间,节约带宽成本。TCR 提供细颗粒度的权限管理及访问控制,保障您的数据安全。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档