Harbor(2.3.0)的定制页面与安装(x86 & arm)
目录
安装docker-compose(docker里面的compose也可以)
说明
开源协议
harbor-arm官方地址:https://github.com/goharbor/harbor-arm
想对Harbor进行二次开发,首先要指定一个harbor的版本,这里我们以Harbor:2.3.0为例:
下载指定版本的Harbor: GitHub - goharbor/harbor at release-2.3.0
查看指定版本的官方文档:https://goharbor.io/docs/2.3.0/
这里要注意,一定要看指定版本的文档,否则会有意想不到的报错!友情提示!!!
第一步:需要准备的环境
Software | Required Version |
docker | 17.05 + |
docker-compose | 1.18.0 + |
python | 2.7 + |
git | 1.9.1 + |
make | 3.81 + |
golang* | 1.15.6 + |
*optional, required only if you use your own Golang environment.
*可选,仅当您使用自己的Golang环境时才需要。
X86环境下的环境准备
安装docker
curl -sSL https://get.daocloud.io/docker | sh
启动 Docker。
$ sudo systemctl start docker
卸载 docker
删除安装包:
yum remove docker-ce
删除镜像、容器、配置文件等内容:
rm -rf /var/lib/docker
安装docker-compose(docker里面的compose也可以)
sudo curl -L "https://github.com/docker/compose/releases/download/v2.2.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
将可执行权限应用于二进制文件:
$ sudo chmod +x /usr/local/bin/docker-compose
创建软链:
$ sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
测试是否安装成功:
$ docker-compose version
安装git
先看看自带的是否瞒住要求,一般都满足要求
CentOS7自带的git版本1.8.3.1,这个版本有点低了。
1.卸载旧版本git
yum remove git
2.安装git仓库
rpm -ivh http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-1.noarch.rpm
3.安装新版本git
yum -y install git
安装go(用go镜像也可以)
一般用镜像就可以,不用单独安装
如果需要安装:
golang所有版本网址
https://studygolang.com/dl
//下载并解压到/usr/local文件下
wget https://studygolang.com/dl/golang/go1.18.3.linux-amd64.tar.gz
//解压并复制到/user/local文件夹下
tar -C /usr/local -zxf go1.18.3.linux-amd64.tar.gz
2.编辑环境变量文件
vim /etc/profile
在文件后追加以下内容
export GOPROXY=https://goproxy.cn
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
export GOPATH=/root/go
export PATH=$PATH:$GOPATH/BIN
退出并保存,刷新环境变量
source /etc/profile
3.检验安装是否成功
go –version
其他依赖
Make、python 自带的就可以
arm环境下的环境准备
arm结构下安装docker
arm架构下安装docker compose
安装docker 和docker-compose-CSDN博客
arm下安装buildx 插件
将安装包上传 /home 目录下
cd /home
将 buildx-v0.8.2.linux-arm64 文件复制到/usr/lib/docker/cli-plugins目录下,并重命名为docker-buildx'
cp buildx-v0.8.2.linux-arm64 /usr/lib/docker/cli-plugins/docker-buildx
echo '添加docker-buildx文件权限'
chmod +x /usr/lib/docker/cli-plugins/docker-buildx
验证
docker buildx version
docker buildx ls
arm其他依赖
git、python、make 自带的都可以满足
go用镜像就可以
第二步:下载代码:
X86 code
然后 git ckeckout release-2.3.0 切换到对应版本
ARM code
先下载harbor-arm工程(打包工具工程)
git clone https://github.com/goharbor/harbor-arm.git
然后命令下载 harbor source code 核心代码
cd harbor-arm && make download
第三步:修改前台代码
Harber支持的简单的修改:
自定义主题和外观、logo、标题等
Harbor docs | Customize the Look and Feel of Harbor
国际化及一些菜单提示的修改
Harbor docs | Developing for Internationalization
前端的进一步自我定制开发和测试
Harbor docs | Developing for Internationalization
具体流程如下:
1. npm install (should trigger 'npm postinstall')
2. npm run postinstall (if not triggered, manually run this step)
3. create "proxy.config.json" file with below content under "portal" directory, and replace "hostname" with an available Harbor hostname
4. npm run start
5. open your browser on https://localhost:4200
```json
{
"/api/*": {
"target": "https://hostname",
"secure": false,
"changeOrigin": true,
"logLevel": "debug"
},
"/service/*": {
"target": "https://hostname",
"secure": false,
"logLevel": "debug"
},
"/c/login": {
"target": "https://hostname",
"secure": false,
"logLevel": "debug"
},
"/c/oidc/login": {
"target": "https://hostname",
"secure": false,
"logLevel": "debug"
},
"/sign_in": {
"target": "https://hostname",
"secure": false,
"logLevel": "debug"
},
"/c/log_out": {
"target": "https://hostname",
"secure": false,
"logLevel": "debug"
},
"/sendEmail": {
"target": "https://hostname",
"secure": false,
"logLevel": "debug"
},
"/language": {
"target": "https://hostname",
"secure": false,
"logLevel": "debug"
},
"/reset": {
"target": "https://hostname",
"secure": false,
"logLevel": "debug"
},
"/c/userExists": {
"target": "https://hostname",
"secure": false,
"logLevel": "debug"
},
"/reset_password": {
"target": "https://hostname",
"secure": false,
"logLevel": "debug"
},
"/i18n/lang/*.json": {
"target": "https://hostname",
"secure": false,
"logLevel": "debug"
},
"/swagger.json": {
"target": "https://hostname",
"secure": false,
"logLevel": "debug"
},
"/swagger2.json": {
"target": "https://hostname",
"secure": false,
"logLevel": "debug"
},
"/chartrepo/*": {
"target": "https://hostname",
"secure": false,
"logLevel": "debug"
},
"/LICENSE": {
"target": "https://hostname",
"secure": false,
"logLevel": "debug"
}
}
```
本地调试问题
- npm版本低的话,需要升级npm
- create "proxy.config.json" file with below content under "portal" directory, and replace "hostname" with an available Harbor hostname 这一步中的"proxy.config.json" 可以参考本文件所在目录下的,连的是测试环境的后台
- npm install 安装后,npm run start仍然提示缺包的话需要自己手动安装后再次启动
比如提示缺少react-dom
自己手动安装
启动成功后如下
第四步:打包安装harbor
在按需定制好前台后需要部署前后台
公共准备(x86 和 arm都需要)
修改配置文件配置
将文件make/harbor.yml.tmp 复制到make/harbor.yml, 然后修改必要的配置 比如修改hostname, admin password 和mail server等等
示例:
修改 ip 地址
#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
harbor_admin_password: Harbor12345 //web界面admin用户的密码
[root@master harbor]# vi /etc/hosts
[root@master harbor]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.75.128 master.example.com //添加你的ip和主机名
安装前的一些准备
打包安装前,启动daocker,并登录号 docker.io
因为过程中会下载基础镜像,不登录,pull下载镜像会有限制
最好通过命令 chmod -R 777 /make 把make目录下所有的文件都赋予执行权限
最好在linux上直接clone工程,然后只将前台修改部分覆盖
如果工程目录是从windows上复制过来的,sh脚本可能会有问题,要通过一下命令处理下sh脚本
sed -i 's/\r$//' make/*.sh
sed -i 's/\r$//' make/photon/*/*.sh
可能还存在其他脚本,具体看报错
保证网络可用,可以正常访问github、docker
Github不可用的话这一步会出错
X86安装
编译、构建镜像、启动harbor
1、然后使用官方的go镜像打包harbor:
(1)在没有公证人的情况下构建,安装和启动Harbor:
make install COMPILETAG=compile_golangimage
(2)使用公证人建立,安装和启动Harbor:
make install COMPILETAG=compile_golangimage NOTARYFLAG=true
2、使用自己的Golang环境编译代码,然后构建Harbor
mkdir $GOPATH/src/github.com/goharbor/
cd ..
mv harbor $GOPATH/src/github.com/goharbor/.
(1)在没有公证人的情况下构建,安装和启动Harbor:
cd $GOPATH/src/github.com/goharbor/harbor
make install
(2)使用公证人建立,安装和启动Harbor:
cd $GOPATH/src/github.com/goharbor/harbor
make install -e NOTARYFLAG=true CLAIRFLAG=true
打包离线包
make package_offline COMPILETAG=compile_golangimage
arm安装
系统要求
在Linux主机上:docker 19+并支持docker buildx
在构建harobor镜像之前,您需要检查本地环境是否支持docker buildx
通过运行命令“docker buildx ls”,如果结果显示“linux/arm64”,则证明可以构建arm镜像
安装命令流程
在 /harbor-arm 目录下就可以执行
## Get Started
```
# first step: clone harbor ARM code
git clone https://github.com/goharbor/harbor-arm.git
# execute build command:Download harbor source code
cd harbor-arm && make download
# compile redis:
make compile_redis
# Prepare to build arm architecture image data:
make prepare_arm_data
# Replace build arm image parameters:
make pre_update
# Compile harbor components:
make compile COMPILETAG=compile_golangimage
# Build harbor arm image:
make build GOBUILDTAGS="include_oss include_gcs" BUILDBIN=true NOTARYFLAG=true TRIVYFLAG=true CHARTFLAG=true GEN_TLS=true PULL_BASE_FROM_DOCKERHUB=false
```
Make具体可以执行哪些命令可以查看makefile 文件
harbor-arm/Makefile at main · goharbor/harbor-arm · GitHub
打包离线包
要进 harbor-arm/src/github.com/goharbor/harbor 目录下执行
make package_offline COMPILETAG=compile_golangimage
验证安装
安装后会看到如下信息:
Start complete. You can visit harbor now.
Harbor的启动与停止
Restart Docker Engine.
systemctl restart docker
Stop Harbor.
docker-compose down -v
Restart Harbor.
docker-compose up -d
启动和停止命令要在 harbor/make 目录下执行
Make命令
参数
参数 | 描述 |
BASEIMAGETAG | The tag for base image, default:dev |
VERSIONTAG | The tag for harbor image, default:dev |
DEVFLAG | Build model flag, default: true |
GOBUILDIMAGE | Golang image to compile harbor go source code. |
NOTARYFLAG | Whether to enable notary in harbor, default:false |
TRIVYFLAG | Whether to enable trivy in harbor, default:false |
CHARTFLAG | Whether to enable chartmuseum in harbor, default:false |
HTTPPROXY | Clarity proxy to build UI. |
Make 任务
任务 | 描述 |
all | prepare env, compile binaries, build images and install images |
prepare | prepare env |
compile | compile core and jobservice code |
compile_core | compile core binary |
compile_jobservice | compile jobservice binary |
build | build Harbor docker images |
build_base_docker | build Harbor docker base images |
install | compile binaries, build images, prepare specific version of compose file and startup Harbor instance |
start | startup Harbor instance |
down | shutdown Harbor instance |
package_online | prepare online install package |
package_offline | prepare offline install package |
pushimage | push Harbor images to specific registry server |
cleanall | remove binary, Harbor images, specific version docker-compose file, specific version tag and online/offline install package |
cleanbinary | remove core and jobservice binary |
cleanimage | remove Harbor images |
cleandockercomposefile | remove specific version docker-compose |
cleanpackage | remove online/offline install package |
原文地址:https://blog.csdn.net/mengo1234/article/details/144750333
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!