k8s 之harbor仓库安装(四)

liaochaowu 2020-06-06

1.200机器安装harbor仓库

[ ~]# mkdir -p /opt/src
[ ~]# cd /opt/src
[ src]# ll
total 566428
-rw-r--r-- 1 root root 580021898 Apr  1 18:46 harbor-offline-installer-v1.8.3.tgz
[ src]# tar xf harbor-offline-installer-v1.8.3.tgz -C /opt/

# 把软件包做版本标识,做一个软链接,便于以后升级
[ src]# cd ..
[ opt]# mv harbor/ harbor-v1.8.0
[ opt]# ln -s /opt/harbor-v1.8.0/ /opt/harbor
[ opt]# ll
total 0
drwxr-xr-x 2 root root  71 Jun  6 11:19 certs
drwx--x--x 4 root root  28 Jun  6 11:43 containerd
lrwxrwxrwx 1 root root  19 Jun  6 11:57 harbor -> /opt/harbor-v1.8.0/
drwxr-xr-x 2 root root 100 Jun  6 11:57 harbor-v1.8.0
drwxr-xr-x 2 root root  49 Jun  6 11:55 src
编辑harbor文件
[ opt]# cd harbor
[ harbor]# vi harbor.yml
5 hostname: harbor.od.com
10   port: 180
27 harbor_admin_password: Harbor12345
40 data_volume: /data/harbor
87     location: /data/harbor/logs  # 更改日志存储路径

[ harbor]# mkdir -p /data/harbor/logs

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

每次重启docker需要执行也可以通过脚本方式启动
[ harbor]# docker-compose up -d

k8s 之harbor仓库安装(四)

2.安装nginx做反向代理

[ harbor]#  yum install -y nginx
[ harbor]# vi /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;
    }
}
[ harbor]# nginx -t
[ harbor]# systemctl start nginx
[ harbor]# systemctl enable nginx

3 dns服务器配置域名

[ ~]# vi /var/named/od.com.zone 
[ ~]# cat /var/named/od.com.zone
$ORIGIN od.com.
$TTL 600    ; 10 minutes
@           IN SOA  dns.od.com. dnsadmin.od.com. (
                20200606 ; 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.12.11
harbor             A    192.168.12.200
[ ~]# systemctl restart named
[ ~]# dig -t A harbor.od.com +short
192.168.12.200

k8s 之harbor仓库安装(四)

新建一个public项目,公开

[ harbor]# docker pull nginx:1.7.9

[ harbor]# docker tag nginx:1.7.9 harbor.od.com/public/nginx:v1.7.9  

[ harbor]# docker login harbor.od.com

[ harbor]# docker push harbor.od.com/public/nginx:v1.7.9

原文章已同步到语雀‘

https://www.yuque.com/songyifei/bkxwl0/ihp7o5

相关推荐