3 搭建harbor

安装harbor仓库

安装1.7.6以上版本	
# 1.9.1不能用,添加dashboard.rongbiz.cn会无法push

[root@rstx-53安装harbor仓库

安装1.7.6以上版本

1.9.1不能用,添加dashboard.rongbiz.cn会无法push

[root@rstx-53 ~]# mkdir /opt/src
[root@rstx-53 ~]# cd /opt/src/
[root@rstx-53 src]# ls
harbor-offline-installer-v1.10.1.tgz

[root@rstx-53 src]# tar zxvf harbor-offline-installer-v1.10.1.tgz -C /opt/

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

[root@rstx-53 src]# cd ..
[root@rstx-53 opt]# mv harbor/ harbor-v1.10.1
[root@rstx-53 opt]# ln -s harbor-v1.10.1/ harbor
[root@rstx-53 opt]# ll
总用量 0
drwxr-xr-x  2 root root  71 7月  15 17:25 certs
drwx--x--x. 4 root root  28 6月  12 19:42 containerd
lrwxrwxrwx  1 root root  15 7月  16 09:12 harbor -> harbor-v1.10.1/
drwxr-xr-x  2 root root 118 7月  16 09:12 harbor-v1.10.1
drwxr-xr-x  2 root root  50 7月  16 09:10 src

编辑harbor文件
[root@rstx-53 opt]# cd harbor
[root@rstx-53 harbor]# vi harbor.yml
5 hostname: harbor.rongbiz.cn
10   port: 180
27 harbor_admin_password: Harbor12345
40 data_volume: /data/harbor
87     location: /data/harbor/logs	# 更改日志存储路径

[root@rstx-53 harbor]# mkdir -p /data/harbor/logs

单机编排工具

[root@rstx-53 harbor]# yum install -y docker-compose
[root@rstx-53 harbor]# rpm -qa docker-compose
docker-compose-1.18.0-4.el7.noarch
安装
[root@rstx-53 harbor]# ./install.sh 

[root@rstx-53 harbor]# docker-compose ps

每次重启docker需要执行
[root@rstx-53 harbor]# docker-compose up -d

安装nginx做反向代理
[root@rstx-53 harbor]# yum install -y nginx

[root@rstx-53 harbor]# vi /etc/nginx/conf.d/harbor.rongbiz.cn.conf
server {
    listen       80;
    server_name  harbor.rongbiz.cn;

    client_max_body_size 1000m;

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

检测配置文件
[root@rstx-53 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@rstx-53 harbor]# systemctl start nginx
[root@rstx-53 harbor]# systemctl enable nginx

dns服务器

[root@rstx-201 named]# vi /var/named/rongbiz.cn.zone 
$ORIGIN rongbiz.cn.
$TTL 600        ; 10 minutes
@               IN SOA  dns.rongbiz.cn. dnsadmin.rongbiz.cn. (
                                2019120902 ; serial		# 往后滚动一个记录编号02,每次更改配置,必须滚动一个序号
                                10800      ; refresh (3 hours)
                                900        ; retry (15 minutes)
                                604800     ; expire (1 week)
                                86400      ; minimum (1 day)
                                )
                                NS   dns.rongbiz.cn.
$TTL 60 ; 1 minute
dns                A    192.168.153.11
harbor             A    192.168.153.200

[root@rstx-201 named]# systemctl restart named 

验证
[root@rstx-201 named]# dig -t A harbor.rongbiz.cn +short

http://harbor.rongbiz.cn/
新建一个public项目,公开

[root@rstx-53 harbor]# docker pull nginx:1.7.9

[root@rstx-53 harbor]# docker tag nginx:1.7.9 harbor.rongbiz.cn/public/nginx:v1.7.9 

[root@rstx-53 harbor]# docker login harbor.rongbiz.cn

[root@rstx-53 harbor]# docker push harbor.rongbiz.cn/public/nginx:v1.7.9
``` ~]# mkdir /opt/src
[root@rstx-53 ~]# cd /opt/src/
[root@rstx-53 src]# ls
harbor-offline-installer-v1.9.1.tgz

[root@hdss7-22 src]# tar zxvf harbor-offline-installer-v1.8.0.tgz -C /opt/

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

[root@rstx-53 src]# cd ..
[root@rstx-53 opt]# mv harbor/ harbor-v1.8.0
[root@rstx-53 opt]# ln -s /opt/harbor-v1.8.0/ /opt/harbor
[root@rstx-53 opt]# ll
总用量 0
drwx--x--x 4 root root  28 12月 10 14:30 containerd
lrwxrwxrwx 1 root root  19 12月 10 15:00 harbor -> /opt/harbor-v1.8.0/
drwxr-xr-x 2 root root 100 12月 10 14:58 harbor-v1.8.0
drwxr-xr-x 2 root root  49 12月 10 14:56 src

编辑harbor文件

[root@rstx-53 opt]# cd harbor
[root@rstx-53 harbor]# vi harbor.yml
5 hostname: harbor.rongbiz.cn
10   port: 180
27 harbor_admin_password: Harbor12345
40 data_volume: /data/harbor
87     location: /data/harbor/logs	# 更改日志存储路径

[root@rstx-53 harbor]# mkdir -p /data/harbor/logs

单机编排工具
[root@rstx-53 harbor]# yum install -y docker-compose
[root@rstx-53 harbor]# rpm -qa docker-compose
docker-compose-1.18.0-4.el7.noarch
安装
[root@rstx-53 harbor]# ./install.sh 

[root@rstx-53 harbor]# docker-compose ps

每次重启docker需要执行
[root@rstx-53 harbor]# docker-compose up -d

安装nginx做反向代理
[root@rstx-53 harbor]# yum install -y nginx

[root@rstx-53 harbor]# vi /etc/nginx/conf.d/harbor.rongbiz.cn.conf
server {
    listen       80;
    server_name  harbor.rongbiz.cn;

    client_max_body_size 1000m;

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

检测配置文件
[root@hdss7-11 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@hdss7-11 harbor]# systemctl start nginx
[root@hdss7-11 harbor]# systemctl enable nginx

dns服务器
[root@hdss7-11 named]# vi /var/named/rongbiz.cn.zone 
$ORIGIN rongbiz.cn.
$TTL 600        ; 10 minutes
@               IN SOA  dns.rongbiz.cn. dnsadmin.rongbiz.cn. (
                                2020071601 ; serial		# 往后滚动一个记录编号02,每次更改配置,必须滚动一个序号
                                10800      ; refresh (3 hours)
                                900        ; retry (15 minutes)
                                604800     ; expire (1 week)
                                86400      ; minimum (1 day)
                                )
                                NS   dns.rongbiz.cn.
$TTL 60 ; 1 minute
dns                A    192.168.1.53
harbor             A    192.168.1.53

[root@hdss7-11 named]# systemctl restart named 

验证
[root@hdss7-11 named]# dig -t A harbor.rongbiz.cn +short

http://harbor.rongbiz.cn/
新建一个public项目,公开

[root@rstx-53 harbor]# docker pull nginx:1.7.9

[root@rstx-53 harbor]# docker tag nginx:1.7.9 harbor.rongbiz.cn/public/nginx:v1.7.9 

[root@rstx-53 harbor]# docker login harbor.rongbiz.cn

[root@rstx-53 harbor]# docker push harbor.rongbiz.cn/public/nginx:v1.7.9

PS:harbor ui删除镜像后 不释放存储空间 用以下命令释放

docker run -it --name gc --rm --volumes-from registry vmware/registry:2.6.2-photon garbage-collect /etc/registry/config.yml
posted @ 2020-07-16 10:59  老夫聊发少年狂88  阅读(100)  评论(0编辑  收藏  举报