Ubuntu18.04 Server安装Harbor
Harbor是一个开源的本地部署的容器镜像注册中心, 带访问权限控制, 以及管理界面. 作用类似于Java中Maven的私有仓库Nexus, 用于配合Jenkins在部署容器到K8s时提供镜像源, 加快创建速度, 同时其内网属性也能在很大程度上保证私有项目的代码安全.
准备工作
目标服务器为Ubuntu18.04 Server, 已经安装并配置好Docker.
Harbor项目地址: https://github.com/goharbor/harbor
Harbor安装说明: https://github.com/goharbor/harbor/blob/master/docs/installation_guide.md
下载offline安装包: https://github.com/vmware/harbor/releases
安装说明
Harbor支持K8s部署, 但一般还是建议单独部署.
Harbor的安装, 实际上是将一系列的容器安装到本地的docker, 其中包含了Nginx, PostgreSQL, Redis以及log服务. 而offline安装包中已经包含这些容器镜像, 避免安装时再下载.
解压后修改harbor.yml, 默认只需要修改hostname为当前主机IP
wget https://github.com/goharbor/harbor/releases/download/v1.9.4/harbor-offline-installer-v1.9.4.tgz tar zxvf harbor-offline-installer-v1.9.4.tgz cd harbor/ vi harbor.yml
安装
sudo ./install.sh
安装之后, 就可以用harbor.yml中配置的hostname和端口来访问了. 默认的用户是admin / Harbor12345
安装后启动的容器
$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c045e8393514 goharbor/harbor-jobservice:v1.9.4 "/harbor/harbor_jobs…" 7 minutes ago Up 7 minutes (healthy) harbor-jobservice 9a3d65e5cdb0 goharbor/nginx-photon:v1.9.4 "nginx -g ‘daemon of…" 7 minutes ago Up 7 minutes (healthy) 0.0.0.0:10080->8080/tcp nginx 44fc38b22688 goharbor/harbor-core:v1.9.4 "/harbor/harbor_core" 7 minutes ago Up 7 minutes (healthy) harbor-core 4224ea0eb383 goharbor/harbor-registryctl:v1.9.4 "/harbor/start.sh" 8 minutes ago Up 7 minutes (healthy) registryctl 772f94b49468 goharbor/registry-photon:v2.7.1-patch-2819-2553-v1.9.4 "/entrypoint.sh /etc…" 8 minutes ago Up 7 minutes (healthy) 5000/tcp registry 795c283eebcd goharbor/redis-photon:v1.9.4 "redis-server /etc/r…" 8 minutes ago Up 7 minutes (healthy) 6379/tcp redis a7050eeaf864 goharbor/harbor-db:v1.9.4 "/docker-entrypoint.…" 8 minutes ago Up 8 minutes (healthy) 5432/tcp harbor-db 0159e6e4a9ec goharbor/harbor-portal:v1.9.4 "nginx -g ‘daemon of…" 8 minutes ago Up 7 minutes (healthy) 8080/tcp harbor-portal 2fcc5620820a goharbor/harbor-log:v1.9.4 "/bin/sh -c /usr/loc…" 8 minutes ago Up 8 minutes (healthy) 127.0.0.1:1514->10514/tcp harbor-log
Harbor可以使用外部的PostgreSQL, 可以使用外部存储, 可以使用云存储azure, gcs, s3, swift, oss, 可以将日志推送到外部syslog服务器.
修改配置
修改配置需要先停止Harbor服务, 再修改harbor.yml, 最后启动Harbor服务
# 停止服务 sudo docker-compose down -v # 修改 vi harbor.yml # 应用 sudo ./prepare # 启动服务 sudo docker-compose up -d