准备工作
构建环境准备
- 机器中需要含有以下命令:
git拉取代码go构建底座PaaS中Golang编写的服务docker构建底座PaaS的容器镜像
- 一个可用于上传构建容器镜像仓库(执行
docker push推送镜像) - 运维应用(SaaS)构建需要在Kubernetes集群中进行:
- Kubernetes 的版本需要大于等于 1.20
- 所需服务器资源量不小于快速安装方案(3台4核16G)
拉取源码
git clone http://github.com/alibaba/sreworks.git -b v1.4 sreworkscd sreworksSW_ROOT=$(pwd)
源码目录结构
├── README.md├── build.sh /* 底座构建脚本 */├── paas /* 底座源码(PaaS) */│ ├── appmanager/ /* 核心应用引擎 appmanager */│ ├── frontend/ /* 前端低代码框架 */│ └── ...├── saas /* 运维应用源码(SaaS) */│ ├── app/ /* 企业应用管理 */│ ├── cluster/ /* 集群管理 */│ ├── dataops/ /* 数据运维平台 */│ └── ...├── plugins/ /* 插件仓库 */│ ├── components/ /* 插件-组件仓库 */│ ├── traits/ /* 插件-运维特征仓库 */│ └── ...├── chart/ /* SREWorks的Helm Chart包 */└── sbin /* 各类辅助脚本工具 */├── upgrade-cluster.sh /* 底座升级脚本 */└── ...
底座源码(PaaS)构建
本地镜像构建
在sreworks目录下,可以在本地执行构建脚本。
执行之前请确认 底座构建依赖 提及的资源均可访问,如不能直接访问,请替换成可访问的资源。
./build.sh --target all --build --tag v1.4
如果镜像无法构建成功,可以直接去公网搬运镜像跳过这个环节,镜像内容是完全一致的。
镜像清单请看参考 https://github.com/alibaba/SREWorks/blob/master/images.txt 其中tag名为v1.4均为底座镜像。
上传SREWorks到仓库
将构建产物发布上传到镜像仓库,SW_REPO变量替换成用户自己准备的容器镜像仓库。
SW_REPO="your-registry.***.com/sreworks"docker login --username=sre****s your-registry.***.com./build.sh --target all --push $SW_REPO --tag v1.4
运维应用(SaaS)源码构建
步骤与快速安装大致相同,替换helm install参数, 触发运维应用来自源码的容器镜像构建。其原理是拉起git仓库的源码,通过云原生化的kankio构建方案构建容器镜像。
执行前注意确认 运维应用构建依赖 和 运维应用运行依赖 提及的资源均可访问,如不能直接访问,请替换成可访问的资源。
# appmanager.server.docker.* 参数为SaaS应用构建制品镜像仓库配置# source.branch/source.repo 参数SaaS应用构建源码仓库来源helm install sreworks $SW_ROOT/chart/sreworks-chart \--kubeconfig="****" \--create-namespace --namespace sreworks \--set appmanager.home.url="https://your-website.***.com" \--set build.enable=true \--set global.images.tag="v1.4" \--set global.images.registry=$SW_REPO \--set appmanager.server.docker.account="sreworks" \--set appmanager.server.docker.password="***" \--set appmanager.server.docker.registry="registry.cn-zhangjiakou.aliyuncs.com" \--set appmanager.server.docker.namespace="builds" \--set source.branch="v1.4" \--set source.repo="https://code.aliyun.com/sreworks_public/mirror.git"
构建参数明细
底座构建依赖
在执行 ./build.sh 命令前可传入下列的环境变量来改变资源地址,如不传入则使用默认值。
# 容器镜像export SW_PYTHON3_IMAGE="python:3.9.12-alpine"export MIGRATE_IMAGE="migrate/migrate"export MAVEN_IMAGE="maven:3.8.3-adoptopenjdk-11"export GOLANG_IMAGE="golang:alpine"export GOLANG_BUILD_IMAGE="golang:1.16"export DISTROLESS_IMAGE="sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/distroless-static:nonroot"# 软件仓库export APK_REPO_DOMAIN="mirrors.tuna.tsinghua.edu.cn"export PYTHON_PIP="http://mirrors.aliyun.com/pypi/simple"export GOPROXY="https://goproxy.cn"export MAVEN_SETTINGS_XML="https://sreworks.oss-cn-beijing.aliyuncs.com/resource/settings.xml"# 二进制命令export HELM_BIN_URL="https://abm-storage.oss-cn-zhangjiakou.aliyuncs.com/lib/helm"export KUSTOMIZE_BIN_URL="https://abm-storage.oss-cn-zhangjiakou.aliyuncs.com/lib/kustomize"export MINIO_CLIENT_URL="https://sreworks.oss-cn-beijing.aliyuncs.com/bin/mc-linux-amd64"# SREWorks内置应用包export SREWORKS_BUILTIN_PACKAGE_URL="https://sreworks.oss-cn-beijing.aliyuncs.com/packages"
运维应用构建依赖
在执行helm install/upgrade 命令的时候,可以选择性传入以下参数,使得运维应用可以在内网进行构建及部署。
# 容器镜像--set global.artifacts.mavenImage="sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/maven:3.8.3-adoptopenjdk-11" \--set global.artifacts.openjdk8Image="sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/openjdk8:alpine-jre" \--set global.artifacts.openjdk11Image="sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/openjdk:11.0.10-jre" \--set global.artifacts.openjdk11AlpineImage="sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/openjdk11:alpine-jre" \--set global.artifacts.alpineImage="sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/alpine:latest" \--set global.artifacts.nodeImage="sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/node:10-alpine" \--set global.artifacts.migrateImage="sw-migrate" \--set global.artifacts.postrunImage="sw-postrun" \--set global.artifacts.python3Image="sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/python:3.9.12-alpine" \--set global.artifacts.bentomlImage="sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/bentoml-model-server:0.13.1-py37" \# 软件仓库--set global.artifacts.apkRepoDomain="mirrors.tuna.tsinghua.edu.cn" \--set global.artifacts.mavenSettingsXml="https://sreworks.oss-cn-beijing.aliyuncs.com/resource/settings.xml" \--set global.artifacts.npmRegistryUrl="https://registry.npmmirror.com" \--set global.artifacts.pythonPip="http://mirrors.aliyun.com/pypi/simple" \# 二进制命令--set global.artifacts.minioClientUrl="https://sreworks.oss-cn-beijing.aliyuncs.com/bin/mc-linux-amd64" \
运维应用运行依赖
除了构建依赖的源以外,还有很多开源软件,请确保其镜像可访问
# SaaS应用Helm包中依赖的镜像--set global.artifacts.logstashImage="sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/logstash:7.10.2" \--set global.artifacts.grafanaImage="sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/grafana:7.5.3" \--set global.artifacts.kibanaImage="sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/kibana:7.10.2" \--set global.artifacts.elasticsearchImage="sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/elasticsearch:7.10.2-with-plugins" \--set global.artifacts.skywalkingOapImage="sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/skywalking-oap-server-utc-8:8.5.0-es7" \--set global.artifacts.skywalkingUiImage="sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/skywalking-ui:8.5.0" \--set global.artifacts.busyboxImage="sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/busybox:1.30" \--set global.artifacts.vvpRegistry="sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror" \--set global.artifacts.vvpAppmanagerImage="sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/vvp-appmanager:2.6.1" \--set global.artifacts.vvpGatewayImage="sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/vvp-gateway:2.6.1" \--set global.artifacts.vvpUiImage="sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/vvp-ui:2.6.1" \--set global.artifacts.metricbeatImage="sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/metricbeat:7.10.2" \--set global.artifacts.filebeatImage="sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/filebeat:7.10.2" \--set global.artifacts.mysqlImage="sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/mysql:8.0.22-debian-10-r44" \# 基础底座的Helm包中依赖的镜像--set appmanagerbase.minio.image.registry="sreworks-registry.cn-beijing.cr.aliyuncs.com" \--set appmanagerbase.minio.image.repository="mirror/minio" \--set appmanagerbase.minio.image.tag="v1.0" \--set appmanagerbase.mysql.image.registry="sreworks-registry.cn-beijing.cr.aliyuncs.com" \--set appmanagerbase.mysql.image.repository="mirror/mysql" \--set appmanagerbase.mysql.image.tag="v1.0" \--set appmanagerbase.redis.image.registry="sreworks-registry.cn-beijing.cr.aliyuncs.com" \--set appmanagerbase.redis.image.repository="mirror/redis" \--set appmanagerbase.redis.image.tag="v1.0" \
其中flink部分需要按照global.artifacts.vvpRegistry的前缀上传如下镜像,建议优先使用flink1.14版本, flink1.12和flink1.13版本根据实际需要提供
sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/flink:1.12.7-stream1-scala_2.12-java8sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/flink:1.12.7-stream1-scala_2.12-java11sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/flink:1.13.5-stream1-scala_2.12-java8sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/flink:1.13.5-stream1-scala_2.12-java11sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/flink:1.14.2-stream1-scala_2.12-java8sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/flink:1.14.2-stream1-scala_2.12-java11sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/vvp-result-fetcher-service:2.6.1
