纯步骤
基于上次已经搭建好的K8S多节点,搭建K8S的harbor私有仓库
开一台服务器,搭建harbor
一:harbor服务端配置
需安装 Python、 Docker 和Docker Compose、harbor
1:基本环境配置
固定IP地址
# vim /etc/sysconfig/network-scripts/ifcfg-ens33
修改并添加:
dhcp改为static
添加:
IPADDR=192.168.195.80
NETMASK=255.255.255.0
GATEWAY=192.168.195.2
DNS1=192.168.195.2
# systemctl restart network
# systemctl stop NetworkManager
# systemctl disable NetworkManager
# iptables -F
关闭核心防护
# setenforce 0
# vi /etc/selinux/config
改为 SELINUX=disabled
# hostnamectl set-hostname harbor
# su
2:首先部署docker环境
安装依赖包
# yum install -y yum-utils device-mapper-persistent-data lvm2
设置阿里云镜像源
# yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# yum install docker-ce -y
# systemctl start docker
# systemctl enable docker
镜像加速配置
现在需要从公有仓库里拉取镜像,由于长城防火墙及网络问题,必须使用镜像加速,才能快速拉取镜像
访问网站https://help.aliyun.com/document_detail/60750.html
生成加速地址"https://elxy356o.mirror.aliyuncs.com"
# cd /etc/docker
# tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://elxy356o.mirror.aliyuncs.com"]
}
EOF
# ls 可看到daemon.jsp
# systemctl daemon-reload 重新加载
开启路由转发
# vim /etc/sysctl.conf
末行插入:
net.ipv4.ip_forward=1
# sysctl -p 生效
重启网络和docker
# service network restart
# systemctl restart docker
docker引擎环境部署完成
3:下载harbor安装程序、下载compose
#rz -E
把harbor-offline-installer-v1.2.2.tgz、docker-compose包复制过来
# chmod +x docker-compose
# mv docker-compose /usr/bin
# tar zxvf harbor-offline-installer-v1.2.2.tgz -C /usr/local/
# cd /usr/local/harbor
# ls
修改harbor配置文件(改为h