From 32e16aec03df3931b207766047f2b8f82b55a8a7 Mon Sep 17 00:00:00 2001 From: songjc <969378911@qq.com> Date: Thu, 23 May 2024 09:53:20 +0800 Subject: [PATCH] =?UTF-8?q?=E9=83=A8=E7=BD=B2=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/x86/build_all.sh | 55 ++++++++++++++++++++ deploy/x86/imagebuild/advisor/Dockerfile | 9 ++++ deploy/x86/imagebuild/advisor/build.sh | 4 ++ deploy/x86/imagebuild/client/Dockerfile | 9 ++++ deploy/x86/imagebuild/client/build.sh | 4 ++ deploy/x86/imagebuild/collector/Dockerfile | 9 ++++ deploy/x86/imagebuild/collector/build.sh | 4 ++ deploy/x86/imagebuild/executor/Dockerfile | 9 ++++ deploy/x86/imagebuild/executor/build.sh | 4 ++ deploy/x86/imagebuild/manager/Dockerfile | 9 ++++ deploy/x86/imagebuild/manager/build.sh | 4 ++ deploy/x86/yaml/advisor.yaml | 29 +++++++++++ deploy/x86/yaml/client.yaml | 49 +++++++++++++++++ deploy/x86/yaml/collector.yaml | 29 +++++++++++ deploy/x86/yaml/config/advisor.config.json | 21 ++++++++ deploy/x86/yaml/config/client.config.json | 15 ++++++ deploy/x86/yaml/config/collector.config.json | 28 ++++++++++ deploy/x86/yaml/config/executor.config.json | 21 ++++++++ deploy/x86/yaml/config/manager.config.json | 24 +++++++++ deploy/x86/yaml/executor.yaml | 29 +++++++++++ deploy/x86/yaml/manager.yaml | 29 +++++++++++ deploy/x86/yaml/start.sh | 32 ++++++++++++ deploy/x86/yaml/stop.sh | 30 +++++++++++ 23 files changed, 456 insertions(+) create mode 100644 deploy/x86/build_all.sh create mode 100644 deploy/x86/imagebuild/advisor/Dockerfile create mode 100644 deploy/x86/imagebuild/advisor/build.sh create mode 100644 deploy/x86/imagebuild/client/Dockerfile create mode 100644 deploy/x86/imagebuild/client/build.sh create mode 100644 deploy/x86/imagebuild/collector/Dockerfile create mode 100644 deploy/x86/imagebuild/collector/build.sh create mode 100644 deploy/x86/imagebuild/executor/Dockerfile create mode 100644 deploy/x86/imagebuild/executor/build.sh create mode 100644 deploy/x86/imagebuild/manager/Dockerfile create mode 100644 deploy/x86/imagebuild/manager/build.sh create mode 100644 deploy/x86/yaml/advisor.yaml create mode 100644 deploy/x86/yaml/client.yaml create mode 100644 deploy/x86/yaml/collector.yaml create mode 100644 deploy/x86/yaml/config/advisor.config.json create mode 100644 deploy/x86/yaml/config/client.config.json create mode 100644 deploy/x86/yaml/config/collector.config.json create mode 100644 deploy/x86/yaml/config/executor.config.json create mode 100644 deploy/x86/yaml/config/manager.config.json create mode 100644 deploy/x86/yaml/executor.yaml create mode 100644 deploy/x86/yaml/manager.yaml create mode 100644 deploy/x86/yaml/start.sh create mode 100644 deploy/x86/yaml/stop.sh diff --git a/deploy/x86/build_all.sh b/deploy/x86/build_all.sh new file mode 100644 index 0000000..986bc7a --- /dev/null +++ b/deploy/x86/build_all.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +build_folder="$PWD/build" +imagebuild_folder="$PWD/imagebuild" +yml_folder="$PWD/yml" + +echo "开始构建advisor镜像..." +cd "$imagebuild_folder"/advisor || exit +rm -rf advisor +rm -rf confs +cp -r "$build_folder"/advisor . +#cp -r "$build_folder"/confs . +sh build.sh +echo "advisor镜像构建完成" + +echo "开始构建collector镜像..." +cd "$imagebuild_folder"/collector || exit +rm -rf collector +rm -rf confs +cp -r "$build_folder"/collector . +#cp -r "$build_folder"/confs . +sh build.sh +echo "collector镜像构建完成" + +echo "开始构建executor镜像..." +cd "$imagebuild_folder"/executor || exit +rm -rf executor +rm -rf confs +cp -r "$build_folder"/executor . +#cp -r "$build_folder"/confs . +sh build.sh +echo "executor镜像构建完成" + +echo "开始构建manager镜像..." +cd "$imagebuild_folder"/manager || exit +rm -rf manager +rm -rf confs +cp -r "$build_folder"/manager . +#cp -r "$build_folder"/confs . +sh build.sh +echo "manager镜像构建完成" + +echo "开始构建client镜像..." +cd "$imagebuild_folder"/client || exit +rm -rf client +rm -rf confs +cp -r "$build_folder"/client . +#cp -r "$build_folder"/confs . +sh build.sh +echo "client镜像构建完成" + +echo "全部镜像构建完成" +#echo "生成yaml脚本" +#cd "$yml_folder" || exit +#sh replace.sh diff --git a/deploy/x86/imagebuild/advisor/Dockerfile b/deploy/x86/imagebuild/advisor/Dockerfile new file mode 100644 index 0000000..7ab04c8 --- /dev/null +++ b/deploy/x86/imagebuild/advisor/Dockerfile @@ -0,0 +1,9 @@ +FROM alpine:latest +COPY . /opt +WORKDIR /opt/advisor +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories +RUN apk add --no-cache tzdata +ENV TZ=Asia/Shanghai +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone +RUN chmod +x advisor +ENTRYPOINT ["./advisor"] diff --git a/deploy/x86/imagebuild/advisor/build.sh b/deploy/x86/imagebuild/advisor/build.sh new file mode 100644 index 0000000..f2233ea --- /dev/null +++ b/deploy/x86/imagebuild/advisor/build.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +docker build -t 112.95.163.90:5010/schadvisorservice-x86:latest . +docker push 112.95.163.90:5010/schadvisorservice-x86:latest diff --git a/deploy/x86/imagebuild/client/Dockerfile b/deploy/x86/imagebuild/client/Dockerfile new file mode 100644 index 0000000..21ddeb1 --- /dev/null +++ b/deploy/x86/imagebuild/client/Dockerfile @@ -0,0 +1,9 @@ +FROM alpine:latest +COPY . /opt +WORKDIR /opt/client +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories +RUN apk add --no-cache tzdata +ENV TZ=Asia/Shanghai +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone +RUN chmod +x client +ENTRYPOINT ["./client","serve","http"] diff --git a/deploy/x86/imagebuild/client/build.sh b/deploy/x86/imagebuild/client/build.sh new file mode 100644 index 0000000..3ffc734 --- /dev/null +++ b/deploy/x86/imagebuild/client/build.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +docker build -t 112.95.163.90:5010/schclientservice-x86:latest . +docker push 112.95.163.90:5010/schclientservice-x86:latest diff --git a/deploy/x86/imagebuild/collector/Dockerfile b/deploy/x86/imagebuild/collector/Dockerfile new file mode 100644 index 0000000..9f5636d --- /dev/null +++ b/deploy/x86/imagebuild/collector/Dockerfile @@ -0,0 +1,9 @@ +FROM alpine:latest +COPY . /opt +WORKDIR /opt/collector +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories +RUN apk add --no-cache tzdata +ENV TZ=Asia/Shanghai +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone +RUN chmod +x collector +ENTRYPOINT ["./collector"] diff --git a/deploy/x86/imagebuild/collector/build.sh b/deploy/x86/imagebuild/collector/build.sh new file mode 100644 index 0000000..78dceb8 --- /dev/null +++ b/deploy/x86/imagebuild/collector/build.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +docker build -t 112.95.163.90:5010/schcollectorservice-x86:latest . +docker push 112.95.163.90:5010/schcollectorservice-x86:latest diff --git a/deploy/x86/imagebuild/executor/Dockerfile b/deploy/x86/imagebuild/executor/Dockerfile new file mode 100644 index 0000000..952c3dc --- /dev/null +++ b/deploy/x86/imagebuild/executor/Dockerfile @@ -0,0 +1,9 @@ +FROM alpine:latest +COPY . /opt +WORKDIR /opt/executor +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories +RUN apk add --no-cache tzdata +ENV TZ=Asia/Shanghai +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone +RUN chmod +x executor +ENTRYPOINT ["./executor"] diff --git a/deploy/x86/imagebuild/executor/build.sh b/deploy/x86/imagebuild/executor/build.sh new file mode 100644 index 0000000..b05faee --- /dev/null +++ b/deploy/x86/imagebuild/executor/build.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +docker build -t 112.95.163.90:5010/schexecutorservice-x86:latest . +docker push 112.95.163.90:5010/schexecutorservice-x86:latest diff --git a/deploy/x86/imagebuild/manager/Dockerfile b/deploy/x86/imagebuild/manager/Dockerfile new file mode 100644 index 0000000..ac6da88 --- /dev/null +++ b/deploy/x86/imagebuild/manager/Dockerfile @@ -0,0 +1,9 @@ +FROM alpine:latest +COPY . /opt +WORKDIR /opt/manager +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories +RUN apk add --no-cache tzdata +ENV TZ=Asia/Shanghai +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone +RUN chmod +x manager +ENTRYPOINT ["./manager"] diff --git a/deploy/x86/imagebuild/manager/build.sh b/deploy/x86/imagebuild/manager/build.sh new file mode 100644 index 0000000..50e66f8 --- /dev/null +++ b/deploy/x86/imagebuild/manager/build.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +docker build -t 112.95.163.90:5010/schmanagerservice-x86:latest . +docker push 112.95.163.90:5010/schmanagerservice-x86:latest diff --git a/deploy/x86/yaml/advisor.yaml b/deploy/x86/yaml/advisor.yaml new file mode 100644 index 0000000..1cd25e4 --- /dev/null +++ b/deploy/x86/yaml/advisor.yaml @@ -0,0 +1,29 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: schadvisor + name: schadvisor + namespace: default +spec: + selector: + matchLabels: + app: schadvisor + template: + metadata: + labels: + app: schadvisor + spec: + containers: + - name: schadvisorservice + image: 112.95.163.90:5010/schadvisorservice-x86:latest + imagePullPolicy: Always + volumeMounts: + - name: schadvisorconfig + mountPath: /opt/confs + volumes: + - name: schadvisorconfig + configMap: + name: schadvisor-config + restartPolicy: Always + diff --git a/deploy/x86/yaml/client.yaml b/deploy/x86/yaml/client.yaml new file mode 100644 index 0000000..ac96d0a --- /dev/null +++ b/deploy/x86/yaml/client.yaml @@ -0,0 +1,49 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: schclient + name: schclient + namespace: default +spec: + selector: + matchLabels: + app: schclient + template: + metadata: + labels: + app: schclient + spec: + containers: + - name: schclientservice + image: 112.95.163.90:5010/schclientservice-x86:latest + imagePullPolicy: Always + volumeMounts: + - name: schclientconfig + mountPath: /opt/confs + volumes: + - name: schclientconfig + configMap: + name: schclient-config + nodeSelector: + nodetype: pcm2 + restartPolicy: Always + +--- +apiVersion: v1 +kind: Service +metadata: + labels: + app: schclient + name: schclient + namespace: default +spec: + ports: + - port: 7891 + protocol: TCP + targetPort: 7891 + nodePort: 32011 + selector: + app: schclient + type: NodePort + diff --git a/deploy/x86/yaml/collector.yaml b/deploy/x86/yaml/collector.yaml new file mode 100644 index 0000000..46be686 --- /dev/null +++ b/deploy/x86/yaml/collector.yaml @@ -0,0 +1,29 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: schcollector + name: schcollector + namespace: default +spec: + selector: + matchLabels: + app: schcollector + template: + metadata: + labels: + app: schcollector + spec: + containers: + - name: schcollectorservice + image: 112.95.163.90:5010/schcollectorservice-x86:latest + imagePullPolicy: Always + volumeMounts: + - name: schcollectorconfig + mountPath: /opt/confs + volumes: + - name: schcollectorconfig + configMap: + name: schcollector-config + restartPolicy: Always + diff --git a/deploy/x86/yaml/config/advisor.config.json b/deploy/x86/yaml/config/advisor.config.json new file mode 100644 index 0000000..7489d0b --- /dev/null +++ b/deploy/x86/yaml/config/advisor.config.json @@ -0,0 +1,21 @@ +{ + "logger": { + "output": "stdout", + "outputFileName": "advisor", + "outputDirectory": "log", + "level": "debug" + }, + "rabbitMQ": { + "address": "127.0.0.1:5672", + "account": "cloudream", + "password": "123456", + "vhost": "/" + }, + "cloudreamStorage": { + "url": "http://localhost:7890" + }, + "pcm": { + "url": "http://localhost:7892" + }, + "reportIntervalSec": 10 +} \ No newline at end of file diff --git a/deploy/x86/yaml/config/client.config.json b/deploy/x86/yaml/config/client.config.json new file mode 100644 index 0000000..7793d02 --- /dev/null +++ b/deploy/x86/yaml/config/client.config.json @@ -0,0 +1,15 @@ +{ + "logger": { + "output": "stdout", + "level": "debug" + }, + "rabbitMQ": { + "address": "127.0.0.1:5672", + "account": "cloudream", + "password": "123456", + "vhost": "/" + }, + "cloudreamStorage": { + "url": "http://localhost:7890" + } +} \ No newline at end of file diff --git a/deploy/x86/yaml/config/collector.config.json b/deploy/x86/yaml/config/collector.config.json new file mode 100644 index 0000000..fc0e5ef --- /dev/null +++ b/deploy/x86/yaml/config/collector.config.json @@ -0,0 +1,28 @@ +{ + "logger": { + "output": "stdout", + "outputFileName": "collector", + "outputDirectory": "log", + "level": "debug" + }, + "rabbitMQ": { + "address": "127.0.0.1:5672", + "account": "cloudream", + "password": "123456", + "vhost": "/" + }, + "cloudreamStorage": { + "url": "http://localhost:7890" + }, + "unifyOps": { + "url": "http://localhost:7891" + }, + "slwNodes": [ + { + "id": 1711652475901054976, + "name": "hwj", + "stgNodeID": 1, + "storageID": 1 + } + ] +} \ No newline at end of file diff --git a/deploy/x86/yaml/config/executor.config.json b/deploy/x86/yaml/config/executor.config.json new file mode 100644 index 0000000..83f9aa5 --- /dev/null +++ b/deploy/x86/yaml/config/executor.config.json @@ -0,0 +1,21 @@ +{ + "logger": { + "output": "stdout", + "outputFileName": "executor", + "outputDirectory": "log", + "level": "debug" + }, + "rabbitMQ": { + "address": "127.0.0.1:5672", + "account": "cloudream", + "password": "123456", + "vhost": "/" + }, + "cloudreamStorage": { + "url": "http://localhost:7890" + }, + "pcm": { + "url": "http://localhost:7070" + }, + "reportIntervalSec": 10 +} \ No newline at end of file diff --git a/deploy/x86/yaml/config/manager.config.json b/deploy/x86/yaml/config/manager.config.json new file mode 100644 index 0000000..aa59370 --- /dev/null +++ b/deploy/x86/yaml/config/manager.config.json @@ -0,0 +1,24 @@ +{ + "logger": { + "output": "stdout", + "outputFileName": "manager", + "outputDirectory": "log", + "level": "debug" + }, + "rabbitMQ": { + "address": "127.0.0.1:5672", + "account": "cloudream", + "password": "123456", + "vhost": "/" + }, + "db": { + "address": "127.0.0.1:3306", + "account": "root", + "password": "123456", + "databaseName": "scheduler" + }, + "cloudreamStorage": { + "url": "http://localhost:7890" + }, + "reportTimeoutSecs": 20 +} \ No newline at end of file diff --git a/deploy/x86/yaml/executor.yaml b/deploy/x86/yaml/executor.yaml new file mode 100644 index 0000000..63cff31 --- /dev/null +++ b/deploy/x86/yaml/executor.yaml @@ -0,0 +1,29 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: schexecutor + name: schexecutor + namespace: default +spec: + selector: + matchLabels: + app: schexecutor + template: + metadata: + labels: + app: schexecutor + spec: + containers: + - name: schexecutorservice + image: 112.95.163.90:5010/schexecutorservice-x86:latest + imagePullPolicy: Always + volumeMounts: + - name: schexecutorconfig + mountPath: /opt/confs + volumes: + - name: schexecutorconfig + configMap: + name: schexecutor-config + restartPolicy: Always + diff --git a/deploy/x86/yaml/manager.yaml b/deploy/x86/yaml/manager.yaml new file mode 100644 index 0000000..b5206a6 --- /dev/null +++ b/deploy/x86/yaml/manager.yaml @@ -0,0 +1,29 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: schmanager + name: schmanager + namespace: default +spec: + selector: + matchLabels: + app: schmanager + template: + metadata: + labels: + app: schmanager + spec: + containers: + - name: schmanagerservice + image: 112.95.163.90:5010/schmanagerservice-x86:latest + imagePullPolicy: Always + volumeMounts: + - name: schmanagerconfig + mountPath: /opt/confs + volumes: + - name: schmanagerconfig + configMap: + name: schmanager-config + restartPolicy: Always + diff --git a/deploy/x86/yaml/start.sh b/deploy/x86/yaml/start.sh new file mode 100644 index 0000000..9ef5e53 --- /dev/null +++ b/deploy/x86/yaml/start.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# 获取当前路径 +current_path=$(pwd) + +# 拉起configmap +cd $current_path/config +config_files=$(ls *.json 2>/dev/null) + +if [ -z "$config_files" ]; then + echo "当前路径下没有.config.json文件。" + exit 1 +fi + +for file in $config_files; do + if [[ -f "$file" ]]; then + name=$(echo "$file" | cut -d '.' -f1) + kubectl create cm sch$name-config --from-file=./$file + fi +done + +# 拉起pod +cd $current_path +yaml_files=$(ls *.yaml 2>/dev/null) +for yaml_file in $yaml_files; do + echo "Applying $yaml_file ..." + kubectl apply -f $yaml_file +done + + + + diff --git a/deploy/x86/yaml/stop.sh b/deploy/x86/yaml/stop.sh new file mode 100644 index 0000000..dab2160 --- /dev/null +++ b/deploy/x86/yaml/stop.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# 获取当前路径 +current_path=$(pwd) + +# 删除configmap +cd $current_path/config +config_files=$(ls *.json 2>/dev/null) + +if [ -z "$config_files" ]; then + echo "当前路径下没有.config.json文件。" + exit 1 +fi + +for file in $config_files; do + if [[ -f "$file" ]]; then + name=$(echo "$file" | cut -d '.' -f1) + kubectl delete cm sch$name-config + fi +done + +# 删除pod +cd $current_path +yaml_files=$(ls *.yaml 2>/dev/null) + +for yaml_file in $yaml_files; do + echo "Delete $yaml_file ..." + kubectl delete -f $yaml_file +done +