k8s harbor镜像仓库

2022/4/7 23:20:20

本文主要是介绍k8s harbor镜像仓库,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

Harbor镜像仓库的安装及简单使用

https://github.com/goharbor/harbor/releases

https://www.cnblogs.com/ly159357/p/15420760.html

docker-compose.yml 文件修改

hostname: 192.168.1.226 
http:
  # port for http, default is 80. If https enabled, this port will redirect to https port
  port: 8123 

harbor_admin_password: 12345

  

wget https://storage.googleapis.com/harbor-releases/release-1.9.0/harbor-offline-installer-v1.9.0.tgz
解压
安装
./install.sh

 

浏览器访问 
http://192.168.1.226:8123/

 

Harbor在架构上主要有Proxy、 Registry、 Core services、 Database ( Harbor-db)、Log collector ( Harbor-log)、Job services六个组件。

1)Proxy: Harbor 的 Registry、 UI、Token 服务等组件,都处在nginx反向代理后边。该代理将来自浏览器、docker clients
的请求转发到后端不同的服务上。

2)Registry:负责储存Docker 镜像,并处理Docker push/pull命令。由于要对用户进行访问控制,即不同用户对Docker 镜像
有不同的读写权限,Registry 会指向一个Token 服务,强制用户的每次Docker pull/push 请求都要携带一个合法的Token,
Registry会通过公钥对Token进行解密验证。

3)Core services:Harbor的核心功能,主要提供以下3个服务:

UI (harbor-ui) :提供图形化界面,帮助用户管理Registry上的镜像 (image) ,并对用户进行授权。
WebHook:为了及时获取Registry上image 状态变化的情况,在Registry上配置 Webhook, 把状态变化传递给 UI 模块。
Token 服务:负责根据用户权限给每个Docker push/pull 命令签发Token。 Docker 客户端向Registry 服务发起的请求,
如果不包含Token,会被重定向到 Token 服务,获得 Token 后再重新向Registry 进行请求。
4)Database (harbor -db) :为core services提供数据库服务,负责储存用户权限、审计日志、Docker 镜像分组信息等数据。

5)Job services:主要用于镜像复制,本地镜像可以被同步到远程Harbor实例上。

6)Log collector (harbor-log) :负责收集其他组件的日志到一个地方。

Harbor 的每个组件都是以 Docker 容器的形式构建的,因此,使用 Docker Compose 来对它进行部署。

总共分为7个容器运行,通过在 docker- compose.yml 所在目录中执行 docker-compose ps命令来查看, 名称分别为:nginx、 harbor-jobservice、 harbor-ui、 harbor-db、 harbor-adminserver、registry、 harbor-log。

其中 harbor-adminserver 主要是作为一个后端的配置数据管理,并没有太多的其他功能。harbor-ui 所要操作的所有数据都通过 harbor-adminserver 这样一个数据配置管理中心来完成。


82e5c74e378e   goharbor/nginx-photon:v1.9.0                        "nginx -g 'daemon of…"   47 hours ago        Up 9 minutes (healthy)   0.0.0.0:8123->8080/tcp      nginx
7adeb5bf9249   goharbor/harbor-jobservice:v1.9.0                   "/harbor/harbor_jobs…"   47 hours ago        Up 9 minutes (healthy)                               harbor-jobservice
b7f3eeba908f   goharbor/harbor-core:v1.9.0                         "/harbor/harbor_core"    47 hours ago        Up 9 minutes (healthy)                               harbor-core
99ff9b666695   goharbor/registry-photon:v2.7.1-patch-2819-v1.9.0   "/entrypoint.sh /etc…"   47 hours ago        Up 9 minutes (healthy)   5000/tcp                    registry
e121f331e9a5   goharbor/harbor-portal:v1.9.0                       "nginx -g 'daemon of…"   47 hours ago        Up 9 minutes (healthy)   8080/tcp                    harbor-portal
abeaf49cd212   goharbor/redis-photon:v1.9.0                        "redis-server /etc/r…"   47 hours ago        Up 9 minutes (healthy)   6379/tcp                    redis
d5e0e412c840   goharbor/harbor-db:v1.9.0                           "/docker-entrypoint.…"   47 hours ago        Up 9 minutes (healthy)   5432/tcp                    harbor-db
3f77715c1983   goharbor/harbor-registryctl:v1.9.0                  "/harbor/start.sh"       47 hours ago        Up 9 minutes (healthy)                               registryctl
2cbcd4533ea4   goharbor/harbor-log:v1.9.0                          "/bin/sh -c /usr/loc…"   47 hours ago        Up 9 minutes (healthy)   127.0.0.1:1514->10514/tcp   harbor-log

 

[root@k8s-node02 harbor]# docker-compose ps
NAME                COMMAND                  SERVICE             STATUS              PORTS
harbor-core         "/harbor/harbor_core"    core                running (healthy)   
harbor-db           "/docker-entrypoint.…"   postgresql          running (healthy)   5432/tcp
harbor-jobservice   "/harbor/harbor_jobs…"   jobservice          running (healthy)   
harbor-log          "/bin/sh -c /usr/loc…"   log                 running (healthy)   127.0.0.1:1514->10514/tcp
harbor-portal       "nginx -g 'daemon of…"   portal              running (healthy)   8080/tcp
nginx               "nginx -g 'daemon of…"   proxy               running (healthy)   0.0.0.0:8123->8080/tcp
redis               "redis-server /etc/r…"   redis               running (healthy)   6379/tcp
registry            "/entrypoint.sh /etc…"   registry            running (healthy)   5000/tcp
registryctl         "/harbor/start.sh"       registryctl         running (healthy)   

  

 

  

重启   cd /root/harbor; docker-compose stop &&  docker-compose up -d

 [root@k8s-node02 harbor]# docker-compose stop
[+] Running 9/9
 ⠿ Container nginx              Stopped                                                                             0.0s
 ⠿ Container harbor-jobservice  Stopped                                                                             0.6s
 ⠿ Container registryctl        Stopped                                                                             0.0s
 ⠿ Container harbor-portal      Stopped                                                                             0.0s
 ⠿ Container harbor-core        Stopped                                                                             0.0s
 ⠿ Container harbor-db          Stopped                                                                            11.4s
 ⠿ Container registry           Stopped                                                                             0.0s
 ⠿ Container redis              Stopped                                                                             0.0s
 ⠿ Container harbor-log         Stopped                                                                            11.2s
[root@k8s-node02 harbor]# docker-compose up -d
[+] Running 9/9
 ⠿ Container harbor-log         Started                                                                             2.7s
 ⠿ Container harbor-db          Started                                                                             9.6s
 ⠿ Container harbor-portal      Started                                                                             8.7s
 ⠿ Container redis              Started                                                                            10.1s
 ⠿ Container registry           Started                                                                             8.6s
 ⠿ Container registryctl        Started                                                                             8.7s
 ⠿ Container harbor-core        Started                                                                            14.0s
 ⠿ Container harbor-jobservice  Started                                                                            26.0s
 ⠿ Container nginx              Started  

  



这篇关于k8s harbor镜像仓库的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程