搭建私有仓库harbor

搭建私有仓库harbor

什么是harbor

Harbor是由VMware公司开源的企业级的Docker Registry管理项目,包括权限管理(RBAC)、LDAP、日志审核、管理界面、自我注册、镜像复制和中文支持等功能.搭建harbor可以作为私有仓库管理镜像。

环境准备

CPU:内核总数4核
内存:4G
硬盘:100G
主机ip:192.168.40.100

搭建过程

签发证书

因为k8s获取harbor仓库的镜像是使用的https,所以需要签发证书

#创建ssl目录
mkdir /data/ssl -p

#生成ca证书
openssl genrsa -out ca.key 3072

#生成数字证书ca.pem,有效期十年
openssl req -new -x509 -days 3650 -key ca.key -out ca.pem

#生成域名证书
openssl genrsa -out harbor.key  3072

#生成证书请求
openssl req -new -key harbor.key -out harbor.csr

#签发证书
openssl x509 -req -in harbor.csr -CA ca.pem -CAkey ca.key -CAcreateserial -out harbor.pem -days 3650

安装harbor

#关闭防火墙
systemctl stop firewalld && systemctl disable firewalld

#关闭iptables防火墙
yum install iptables-services -y
service iptables stop   && systemctl disable iptables
iptables -F

#关闭selinux
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

#配置时间同步
yum install -y ntp ntpdate
ntpdate cn.pool.ntp.org

#配置hosts
vim /etc/hosts
#添加
192.168.40.100 harbor

#安装docker
...

#开启包转发和修改内核参数
modprobe br_netfilter
vim /etc/sysctl.d/docker.conf
#
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
#
sysctl -p /etc/sysctl.d/docker.conf

#重启docker
systemctl restart docker 

#安装docker-compose
curl -L https://get.daocloud.io/docker/compose/releases/download/v2.4.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
#赋权
chmod +x /usr/local/bin/docker-compose

#安装harbor
mkdir /data/install -p
wget https://storage.googleapis.com/harbor-releases/release-1.9.0/harbor-offline-installer-v1.9.4.tgz
tar xvzf harbor-offline-installer-v1.9.4.tgz
cd harbor
#修改配置文件
vim harbor.yml
#
hostname:  harbor
...
certificate: /data/ssl/harbor.pem
private_key: /data/ssl/harbor.key
#
./install.sh

登录harbor

在物理机上输入https://harbor
默认用户名密码为:admin/Harbor12345

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值