虚拟机 rocky9.4 linux master node01 node02 已部署k8s集群版本 1.31
方法
一 使用容器部署harbor
(1)
wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo
yum -y install docker-ce
systemctl enable docker && systemctl start docker
(2下载一个docker-compose工具
[root@harbor ~]# wget https://github.com/docker/compose/releases/download/v2.20.3/docker-compose-linux-x86_64
curl -L https://get.daocloud.io/docker/compose/releases/download/1.25.0/docker-compose-\`uname -s`-`uname -m` > /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose -v
3.下载Harbor的压缩包
https://github.com/goharbor/harbor/releases
#上传压缩包到linux,并解压
tar -xzf -offline-installer-v2.1.0_2.tgz
mkdir /opt/harbor
mv harbor/* /opt/harbor
cd /opt/harbor
4.修改harbor配置
#没有的话复制harbor.yml.tmpl
cp -a harbor.yml.tmpl harbor.yml
vim harbor.yml
修改hostname和port
hostname: 192.168.10.10
port: 80
#注释掉https这段
https related config
#https:
https port for harbor, default is 443
port: 443
The path of cert and key files for nginx
certificate: /your/certificate/path
#private_key: /your/private/key/path
5.安装harbor
./install.sh
6、访问地址与账号密码http://192.168.10.100默认账户密码:admin/Harbor12345
6.启动、停止、重启
docker-compose up -d 启动
docker-compose stop 停止
docker-compose restart 重新启动
7 登录harbor 新建项目
vim /etc/docker/daemon.json
客户端设置
{
"registry-mirrors": ["https://1dmptu91.mirror.aliyuncs.com"],
"exec-opts": ["native.cgroupdriver=systemd"],
"insecure-registries": ["http://192.168.10.100"]
}
[root@master ~]# systemctl restart docker
客户机登录仓库:
docker login -u 'admin' -p 'Harbor12345' http://192.168.10.100
docker tag nginx:1.20 192.168.10.100/yb/nginx
上传仓库
docker pull 192.168.10.100/yb/nginx