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官方也提供了公共的镜像仓库,但是从安全和效率等方面考虑,部署我们私有环境 ...
随机推荐
- python-----操作路径
分离路径.文件名 org_path = r"F:\temp\test" fpath, fname = os.path.split(org_path) print(fpath,fna ...
- ini文件读写 保存上次存储内容
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- Sleep-Join方法理解
package cn.mayday.test; public class JoinTest { public static void main(String[] args) { try { int c ...
- Vue入门(四)——Axios向SpringMVC传数据
在实际业务需求中,经常会出现前台传表单或者对象到后台,后台Handler接受并转换成对应的POJO以供业务代码使用 此时在SpringMVC框架中就要用到@RequestBody注解,该注解用于将请求 ...
- lite-monitor 一款基于shell命令的监控系统
介绍 lite-monitor 一款基于shell命令的监控系统,可以根据项目中输出的日志定时输出或者统计输出,并发送钉钉机器人报警消息. lite-monitor能做什么: 定时监控某个服务进程是否 ...
- BZOJ 3658: Jabberwocky (双向链表+BIT)
题意 平面上有n个点,每个点有k种颜色中的一个.你可以选择一条水平的线段获得在其上方或其下方的所有点,请求出你最多能够得到多少点,使得获得的点并不包含所有的颜色. 分析 线段可以向上向下,那么我们只考 ...
- java中commons-beanutils的介绍(转)
1. 概述 commons-beanutil开源库是apache组织的一个基础的开源库.为apache中很多类提供工具方法.学习它是学习其它开源库实现的基础. Commons-beanutil中包 ...
- py操作mongodb总结
python使用的版本 python3. python操作mongodb使用的是pymongo,安装方法: pip install pymongo 测试 PyMongo 接下来我们可以创建一个测试文件 ...
- parents([expr]) 取得一个包含着所有匹配元素的祖先元素的元素集合(不包含根元素)。可以通过一个可选的表达式进行筛选。
parents([expr]) 概述 取得一个包含着所有匹配元素的祖先元素的元素集合(不包含根元素).可以通过一个可选的表达式进行筛选.大理石平台检定规程 参数 exprStringV1.0 用于 ...
- Python数据抓取(1) —数据处理前的准备
(一)数据抓取概要 为什么要学会抓取网络数据? 对公司或对自己有价值的数据,80%都不在本地的数据库,它们都散落在广大的网络数据,这些数据通常都伴随着网页的形式呈现,这样的数据我们称为非结构化数据 如 ...