k8s--docker镜像私有仓库( harbor)

4 篇文章 0 订阅

安装1.7.6以上版本,在200那台主配置服务器上操作

1. 下载并解压导指定目录

[root@hdss-1-200 src]# ls
harbor-offline-installer-v1.8.3.tgz
[root@hdss-1-200 src]# tar -zxvf harbor-offline-installer-v1.8.3.tgz -C /opt/
harbor/harbor.v1.8.3.tar.gz
harbor/prepare
harbor/LICENSE
harbor/install.sh
harbor/harbor.yml
[root@hdss-1-200 opt]# ll
total 0
drwxr-xr-x  2 root root  71 Feb  8 12:13 certs
drwxr-xr-x  2 root root 100 Feb  8 12:49 harbor
drwxr-xr-x. 2 root root   6 Oct 30  2018 rh
drwxr-xr-x  2 root root  49 Feb  8 12:44 src

2.把软件包做版本标识,做一个软链接,便于以后升级

[root@hdss-1-200 opt]# mv harbor/ harbor-v1.8.3
[root@hdss-1-200 opt]# ln -s /opt/harbor-v1.8.3/ /opt/harbor
[root@hdss-1-200 opt]# ll
total 0
drwxr-xr-x  2 root root  71 Feb  8 12:13 certs
lrwxrwxrwx  1 root root  19 Feb  8 12:52 harbor -> /opt/harbor-v1.8.3/
drwxr-xr-x  2 root root 100 Feb  8 12:49 harbor-v1.8.3
drwxr-xr-x. 2 root root   6 Oct 30  2018 rh
drwxr-xr-x  2 root root  49 Feb  8 12:44 src
[root@hdss-1-200 opt]# 

3.编辑harbor文件

[root@hdss-1-200 opt]# cd harbor
[root@hdss-1-200 harbor]# ll
total 569632
-rw-r--r-- 1 root root 583269670 Sep 15  2019 harbor.v1.8.3.tar.gz
-rw-r--r-- 1 root root      4519 Sep 15  2019 harbor.yml
-rwxr-xr-x 1 root root      5088 Sep 15  2019 install.sh
-rw-r--r-- 1 root root     11347 Sep 15  2019 LICENSE
-rwxr-xr-x 1 root root      1654 Sep 15  2019 prepare
[root@hdss-1-200 harbor]# vi harbor.yml
5    hostname: harbor.od.com
10   port: 180
27   harbor_admin_password: Harbor12345
35   data_volume: /data/harbor
82   location: /data/harbor/logs	# 更改日志存储路径
[root@hdss-1-200 harbor]# mkdir -p /data/harbor/logs
[root@hdss-1-200 harbor]# 

 4.harbor单机编排依赖docker-compose,所以需要安装docker-compose

[root@hdss-1-200 harbor]#  yum install -y docker-compose
[root@hdss-1-200 harbor]#  rpm -qa docker-compose
docker-compose-1.18.0-4.el7.noarch

5.yml文件配置好之后.sh的可执行文件就可以用了 

[root@hdss-1-200 harbor]# ./install.sh 

[Step 0]: checking installation environment ...

Note: docker version: 20.10.3

Note: docker-compose version: 1.18.0

[Step 1]: loading Harbor images ...
b80136ee24a4: Loading layer [==================================================>]  34.25MB/34.25MB
88c6d2bb8c65: Loading layer [==================================================>]  63.49MB/63.49MB
2d2b1a3edc7d: Loading layer [==================================================>]  53.06MB/53.06MB
8f9195383bd6: Loading layer [==================================================>]  6.656kB/6.656kB
5ca164c40e26: Loading layer [==================================================>]  2.048kB/2.048kB
7bb465660a7f: Loading layer [==================================================>]   7.68kB/7.68kB
01dbbe931cd2: Loading layer [==================================================>]   2.56kB/2.56kB
d3f864467c00: Loading layer [==================================================>]   2.56kB/2.56kB
7127932e50b4: Loading layer [==================================================>]   2.56kB/2.56kB
Loaded image: goharbor/harbor-db:v1.8.3
95d29642f385: Loading layer [==================================================>]  76.86MB/76.86MB
6c5c14da0eb6: Loading layer [==================================================>]  3.072kB/3.072kB
0ae2f6f75c2d: Loading layer [==================================================>]   59.9kB/59.9kB
c05fa142a5f0: Loading layer [==================================================>]  61.95kB/61.95kB
Loaded image: goharbor/redis-photon:v1.8.3
0a0f9f6b0d73: Loading layer [==================================================>]  8.979MB/8.979MB
4ff59ce76df8: Loading layer [==================================================>]  5.143MB/5.143MB
595e28a6d5dd: Loading layer [==================================================>]  13.72MB/13.72MB
08ecdfede76e: Loading layer [==================================================>]  26.47MB/26.47MB
cec929bcb1ce: Loading layer [==================================================>]  22.02kB/22.02kB
6b8df09d36cd: Loading layer [==================================================>]  3.072kB/3.072kB
cb3dc5d6a05f: Loading layer [==================================================>]  45.33MB/45.33MB
Loaded image: goharbor/notary-signer-photon:v0.6.1-v1.8.3
1725b0c1a9a8: Loading layer [==================================================>]  8.985MB/8.985MB
e7d8ded7fdc4: Loading layer [==================================================>]  44.39MB/44.39MB
4e7b23fb9f82: Loading layer [==================================================>]  2.048kB/2.048kB
66c0e65d70f6: Loading layer [==================================================>]  3.072kB/3.072kB
9544c2e379f9: Loading layer [==================================================>]   44.4MB/44.4MB
Loaded image: goharbor/chartmuseum-photon:v0.9.0-v1.8.3
d32f29d72d88: Loading layer [==================================================>]  8.979MB/8.979MB
c0506e3ca763: Loading layer [==================================================>]  46.92MB/46.92MB
f64cde554714: Loading layer [==================================================>]  5.632kB/5.632kB
db04f8e0162d: Loading layer [==================================================>]  29.18kB/29.18kB
b631ee787727: Loading layer [==================================================>]  46.92MB/46.92MB
Loaded image: goharbor/harbor-core:v1.8.3
f576d64ee0ba: Loading layer [==================================================>]  50.61MB/50.61MB
290c9b6289d5: Loading layer [==================================================>]  3.584kB/3.584kB
5d61584d2956: Loading layer [==================================================>]  3.072kB/3.072kB
67ef984d4b8a: Loading layer [==================================================>]   2.56kB/2.56kB
0dc33d9e6bd9: Loading layer [==================================================>]  3.072kB/3.072kB
d8c16c3b7ac3: Loading layer [==================================================>]  3.584kB/3.584kB
be69664d356a: Loading layer [==================================================>]  12.29kB/12.29kB
Loaded image: goharbor/harbor-log:v1.8.3
96afca216a34: Loading layer [==================================================>]   8.98MB/8.98MB
cf2507154eef: Loading layer [==================================================>]  3.072kB/3.072kB
4a2c6388ed0f: Loading layer [==================================================>]   20.1MB/20.1MB
32036e8a07e3: Loading layer [==================================================>]  3.072kB/3.072kB
7454fe51a038: Loading layer [==================================================>]  7.465MB/7.465MB
198ef4779172: Loading layer [==================================================>]  27.56MB/27.56MB
Loaded image: goharbor/harbor-registryctl:v1.8.3
bb54e139bca3: Loading layer [==================================================>]  15.13MB/15.13MB
4941410aed1b: Loading layer [==================================================>]  26.47MB/26.47MB
1449fb6cde1c: Loading layer [==================================================>]  22.02kB/22.02kB
fd78de699481: Loading layer [==================================================>]  3.072kB/3.072kB
3791b26acaa3: Loading layer [==================================================>]  46.74MB/46.74MB
Loaded image: goharbor/notary-server-photon:v0.6.1-v1.8.3
3839997fbf5d: Loading layer [==================================================>]    113MB/113MB
0b471d0667f2: Loading layer [==================================================>]  10.94MB/10.94MB
354943756514: Loading layer [==================================================>]  2.048kB/2.048kB
2a59d04b8c15: Loading layer [==================================================>]  48.13kB/48.13kB
075a225c2421: Loading layer [==================================================>]  3.072kB/3.072kB
5a3c08a102df: Loading layer [==================================================>]  10.99MB/10.99MB
Loaded image: goharbor/clair-photon:v2.0.8-v1.8.3
86a1b291bcc8: Loading layer [==================================================>]  337.6MB/337.6MB
1abd6cfbee84: Loading layer [==================================================>]    107kB/107kB
Loaded image: goharbor/harbor-migrator:v1.8.3
f43d0ed4d1b5: Loading layer [==================================================>]   2.56kB/2.56kB
cdf4be494423: Loading layer [==================================================>]  1.536kB/1.536kB
1da4caf48243: Loading layer [==================================================>]  71.98MB/71.98MB
e4959b489cdc: Loading layer [==================================================>]  42.56MB/42.56MB
7d02cb057768: Loading layer [==================================================>]  144.4kB/144.4kB
dc328ed7230a: Loading layer [==================================================>]  3.006MB/3.006MB
Loaded image: goharbor/prepare:v1.8.3
d240fe19eee2: Loading layer [==================================================>]  3.565MB/3.565MB
95109f705255: Loading layer [==================================================>]   6.59MB/6.59MB
4d1442f2fd56: Loading layer [==================================================>]  161.3kB/161.3kB
c08c13f64b16: Loading layer [==================================================>]    215kB/215kB
5d50a9be80ef: Loading layer [==================================================>]  3.584kB/3.584kB
Loaded image: goharbor/harbor-portal:v1.8.3
cebbfd271c14: Loading layer [==================================================>]  3.565MB/3.565MB
Loaded image: goharbor/nginx-photon:v1.8.3
947d02006ad8: Loading layer [==================================================>]  8.979MB/8.979MB
1b8f6ef98cc1: Loading layer [==================================================>]  38.83MB/38.83MB
48afdc6a3f19: Loading layer [==================================================>]  38.83MB/38.83MB
Loaded image: goharbor/harbor-jobservice:v1.8.3
dd073e952ef4: Loading layer [==================================================>]   8.98MB/8.98MB
14a5970524bb: Loading layer [==================================================>]  3.072kB/3.072kB
8d6eade07896: Loading layer [==================================================>]   2.56kB/2.56kB
0c4f17cf375a: Loading layer [==================================================>]   20.1MB/20.1MB
d18322acb4ac: Loading layer [==================================================>]   20.1MB/20.1MB
Loaded image: goharbor/registry-photon:v2.7.1-patch-2819-v1.8.3


[Step 2]: preparing environment ...
prepare base dir is set to /opt/harbor-v1.8.3
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
Creating harbor-log ... done
Generated configuration file: /compose_location/docker-compose.yml
Clean up the input dir

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

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

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

[root@hdss-1-200 harbor]# .

6.查看docker运行情况

[root@hdss-1-200 harbor]# docker-compose ps 
      Name                     Command               State             Ports          
--------------------------------------------------------------------------------------
harbor-core         /harbor/start.sh                 Up                               
harbor-db           /entrypoint.sh postgres          Up      5432/tcp                 
harbor-jobservice   /harbor/start.sh                 Up                               
harbor-log          /bin/sh -c /usr/local/bin/ ...   Up      127.0.0.1:1514->10514/tcp
harbor-portal       nginx -g daemon off;             Up      80/tcp                   
nginx               nginx -g daemon off;             Up      0.0.0.0:180->80/tcp      
redis               docker-entrypoint.sh redis ...   Up      6379/tcp                 
registry            /entrypoint.sh /etc/regist ...   Up      5000/tcp                 
registryctl         /harbor/start.sh                 Up                               
[root@hdss-1-200 harbor]# docker ps -a
CONTAINER ID   IMAGE                                               COMMAND                  CREATED         STATUS                   PORTS                       NAMES
11ef19bd1af8   goharbor/nginx-photon:v1.8.3                        "nginx -g 'daemon of??   2 minutes ago   Up 2 minutes (healthy)   0.0.0.0:180->80/tcp         nginx
1f3c821da9f6   goharbor/harbor-portal:v1.8.3                       "nginx -g 'daemon of??   2 minutes ago   Up 2 minutes (healthy)   80/tcp                      harbor-portal
527be5971ac1   goharbor/harbor-jobservice:v1.8.3                   "/harbor/start.sh"       2 minutes ago   Up 2 minutes                                         harbor-jobservice
5211221279c5   goharbor/harbor-core:v1.8.3                         "/harbor/start.sh"       2 minutes ago   Up 2 minutes (healthy)                               harbor-core
3bdacef82213   goharbor/harbor-db:v1.8.3                           "/entrypoint.sh post??   2 minutes ago   Up 2 minutes (healthy)   5432/tcp                    harbor-db
147bb1383e04   goharbor/harbor-registryctl:v1.8.3                  "/harbor/start.sh"       2 minutes ago   Up 2 minutes (healthy)                               registryctl
fc93071a12bc   goharbor/registry-photon:v2.7.1-patch-2819-v1.8.3   "/entrypoint.sh /etc??   2 minutes ago   Up 2 minutes (healthy)   5000/tcp                    registry
a79ede21af31   goharbor/redis-photon:v1.8.3                        "docker-entrypoint.s??   2 minutes ago   Up 2 minutes             6379/tcp                    redis
55eebd667c91   goharbor/harbor-log:v1.8.3                          "/bin/sh -c /usr/loc??   2 minutes ago   Up 2 minutes (healthy)   127.0.0.1:1514->10514/tcp   harbor-log
[root@hdss-1-200 harbor]# 

 7.安装nginx做反向代理

[root@hdss-1-200 ~]# yum install -y nginx

8.编辑harbor.od.com.conf

[root@hdss-1-200 harbor]# vim /etc/nginx/conf.d/harbor.od.com.conf

server {
    listen       80;
    server_name  harbor.od.com;

    client_max_body_size 1000m;

    location / {
        proxy_pass http://127.0.0.1:180;
    }
}

9.检查配置并开机启动

[root@hdss-1-200 harbor]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@hdss-1-200 harbor]# systemctl start nginx
[root@hdss-1-200 harbor]# systemctl enable nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.

 10.测试能不能获得返回值发现报错

[root@hdss-1-200 harbor]# curl harbor.od.com
curl: (6) Could not resolve host: harbor.od.com; Unknown error

11.修改11上的DNS配置

$ORIGIN od.com.
$TTL 600        ; 10 minutes
@               IN SOA  dns.od.com. dnsadmin.od.com. (
                                2021020902 ; serial
                                10800      ; refresh (3 hours)
                                900        ; retry (15 minutes)
                                604800     ; expire (1 week)
                                86400      ; minimum (1 day)
                                )
                                NS   dns.od.com.
$TTL 60 ; 1 minute
dns                A    192.168.1.11
harbor             A    192.168.1.200

[root@hdss-1-11 named]# systemctl restart named 
[root@hdss-1-11 named]# dig -t A harbor.od.com +short
192.168.1.200

 13.再次测试查看

[root@hdss-1-200 harbor]# curl harbor.od.com
curl: (6) Could not resolve host: harbor.od.com; Unknown error
[root@hdss-1-200 harbor]# curl harbor.od.com
<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <title>Harbor</title>
    <base href="/">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="icon" type="image/x-icon" href="favicon.ico?v=2">
<link rel="stylesheet" href="styles.c1fdd265f24063370a49.css"></head>

<body>
    <harbor-app>
        <div class="spinner spinner-lg app-loading">
            Loading...
        </div>
    </harbor-app>
<script type="text/javascript" src="runtime.26209474bfa8dc87a77c.js"></script><script type="text/javascript" src="scripts.c04548c4e6d1db502313.js"></script><script type="text/javascript" src="main.144e8ccd474a28572e81.js"></script></body>

</html>[root@hdss-1-200 harbor]# 

14.前台页面访问

 账号登录

创建项目

15.先从公共仓库里拉取镜像

[root@hdss-1-200 harbor]# docker pull nginx:1.7.9
1.7.9: Pulling from library/nginx
Image docker.io/library/nginx:1.7.9 uses outdated schema1 manifest format. Please upgrade to a schema2 image for better future compatibility. More information at https://docs.docker.com/registry/spec/deprecated-schema-v1/
a3ed95caeb02: Pull complete 
6f5424ebd796: Pull complete 
d15444df170a: Pull complete 
e83f073daa67: Pull complete 
a4d93e421023: Pull complete 
084adbca2647: Pull complete 
c9cec474c523: Pull complete 
Digest: sha256:e3456c851a152494c3e4ff5fcc26f240206abac0c9d794affb40e0714846c451
Status: Downloaded newer image for nginx:1.7.9
docker.io/library/nginx:1.7.9

 16.将下载好的docker镜像本地打包,再推送到harbor私有仓库

[root@hdss-1-200 ~]# docker images|grep 1.7.9
nginx                           1.7.9                      84581e99d807   6 years ago     91.7MB
[root@hdss-1-200 ~]# docker tag 84581e99d807 harbor.od.com/public/nginx:v1.7.9
[root@hdss-1-200 ~]# docker login harbor.od.com
Username: admin
Password: 
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded
[root@hdss-1-200 ~]# docker push harbor.od.com/public/nginx:v1.7.9
The push refers to repository [harbor.od.com/public/nginx]
5f70bf18a086: Pushed 
4b26ab29a475: Pushed 
ccb1d68e3fb7: Pushed 
e387107e2065: Pushed 
63bf84221cce: Pushed 
e02dce553481: Pushed 
dea2e4984e29: Pushed 
v1.7.9: digest: sha256:b1f5935eb2e9e2ae89c0b3e2e148c19068d91ca502e857052f14db230443e4c2 size: 3012
[root@hdss-1-200 ~]# 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值