harbor部署
4 min read

harbor部署

下载harbor二进制安装包

harbor-online-installer-v1.8.1.tgz

解压安装
[root@k8s-master-01 ~]# tar xf harbor-online-installer-v1.8.1.tgz
[root@k8s-master-01 ~]# ll
总用量 15
-rw-------. 1 root root 1413 11月  2 11:01 anaconda-ks.cfg
drwxr-xr-x. 2 root root   72 11月  4 10:10 harbor
-rwxr-xr-x. 1 root root 7953 11月  4 10:07 harbor-online-installer-v1.8.1.tgz
[root@k8s-master-01 ~]# ll harbor
总用量 32
-rw-r--r--. 1 root root  4519 6月  18 2019 harbor.yml
-rwxr-xr-x. 1 root root  5088 6月  18 2019 install.sh
-rw-r--r--. 1 root root 11347 6月  18 2019 LICENSE
-rwxr-xr-x. 1 root root  1654 6月  18 2019 prepare
编辑配置文件
[root@k8s-master-01 ~]# vi harbor/harbor.yml
hostname: harbor.fmmu.mtn
# 将hostname改成你本机的网址或IP
  • 使修改的配置文件生效
[root@k8s-master-01 ~]# ./harbor/prepare
prepare base dir is set to /root/harbor
Generated configuration file: /config/log/logrotate.conf
Generated configuration file: /config/nginx/nginx.conf
Generated configuration file: /config/core/env
Generated configuration file: /config/core/app.conf
Generated configuration file: /config/registry/config.yml
Generated configuration file: /config/registryctl/env
Generated configuration file: /config/db/env
Generated configuration file: /config/jobservice/env
Generated configuration file: /config/jobservice/config.yml
Generated and saved secret to file: /secret/keys/secretkey
Generated certificate, key file: /secret/core/private_key.pem, cert file: /secret/registry/root.crt
Generated configuration file: /compose_location/docker-compose.yml
Clean up the input dir

注意:
执行这一步命令需要用到下面的镜像,而且要确保hostname选项那里的域名是能正常解析的。
goharbor/prepare:v1.8.1

安装

安装需要依赖docker-compose(1.18.0+)。
可直接使用下面方式下载,也可使用我下载好的文件。

[root@k8s-master-01 ~]# curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
[root@k8s-master-01 ~]# chmod +x /usr/local/bin/docker-compose

docker-compose

[root@k8s-master-01 ~]# ./harbor/install.sh

[Step 0]: checking installation environment ...

Note: docker version: 18.03.1

Note: docker-compose version: 1.27.4


[Step 1]: preparing environment ...
prepare base dir is set to /root/harbor
Clearing the configuration file: /config/log/logrotate.conf
Clearing the configuration file: /config/nginx/nginx.conf
Clearing the configuration file: /config/core/env
Clearing the configuration file: /config/core/app.conf
Clearing the configuration file: /config/registry/config.yml
Clearing the configuration file: /config/registryctl/env
Clearing the configuration file: /config/registryctl/config.yml
Clearing the configuration file: /config/db/env
Clearing the configuration file: /config/jobservice/env
Clearing the configuration file: /config/jobservice/config.yml
Generated configuration file: /config/log/logrotate.conf
Generated configuration file: /config/nginx/nginx.conf
Generated configuration file: /config/core/env
Generated configuration file: /config/core/app.conf
Generated configuration file: /config/registry/config.yml
Generated configuration file: /config/registryctl/env
Generated configuration file: /config/db/env
Generated configuration file: /config/jobservice/env
Generated configuration file: /config/jobservice/config.yml
loaded secret from file: /secret/keys/secretkey
Generated configuration file: /compose_location/docker-compose.yml
Clean up the input dir



[Step 2]: starting Harbor ...
Creating harbor-log ... done
Creating registryctl ... done
Creating redis       ... done
Creating registry    ... done
Creating harbor-db   ... done
Creating harbor-core ... done
Creating harbor-jobservice ... done
Creating harbor-portal     ... done
Creating nginx             ... done

✔ ----Harbor has been installed and started successfully.----

Now you should be able to visit the admin portal at http://harbor.fmmu.mtn.
For more details, please visit https://github.com/goharbor/harbor .

[root@k8s-master-01 ~]# docker ps |grep harbor
a462a246ce99        goharbor/nginx-photon:v1.8.1                        "nginx -g 'daemon of…"   About a minute ago   Up About a minute (healthy)   0.0.0.0:5000->80/tcp                            nginx
efa6d19aa69e        goharbor/harbor-portal:v1.8.1                       "nginx -g 'daemon of…"   About a minute ago   Up About a minute (healthy)   80/tcp                                          harbor-portal
8da71f2a43e5        goharbor/harbor-jobservice:v1.8.1                   "/harbor/start.sh"       About a minute ago   Up About a minute                                                             harbor-jobservice
6d8a0b979043        goharbor/harbor-core:v1.8.1                         "/harbor/start.sh"       About a minute ago   Up About a minute (healthy)                                                   harbor-core
a600d41eb70f        goharbor/registry-photon:v2.7.1-patch-2819-v1.8.1   "/entrypoint.sh /etc…"   About a minute ago   Up About a minute (healthy)   5000/tcp                                        registry
9d4a8de7dbe8        goharbor/harbor-db:v1.8.1                           "/entrypoint.sh post…"   About a minute ago   Up About a minute (healthy)   5432/tcp                                        harbor-db
107b671c5fe6        goharbor/redis-photon:v1.8.1                        "docker-entrypoint.s…"   About a minute ago   Up About a minute             6379/tcp                                        redis
6e5c75493b5e        goharbor/harbor-registryctl:v1.8.1                  "/harbor/start.sh"       About a minute ago   Up About a minute (healthy)                                                   registryctl
c493afcdaf28        goharbor/harbor-log:v1.8.1                          "/bin/sh -c /usr/loc…"   About a minute ago   Up About a minute (healthy)   127.0.0.1:1514->10514/tcp                       harbor-log
启动
  • 停止服务: docker-compose stop
  • 开始服务: docker-compose start

所需要的镜像:

验证

在浏览器输入http://192.168.9.27:5000回车(这里的5000是harbor.yml里面设置的,默认80)


输入用户名和密码之后,点击登录

命令行验证:

# cat /etc/docker/daemon.json
{
  "insecure-registries": [
    "harbor.fmmu.mtn:5000"
  ]
}
# systemctl restart docker
[root@k8s-master-01 docker-server]# docker login http://harbor.fmmu.mtn:5000
Username: admin
Password:
Login Succeeded
[root@k8s-master-01 docker-server]# docker push harbor.fmmu.mtn:5000/xuetangx/forum:master-20200628b234d03dcb32c8e
京ICP备19055754号