05.安装前准备-harbor安装
1.下载包并配置::
[root@server14 ]# mkdir -p /opt/src && cd /opt/src
[root@server14 src]# wget https://github.com/goharbor/harbor/releases/download/v1.9.4/harbor-offline-installer-v1.9.4.tgz
[root@server14 src]# mv harbor /opt/release/harbor-v1.9.4
[root@server14 src]# ln -s /opt/release/harbor-v1.9.4 /opt/apps/harbor
# 改登陆地址和登陆密码:(harbor用默认80端口访问,不用443)
[root@server14 src]# vim /opt/apps/harbor/harbor.yml
hostname: harbor.leon.com
# Remember Change the admin password from UI after launching Harbor.
harbor_admin_password: abcd.1234
#更改docker-compose中文件中nginx的地址为180,因为当前宿主机的80被占用,所以打算从本机的nginx转发到harbor自带的nginx,所以需要改端口。
container_name: nginx
ports:
- 180:8080
2.下载docker-compose并启动安装脚本。
[root@server14 src]# yum install -y docker-compose
[root@server14 src]# cd /opt/apps/harbor/
[root@server14 src]# ./install.sh
[root@server14 src]# docker-compose ps
Name Command State Ports
--------------------------------------------------------------------------------------
harbor-core /harbor/harbor_core Up
harbor-db /docker-entrypoint.sh Up 5432/tcp
harbor-jobservice /harbor/harbor_jobservice ... Up
harbor-log /bin/sh -c /usr/local/bin/ ... Up 127.0.0.1:1514->10514/tcp
harbor-portal nginx -g daemon off; Up 8080/tcp
nginx nginx -g daemon off; Up 0.0.0.0:80->8080/tcp
redis redis-server /etc/redis.conf Up 6379/tcp
registry /entrypoint.sh /etc/regist ... Up 5000/tcp
registryctl /harbor/start.sh Up
3.设置harbor开机启动
[root@hdss7-200 harbor]# cat /etc/rc.d/rc.local
# start harbor
cd /opt/apps/harbor && /usr/bin/docker-compose stop && /usr/bin/docker-compose start
4.服务器安装nginx
# 当前机器中Nginx功能较少,使用yum安装即可。如有多个harbor考虑源码编译且配置健康检查
# nginx配置此处忽略,仅仅使用最简单的配置。
[root@server14 ~]# yum -y install nginx
[root@server14 ~]# systemctl start nginx ; systemctl enable nginx
[root@server14 ~]# cat /etc/nginx/conf.d/harbor.conf
server {
listen 80;
server_name harbor.leon.com;
# 避免出现上传失败的情况
client_max_body_size 1000m;
location / {
proxy_pass http://127.0.0.1:180;
}
}
[root@server14 ~]#
[root@server14 ~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@server14 ~]#
5.去dns服务器(20.0.0.10)添加dns解析:
# 序列号需要滚动一个
[root@server10 ~]# cat /var/named/leon.com.zone
$ORIGIN leon.com.
$TTL 600 ; 10 minutes
@ IN SOA dns.leon.com. dnsadmin.leon.com. (
2020112402 ; serial
10800 ; refresh (3 hours)
900 ; retry (15 minutes)
604800 ; expire (1 week)
86400 ; minimum (1 day)
)
NS dns.leon.com.
$TTL 60 ; 1 minute
dns A 20.0.0.10
harbor A 20.0.0.14
[root@server10 ~]#
重启后验证:
[root@server10 ~]# systemctl restart named.service
[root@server10 ~]# host harbor.leon.com
harbor.leon.com has address 20.0.0.14
[root@server10 ~]#
[root@server12 ~]# dig -t A harbor.leon.com @20.0.0.10 +short
20.0.0.14
[root@server12 ~]#
[root@server13 ~]# dig -t A harbor.leon.com @20.0.0.10 +short
20.0.0.14
[root@server13 ~]#
6.访问:

创建项目,并设置为公开

7.验证:
在node节点上传镜像(默认docker配置文件已经修改仓库地址)。
登陆:
[root@server2 ~]# docker login https://harbor.leon.com
Username: admin
Password:
Error response from daemon: Get https://harbor.leon.com/v1/users/: x509: certificate signed by unknown authority
[root@server2 ~]#
查看现有镜像:
[root@server1 harbor]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
10.0.0.8/leon/devmysql
打tag
[root@server1 harbor]# docker tag 10.0.0.8/leon/devmysql:latest harbor.leon.com/leon/dev.mysql:v1.0
推送:
[root@server1 harbor]# docker push harbor.leon.com/leon/dev.mysql:v1.0
The push refers to repository [harbor.leon.com/leon/dev.mysql]
ee30b869dd90: Pushed
b5d824491b78: Pushed
b26238180bc8: Pushed
01e91410235e: Pushed
b610b16e919f: Pushed
1574ff8789b1: Pushed
e7048a1643a4: Pushed
1bc74a039df4: Pushed
6ebad06b3e49: Pushed
f1621398948b: Pushed
fe4c16cbf7a4: Pushed
v1.0: digest: sha256:d1363110584666965a349528cff160c95f4a80509b119b9986490229b07d7672 size: 2616
[root@server1 harbor]#
查看:



浙公网安备 33010602011771号