逆水行舟用力撑,一篙松劲退千寻。这篇文章主要讲述harbor-https自动安装脚本相关的知识,希望能为你提供帮助。
1.安装环境
root@k8s-harbar:~# cat /etc/issue
Ubuntu 18.04.3 LTS \\n \\l
2.安装准备
harbor-https-install.sh
harbor-offline-installer-v1.2.2.tgz
2.1.harbor-https-install.sh
下载地址:??https://github.com/vmware/harbor/releases??
2.2.harbor-https-install.sh
#/bin/bash
DIR=`pwd`
IP=`ifconfig eth0|awk/netmask/print$2`
echo "docker 安装..."
ps -ef |grep docker > /dev/null
if [ $? -ne 0 ]; then
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
fi
echo "docker-compose 安装..."
if [ ! -e /usr/bin/docker-compose ]; then
sudo curl -L "https://github.com/docker/compose/releases/download/1.23.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
ln -s/usr/local/bin/docker-compose /usr/bin/
fi
echo "python2.7 安装..."
if [ ! -e /usr/bin/python2.7 ]; then
apt-get install python2.7-y
if [ -e /usr/bin/python ]; then
rm -f /usr/bin/python
ln -s /usr/bin/python2.7 /usr/bin/python
else
ln -s /usr/bin/python2.7 /usr/bin/python
fi
fi
if [ ! -e /usr/local/src/certs ]; then
mkdir /usr/local/src/certs
fi
cd /usr/local/src/certs
echo "生成证书...."
openssl genrsa -out ca.key 4096
openssl rand -writerand .rnd > /root/.rnd
openssl req -x509 -new -nodes -sha512 -days 3650 -subj "/C=TW/ST=Taipei/L=Taipei/O=example/OU=Personal/CN=harbor.gesila.com" -key ca.key -out ca.crt
openssl genrsa -out harbor.gesila.com.key 4096
openssl req -sha512 -new -subj "/C=TW/ST=Taipei/L=Taipei/O=example/OU=Personal/CN=harbor.gesila.com" -key harbor.gesila.com.key -out harbor.gesila.com.csr
cat > v3.ext < < -EOF
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
extendedKeyUsage = serverAuth
subjectAltName = @alt_names
[alt_names]
DNS.1=harbor.gesila.com
DNS.2=harbor.gesila
DNS.3=hostname
EOF
openssl x509 -req -sha512 -days 3650 -extfile v3.ext -CA ca.crt -CAkey ca.key -CAcreateserial -in harbor.gesila.com.csr -out harbor.gesila.com.crt
echo "harbor 安装..."
tar xf $DIR/harbor-offline-installer-v1.2.2.tgz -C/usr/local/src
cd /usr/local/src/harbor/
sed-i /hostname =/s@.*@hostname = harbor.gesila.com@harbor.cfg
sed-i /ui_url_protocol/s@.*@ui_url_protocol = https@harbor.cfg
sed-i /ssl_cert =/s@.*@ssl_cert = /usr/local/src/certs/harbor.gesila.com.crt@harbor.cfg
sed-i /ssl_cert_key/s@.*@ssl_cert_key = /usr/local/src/certs/harbor.gesila.com.key@harbor.cfg
sed-i /harbor_admin_password/s@.*@harbor_admin_password = 123456@harbor.cfg
sed-i /empty_subj =/s@.*@empty_subj = "/C=US/ST=California/L=Palo Alto/O=VMware, Inc./OU=Harbor/CN=notarysigner"@prepare
./prepare
./install.sh
if [ ! -e /etc/docker/certs.d/harbor.gesila.com ]; then
mkdir /etc/docker/certs.d/harbor.gesila.com -p
fi
cp /usr/local/src/certs/harbor.gesila.com.crt/etc/docker/certs.d/harbor.gesila.com
grep $IP /lib/systemd/system/docker.service
if [ $? -ne 0 ]; then
sed-i -r "/ExecStart=/s@(.*)@\\1 --insecure-registry $IP@"/lib/systemd/system/docker.service
fi
systemctl daemon-reload & & systemctl restart docker
echo "安装成功..."
2.3.登录
docker login harbor.gesila.com
第一次登录需要输入账号和密码,如下所示:
2.4.测试上传镜像
docker pull alpine
docker tag alpine harbor.gesila.com/k8s/alpine & & docker pushharbor.gesila.com/k8s/alpine
【harbor-https自动安装脚本】详细安装参考:??https://blog.51cto.com/taowenwu/5052617??
推荐阅读
- Linux文件压缩包
- 本地YUM源建立
- Firewalld 字符管理工具,命令分享
- Git版本控制系统安装部署
- 文件管理-压缩打包命令
- 命令与文件的查询
- Tomcat实现基于域名的多虚拟主机
- 雨林木风 win10 专业版21H264位&32位 v202205
- Vue中的操作指令