harber私有镜像仓库(4)
一、部署准备:


二、修改配置文件:


三、安装harbor程序:

#!/bin/bash #docker version: 1.11.
#docker-compose version: 1.7.
#Harbor version: 0.4. set +e
set -o noglob #
# Set Colors
# bold=$(tput bold)
underline=$(tput sgr )
reset=$(tput sgr0) red=$(tput setaf )
green=$(tput setaf )
white=$(tput setaf )
tan=$(tput setaf )
blue=$(tput setaf ) #
# Headers and Logging
# underline() { printf "${underline}${bold}%s${reset}\n" "$@"
}
h1() { printf "\n${underline}${bold}${blue}%s${reset}\n" "$@"
}
h2() { printf "\n${underline}${bold}${white}%s${reset}\n" "$@"
}
debug() { printf "${white}%s${reset}\n" "$@"
}
info() { printf "${white}➜ %s${reset}\n" "$@"
}
success() { printf "${green}✔ %s${reset}\n" "$@"
}
error() { printf "${red}✖ %s${reset}\n" "$@"
}
warn() { printf "${tan}➜ %s${reset}\n" "$@"
}
bold() { printf "${bold}%s${reset}\n" "$@"
}
note() { printf "\n${underline}${bold}${blue}Note:${reset} ${blue}%s${reset}\n" "$@"
} set -e
set +o noglob usage=$'Please set hostname and other necessary attributes in harbor.cfg first. DO NOT use localhost or 127.0.0.1 for hostname, because Harbor needs to be accessed by external clients.
Please set --with-notary if needs enable Notary in Harbor, and set ui_url_protocol/ssl_cert/ssl_cert_key in harbor.cfg bacause notary must run under https.
Please set --with-clair if needs enable Clair in Harbor'
item= # notary is not enabled by default
with_notary=$false
# clair is not enabled by default
with_clair=$false
# HA mode is not enabled by default
harbor_ha=$false
while [ $# -gt ]; do
case $ in
--help)
note "$usage"
exit ;;
--with-notary)
with_notary=true;;
--with-clair)
with_clair=true;;
--ha)
harbor_ha=true;;
*)
note "$usage"
exit ;;
esac
shift || true
done workdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $workdir # The hostname in harbor.cfg has not been modified
if grep 'hostname = reg.mydomain.com' &> /dev/null harbor.cfg
then
warn "$usage"
exit
fi function check_docker {
if ! docker --version &> /dev/null
then
error "Need to install docker(1.10.0+) first and run this script again."
exit
fi # docker has been installed and check its version
if [[ $(docker --version) =~ (([-]+).([-]+).([-]+)) ]]
then
docker_version=${BASH_REMATCH[]}
docker_version_part1=${BASH_REMATCH[]}
docker_version_part2=${BASH_REMATCH[]} # the version of docker does not meet the requirement
if [ "$docker_version_part1" -lt ] || ([ "$docker_version_part1" -eq ] && [ "$docker_version_part2" -lt ])
then
error "Need to upgrade docker package to 1.10.0+."
exit
else
note "docker version: $docker_version"
fi
else
error "Failed to parse docker version."
exit
fi
} function check_dockercompose {
if ! docker-compose --version &> /dev/null
then
error "Need to install docker-compose(1.7.1+) by yourself first and run this script again."
exit
fi # docker-compose has been installed, check its version
if [[ $(docker-compose --version) =~ (([-]+).([-]+).([-]+)) ]]
then
docker_compose_version=${BASH_REMATCH[]}
docker_compose_version_part1=${BASH_REMATCH[]}
docker_compose_version_part2=${BASH_REMATCH[]} # the version of docker-compose does not meet the requirement
if [ "$docker_compose_version_part1" -lt ] || ([ "$docker_compose_version_part1" -eq ] && [ "$docker_compose_version_part2" -lt ])
then
error "Need to upgrade docker-compose package to 1.7.1+."
exit
else
note "docker-compose version: $docker_compose_version"
fi
else
error "Failed to parse docker-compose version."
exit
fi
} h2 "[Step $item]: checking installation environment ..."; let item+=
check_docker
check_dockercompose if [ -f harbor*.tar.gz ]
then
h2 "[Step $item]: loading Harbor images ..."; let item+=
docker load -i ./harbor*.tar.gz
fi
echo "" h2 "[Step $item]: preparing environment ..."; let item+=
if [ -n "$host" ]
then
sed "s/^hostname = .*/hostname = $host/g" -i ./harbor.cfg
fi
prepare_para=
if [ $with_notary ] && [ ! $harbor_ha ]
then
prepare_para="${prepare_para} --with-notary"
fi
if [ $with_clair ]
then
prepare_para="${prepare_para} --with-clair"
fi
if [ $harbor_ha ]
then
prepare_para="${prepare_para} --ha"
fi
./prepare $prepare_para
echo "" h2 "[Step $item]: checking existing instance of Harbor ..."; let item+=
docker_compose_list='-f docker-compose.yml'
if [ $with_notary ] && [ ! $harbor_ha ]
then
docker_compose_list="${docker_compose_list} -f docker-compose.notary.yml"
fi
if [ $with_clair ]
then
docker_compose_list="${docker_compose_list} -f docker-compose.clair.yml"
fi if [ -n "$(docker-compose $docker_compose_list ps -q)" ]
then
note "stopping existing Harbor instance ..."
docker-compose $docker_compose_list down -v
fi
echo "" h2 "[Step $item]: starting Harbor ..."
if [ $harbor_ha ]
then
mv docker-compose.yml docker-compose.yml.bak
cp ha/docker-compose.yml docker-compose.yml
mv docker-compose.clair.yml docker-compose.clair.yml.bak
cp ha/docker-compose.clair.yml docker-compose.clair.yml
fi
docker-compose $docker_compose_list up -d protocol=http
hostname=reg.mydomain.com if [[ $(cat ./harbor.cfg) =~ ui_url_protocol[[:blank:]]*=[[:blank:]]*(https?) ]]
then
protocol=${BASH_REMATCH[]}
fi if [[ $(grep 'hostname[[:blank:]]*=' ./harbor.cfg) =~ hostname[[:blank:]]*=[[:blank:]]*(.*) ]]
then
hostname=${BASH_REMATCH[]}
fi
echo "" success $"----Harbor has been installed and started successfully.---- Now you should be able to visit the admin portal at ${protocol}://${hostname}.
For more details, please visit https://github.com/vmware/harbor .
"
[root@cicd harbor]# cat install.sh
#!/bin/bash #docker version: 1.11.
#docker-compose version: 1.7.
#Harbor version: 0.4. set +e
set -o noglob #
# Set Colors
# bold=$(tput bold)
underline=$(tput sgr )
reset=$(tput sgr0) red=$(tput setaf )
green=$(tput setaf )
white=$(tput setaf )
tan=$(tput setaf )
blue=$(tput setaf ) #
# Headers and Logging
# underline() { printf "${underline}${bold}%s${reset}\n" "$@"
}
h1() { printf "\n${underline}${bold}${blue}%s${reset}\n" "$@"
}
h2() { printf "\n${underline}${bold}${white}%s${reset}\n" "$@"
}
debug() { printf "${white}%s${reset}\n" "$@"
}
info() { printf "${white}➜ %s${reset}\n" "$@"
}
success() { printf "${green}✔ %s${reset}\n" "$@"
}
error() { printf "${red}✖ %s${reset}\n" "$@"
}
warn() { printf "${tan}➜ %s${reset}\n" "$@"
}
bold() { printf "${bold}%s${reset}\n" "$@"
}
note() { printf "\n${underline}${bold}${blue}Note:${reset} ${blue}%s${reset}\n" "$@"
} set -e
set +o noglob usage=$'Please set hostname and other necessary attributes in harbor.cfg first. DO NOT use localhost or 127.0.0.1 for hostname, because Harbor needs to be accessed by external clients.
Please set --with-notary if needs enable Notary in Harbor, and set ui_url_protocol/ssl_cert/ssl_cert_key in harbor.cfg bacause notary must run under https.
Please set --with-clair if needs enable Clair in Harbor'
item= # notary is not enabled by default
with_notary=$false
# clair is not enabled by default
with_clair=$false
# HA mode is not enabled by default
harbor_ha=$false
while [ $# -gt ]; do
case $ in
--help)
note "$usage"
exit ;;
--with-notary)
with_notary=true;;
--with-clair)
with_clair=true;;
--ha)
harbor_ha=true;;
*)
note "$usage"
exit ;;
esac
shift || true
done workdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $workdir # The hostname in harbor.cfg has not been modified
if grep 'hostname = reg.mydomain.com' &> /dev/null harbor.cfg
then
warn "$usage"
exit
fi function check_docker {
if ! docker --version &> /dev/null
then
error "Need to install docker(1.10.0+) first and run this script again."
exit
fi # docker has been installed and check its version
if [[ $(docker --version) =~ (([-]+).([-]+).([-]+)) ]]
then
docker_version=${BASH_REMATCH[]}
docker_version_part1=${BASH_REMATCH[]}
docker_version_part2=${BASH_REMATCH[]} # the version of docker does not meet the requirement
if [ "$docker_version_part1" -lt ] || ([ "$docker_version_part1" -eq ] && [ "$docker_version_part2" -lt ])
then
error "Need to upgrade docker package to 1.10.0+."
exit
else
note "docker version: $docker_version"
fi
else
error "Failed to parse docker version."
exit
fi
} function check_dockercompose {
if ! docker-compose --version &> /dev/null
then
error "Need to install docker-compose(1.7.1+) by yourself first and run this script again."
exit
fi # docker-compose has been installed, check its version
if [[ $(docker-compose --version) =~ (([-]+).([-]+).([-]+)) ]]
then
docker_compose_version=${BASH_REMATCH[]}
docker_compose_version_part1=${BASH_REMATCH[]}
docker_compose_version_part2=${BASH_REMATCH[]} # the version of docker-compose does not meet the requirement
if [ "$docker_compose_version_part1" -lt ] || ([ "$docker_compose_version_part1" -eq ] && [ "$docker_compose_version_part2" -lt ])
then
error "Need to upgrade docker-compose package to 1.7.1+."
exit
else
note "docker-compose version: $docker_compose_version"
fi
else
error "Failed to parse docker-compose version."
exit
fi
} h2 "[Step $item]: checking installation environment ..."; let item+=
check_docker
check_dockercompose if [ -f harbor*.tar.gz ]
then
h2 "[Step $item]: loading Harbor images ..."; let item+=
docker load -i ./harbor*.tar.gz
fi
echo "" h2 "[Step $item]: preparing environment ..."; let item+=
if [ -n "$host" ]
then
sed "s/^hostname = .*/hostname = $host/g" -i ./harbor.cfg
fi
prepare_para=
if [ $with_notary ] && [ ! $harbor_ha ]
then
prepare_para="${prepare_para} --with-notary"
fi
if [ $with_clair ]
then
prepare_para="${prepare_para} --with-clair"
fi
if [ $harbor_ha ]
then
prepare_para="${prepare_para} --ha"
fi
./prepare $prepare_para
echo "" h2 "[Step $item]: checking existing instance of Harbor ..."; let item+=
docker_compose_list='-f docker-compose.yml'
if [ $with_notary ] && [ ! $harbor_ha ]
then
docker_compose_list="${docker_compose_list} -f docker-compose.notary.yml"
fi
if [ $with_clair ]
then
docker_compose_list="${docker_compose_list} -f docker-compose.clair.yml"
fi if [ -n "$(docker-compose $docker_compose_list ps -q)" ]
then
note "stopping existing Harbor instance ..."
docker-compose $docker_compose_list down -v
fi
echo "" h2 "[Step $item]: starting Harbor ..."
if [ $harbor_ha ]
then
mv docker-compose.yml docker-compose.yml.bak
cp ha/docker-compose.yml docker-compose.yml
mv docker-compose.clair.yml docker-compose.clair.yml.bak
cp ha/docker-compose.clair.yml docker-compose.clair.yml
fi
docker-compose $docker_compose_list up -d protocol=http
hostname=reg.mydomain.com if [[ $(cat ./harbor.cfg) =~ ui_url_protocol[[:blank:]]*=[[:blank:]]*(https?) ]]
then
protocol=${BASH_REMATCH[]}
fi if [[ $(grep 'hostname[[:blank:]]*=' ./harbor.cfg) =~ hostname[[:blank:]]*=[[:blank:]]*(.*) ]]
then
hostname=${BASH_REMATCH[]}
fi
echo "" success $"----Harbor has been installed and started successfully.---- Now you should be able to visit the admin portal at ${protocol}://${hostname}.
For more details, please visit https://github.com/vmware/harbor .
"
install.sh

四、各节点设置登陆harbor私有镜像仓库:





五、上传镜像到harbor私有镜像仓库:





harber私有镜像仓库(4)的更多相关文章
- 使用Nexus3构建Docker私有镜像仓库
一.安装Nexus3 Nexus3是Sonatype提供的仓库管理平台,Nuexus Repository OSS3能够支持Maven.npm.Docker.YUM.Helm等格式数据的存储和发布:并 ...
- 详解docker实战之搭建私有镜像仓库 - kurbernetes
1.实战目的 搭建企业私有的镜像仓库,满足从开发环境推送和拉取镜像.当我们使用k8s来编排和调度容器时,操作的基本单位是镜像,所以需要从仓库去拉取镜像到当前的工作节点.本来使用公共的docker hu ...
- 【Docker】(4)搭建私有镜像仓库
[Docker](4)搭建私有镜像仓库 说明 1. 这里是通过阿里云,搭建Docker私有镜像仓库. 2. 这里打包的镜像是从官网拉下来的,并不是自己项目创建的新镜像,主要测试功能 一.搭建过程 首先 ...
- Harbor私有镜像仓库(上)
上图配置为工作环境 特别注意:win10现在不允许使用私有ca证书,到时登录浏览器会失败,可以选用火狐浏览器. 创建自己的CA证书 openssl req -newkey rsa:4096 -node ...
- [转]Ubuntu18.04下使用Docker Registry快速搭建私有镜像仓库
本文转自:https://blog.csdn.net/BigData_Mining/article/details/88233015 1.背景 在 Docker 中,当我们执行 docker pull ...
- 手动搭建Docker本地私有镜像仓库
实验环境:两个Centos7虚拟机,一个是Server,用作客户端,另一个是Registry,用作Docker私有镜像仓库. 基础配置 查看一下两台虚拟机的IP地址 Server的IP地址是192.1 ...
- 使用docker Registry快速搭建私有镜像仓库
当我们执行docker pull xxx的时候,docker默认是从registry.docker.com这个地址上去查找我们所需要的镜像文件,然后执行下载操作.这类的镜像仓库就是docker默认的公 ...
- harbor私有镜像仓库的搭建与使用与主从复制
harbor私有镜像仓库,私有仓库有两种,一种是harbor,一种是小型的私有仓库,harbor有两种模式,一种是主 从,一种是高可用仓库,项目需求,需要两台服务器,都有docker.ldap权限统一 ...
- 搭建Harbor私有镜像仓库--v1.5.1
搭建Harbor私有镜像仓库--v1.5.1 1.介绍 Docker容器应用的开发和运行离不开可靠的镜像管理,虽然Docker官方也提供了公共的镜像仓库,但是从安全和效率等方面考虑,部署我们私有环境 ...
随机推荐
- web开发:清浮动
一.display总结 二.overflow 三.浮动布局 四.清浮动 五.清浮动的方式 一.display总结 <!DOCTYPE html> <html> <head ...
- Mariadb多实例启动脚本
#!/bin/bash port=3306 mysql_user="root" mysql_pwd="centos" cmd_path="/app/m ...
- C# Transaction 事务处理 -环境事务
一.TransactionScope 环境事务 static async Task TransactionScopeAsync() { using (var scope = new Transacti ...
- mysql: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
https://www.cnblogs.com/jpfss/p/9734487.html (mysql.sock错误解决方案)
- MFC 标签页Tab Control
自带的标签页不好用,因此借助了TabSheet文件TabSheet源码 1.在解决方案资源管理器——项目处鼠标右键——在文件资源管理器中打开文件夹(或者按下图,更方便),把TabSheet.h.Tab ...
- MFC、API、C++三者的区别
MFC(Microsoft Foundation Class)是微软的基础类库,只能用于Windows系统. API(Application Programming Interface)是应用程序编程 ...
- JAVA日期格式转换---让人不得不说的故事
链接:https://my.oschina.net/xinxingegeya/blog/394821 这是给我自己参考的,大家不惜勿喷 1.举例使用 2.各种作用 3.坑(默认中文日期,加上这个就是英 ...
- ueditor上粘贴从word中copy的图片和文字
图片的复制无非有两种方法,一种是图片直接上传到服务器,另外一种转换成二进制流的base64码目前限chrome浏览器使用首先以um-editor的二进制流保存为例:打开umeditor.js,找到UM ...
- 2019CSP-J第二轮 B题C题
B.简单模拟 /* 寻找每一张公交票可用的最早的地铁优惠票,使用过之后一定要销毁*/ #include <iostream> #include <cstdio> #includ ...
- 括号序列的dp问题模型
括号序列的dp问题模型 Codeforces314E ◦给定一个长度为n的仅包含左括号和问号的字符串,将问号变成左括号或 右括号使得该括号序列合法,求方案总数. ◦例如(())与()()都是合法的括号 ...