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官方也提供了公共的镜像仓库,但是从安全和效率等方面考虑,部署我们私有环境 ...
随机推荐
- Hadoop_30_MapReduce_多job串联
一个稍复杂点的处理逻辑往往需要多个mapreduce程序串联处理,多job的串联可以借助mapreduce框架的JobControl实现 示例代码: 每个job装配完成才可以进行下面代码: Cont ...
- (2)python开发环境搭建
电脑配置:推荐i7以上处理器,8g内存就ok了,python对电脑还是稍微有点要求的 当我们编写Python代码时,我们得到的是一个包含Python代码的以.py为扩展名的文本文件.要运行代码,就需要 ...
- CHANGELOG 的实现
项目需要写版本信息时有对除了版本号之外更详细的 changelog 的展示, 于是就需要在平时的 git commit 中进行规范, 才能自动生成CHANGELOG.md. Husky 首先本地安装 ...
- BZOJ 1135 P3488 LYZ-Ice Skates 线段树+Hall
https://www.luogu.org/problem/P3488 根据Hall定理 左边任意一个区间L-R a[i]的和sum[l~r] 都要<= (R-L+1+d)*K 把(R-L+1) ...
- Mac环境下使用Appium Inspector进行元素定位
一.摘要 本篇博文介绍在Mac系统上使用AppiumI Inspector进行App页面元素定位 二.Finding elements by xpath WebElement digit_9 = dr ...
- easyui tree选中指定节点,点击指定节点
功能需求描述如下: A主页面,在datagrid的某行上,操作列,点击详情,Tab页面上加载B页面 B页面,左边是树tree,右边是左边树的详情列表 要求:由A页面链接到B页面,B页面的tree,默认 ...
- avcodec_decode_video2函数
转自 https://www.xuebuyuan.com/2156374.html 该函数的作用是实现压缩视频的解码.在avcodec.h中的声明方式如下: int avcodec_decode_vi ...
- BZOJ 4260: Codechef REBXOR (trie树维护异或最大值)
题意 分析 将区间异或和转化为前缀异或和.那么[L,R][L,R][L,R]的异或和就等于presum[R] xor presum[L−1]presum[R]\ xor \ presum[L-1]pr ...
- [Python自学] day-18 (2) (MTV架构、Django框架、模板语言)
一.实现一个简单的Web服务器 使用Python标准库提供的独立WSGI服务器来实现MVC架构. 首先,实现一个简单的Web服务器: from wsgiref.simple_server import ...
- 将.py脚本打包成.exe
https://www.cnblogs.com/wyl-0120/p/10823102.html 为了方便使用,通过pyinstaller对脚本进行打包成exe文件. pip3 install pyi ...