Browse Source

部署相关

tags/v4.1.0-cloud.1
Lijunmao 1 month ago
parent
commit
6c6acf966b
6 changed files with 261 additions and 7 deletions
  1. +33
    -6
      Makefile
  2. +13
    -0
      build/application/platform-server/dockerfile
  3. +52
    -0
      deploy/charts/octopus/templates/_helpers.tpl
  4. +6
    -0
      deploy/charts/octopus/templates/ingress.yaml
  5. +142
    -0
      deploy/charts/octopus/templates/platform-server.yaml
  6. +15
    -1
      deploy/charts/octopus/values.yaml

+ 33
- 6
Makefile View File

@@ -42,7 +42,7 @@ LD_FLAGS=" \
# 编译
all_build: server_build

server_build: base-server_build admin-server_build openai-server_build taskset_build
server_build: base-server_build admin-server_build openai-server_build platform-server_build taskset_build

init:
mkdir -p ${SERVER_BINARY_DIR}
@@ -62,6 +62,11 @@ openai-server_build: init

cd ./server/openai-server && go build -ldflags ${LD_FLAGS} -o ${SERVER_BINARY_DIR} ./...

platform-server_build: init
cd ./server && go generate

cd ./server/platform-server && go build -ldflags ${LD_FLAGS} -o ${SERVER_BINARY_DIR} ./...

taskset_build: pipeline_build vc-controller_build scheduler_build

pipeline_build: init
@@ -78,7 +83,7 @@ api-doc_build: init
# 运行
all_run: server_run

server_run: base-server_run admin-server_run openai-server_run taskset_run
server_run: base-server_run admin-server_run openai-server_run platform-server_run taskset_run

base-server_run:
cd server && ./bin/base-server -conf base-server/configs &
@@ -89,6 +94,9 @@ admin-server_run:
openai-server_run:
cd server && ./bin/openai-server -conf openai-server/configs &

platform-server_run:
cd server && ./bin/platform-server -conf platform-server/configs &

taskset_run: pipeline_run vc-controller_run scheduler_run

pipeline_run:
@@ -114,6 +122,9 @@ admin-server_stop:
openai-server_stop:
kill -9 `ps -ef|grep "openai-server" |grep -v grep |awk '{print $2}'`

platform-server_stop:
kill -9 `ps -ef|grep "platform-server" |grep -v grep |awk '{print $2}'`

taskset_stop: pipeline_stop vc-controller_stop scheduler_stop

pipeline_stop:
@@ -128,7 +139,7 @@ scheduler_stop:
# 重启
all_stop: server_restart

server_restart: base-server_restart admin-server_restart openai-server_restart taskset_restart
server_restart: base-server_restart admin-server_restart openai-server_restart platform-server_restart taskset_restart

base-server_restart: base-server_stop server_run

@@ -136,6 +147,8 @@ admin-server_restart: admin-server_stop admin-server_run

openai-server_restart: openai-server_stop openai-server_run

platform-server_restart: platform-server_stop platform-server_run

taskset_restart: pipeline_restart vc-controller_restart scheduler_restart

pipeline_restart: pipeline_stop pipeline_run
@@ -167,7 +180,7 @@ taskset_lint: lint_init
cd ./server/taskset && golangci-lint run ./...

# 构建镜像
images: base-server_image admin-server_image openai-server_image taskset_image admin-portal_image openai-portal_image api-doc_image
images: base-server_image admin-server_image openai-server_image platform-server_image taskset_image admin-portal_image openai-portal_image api-doc_image

base-server_image:
docker build --no-cache -t base-server:${RELEASE_VER} -f ./build/application/base-server/dockerfile .
@@ -178,6 +191,9 @@ admin-server_image:
openai-server_image:
docker build --no-cache -t openai-server:${RELEASE_VER} -f ./build/application/openai-server/dockerfile .

platform-server_image:
docker build --no-cache -t platform-server:${RELEASE_VER} -f ./build/application/platform-server/dockerfile .

taskset_image: pipeline_image vc-controller_image scheduler_image

pipeline_image:
@@ -199,7 +215,7 @@ api-doc_image:
docker build --no-cache -t api-doc:${RELEASE_VER} -f ./build/application/api-doc/dockerfile .

# 镜像推送
images_push: base-server_image_push admin-server_image_push openai-server_image_push taskset_image_push admin-portal_image_push openai-portal_image_push api-doc_image_push
images_push: base-server_image_push admin-server_image_push openai-server_image_push platform-server_image_push taskset_image_push admin-portal_image_push openai-portal_image_push api-doc_image_push

image_push_init:
(echo ${DOCKER_HUB_PASSWD} | docker login ${DOCKER_HUB_HOST} -u ${DOCKER_HUB_USERNAME} --password-stdin) 1>/dev/null 2>&1
@@ -237,6 +253,17 @@ ifeq (${NEED_LATEST}, TRUE)
endif
endif

platform-server_image_push: image_push_init
docker tag platform-server:${RELEASE_VER} ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/platform-server:${RELEASE_VER}
docker push ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/platform-server:${RELEASE_VER}

ifneq (${RELEASE_VER}, latest)
ifeq (${NEED_LATEST}, TRUE)
docker tag platform-server:${RELEASE_VER} ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/platform-server:latest
docker push ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/platform-server:latest
endif
endif

taskset_image_push: pipeline_image_push vc-controller_image_push scheduler_image_push

pipeline_image_push: image_push_init
@@ -311,7 +338,7 @@ charts: charts_build charts_push

charts_build:
-mkdir -p ./tmp/charts
helm package ./deploy/charts/octopus --dependency-update --version ${RELEASE_VER} --app-version ${RELEASE_VER} -d ./tmp/charts
helm package ./deploy/charts/octopus --version ${RELEASE_VER} --app-version ${RELEASE_VER} -d ./tmp/charts

charts_push:
-helm repo add --ca-file=${HARBOR_HUB_CA_FILE} --cert-file=${HARBOR_HUB_CERT_FILE} --username=${HARBOR_HUB_USERNAME} --password=${HARBOR_HUB_PASSWD} chartrepo ${HARBOR_HUB_HOST}/chartrepo/${HARBOR_HUB_PROJECT}


+ 13
- 0
build/application/platform-server/dockerfile View File

@@ -0,0 +1,13 @@
from swr.cn-south-1.myhuaweicloud.com/openioctopus/kratos:v2 as builder
WORKDIR /app
COPY ./ ./

RUN make platform-server_build binary_dir="/app/server/bin"

FROM alpine
WORKDIR /app
COPY --from=builder /app/server/bin/platform-server /app/platform-server
RUN chmod +x /app/platform-server
EXPOSE 8001

ENTRYPOINT ["/app/platform-server"]

+ 52
- 0
deploy/charts/octopus/templates/_helpers.tpl View File

@@ -250,6 +250,58 @@ octopus.pcl.ac.cn/resource: {{ .Values.common.resourceTagValuePrefix }}_{{ inclu
{{- end -}}


{{/******************platform-server******************/}}

{{- define "platformserver.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{- define "platformserver.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- printf "%s-platformserver" .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{- define "platformserver.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{- define "platformserver.core-labels" -}}
helm.sh/chart: {{ include "platformserver.chart" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}

{{- define "platformserver.select-labels" -}}
app.kubernetes.io/name: {{ include "platformserver.name" . }}
app.kubernetes.io/instance: {{ include "platformserver.fullname" . }}
app.kubernetes.io/part-of: {{ include "platformserver.name" . }}
{{- end -}}

{{- define "platformserver.resource-labels" -}}
octopus.pcl.ac.cn/resource: {{ .Values.common.resourceTagValuePrefix }}_{{ include "platformserver.fullname" . }}_{{ default .Chart.AppVersion .Values.platformserver.image.tag }}
{{- end -}}


{{- define "platformserver.labels" -}}
{{ include "platformserver.core-labels" . }}
{{ include "platformserver.select-labels" . }}
{{ include "platformserver.resource-labels" . }}
{{- end -}}

{{- define "platformserver.port" -}}
{{- printf "8004" -}}
{{- end -}}


{{/******************base-server******************/}}



+ 6
- 0
deploy/charts/octopus/templates/ingress.yaml View File

@@ -2,11 +2,13 @@
{{- $fullName := include "octopus.fullname" . -}}
{{- $adminserverName := include "adminserver.fullname" . -}}
{{- $openaiserverName := include "openaiserver.fullname" . -}}
{{- $platformserverName := include "platformserver.fullname" . -}}
{{- $adminportalName := include "adminportal.fullname" . -}}
{{- $openaiportalName := include "openaiportal.fullname" . -}}
{{- $apidocName := include "apidoc.fullname" . -}}
{{- $adminserverPath := .Values.ingress.adminserverPath -}}
{{- $openaiserverPath := .Values.ingress.openaiserverPath -}}
{{- $platformserverPath := .Values.ingress.platformserverPath -}}
{{- $adminportalPath := trimSuffix "/" .Values.ingress.adminportalPath -}}
{{- $openaiportalPath := trimSuffix "/" .Values.ingress.openaiportalPath -}}
{{- $minioName := include "minio.fullname" . -}}
@@ -37,6 +39,10 @@ spec:
serviceName: {{ $openaiserverName }}
servicePort: {{ template "openaiserver.port" . }}
path: {{ $openaiserverPath }}(/|$)(.*)
- backend:
serviceName: {{ $platformserverName }}
servicePort: {{ template "platformserver.port" . }}
path: {{ $platformserverPath }}(/|$)(.*)

---



+ 142
- 0
deploy/charts/octopus/templates/platform-server.yaml View File

@@ -0,0 +1,142 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ template "platformserver.fullname" . }}

---

apiVersion: v1
kind: Service
metadata:
name: {{ template "platformserver.fullname" . }}
labels:
{{ include "platformserver.labels" . | indent 4 }}
spec:
ports:
- name: http
protocol: TCP
port: {{ template "platformserver.port" . }}
targetPort: {{ template "platformserver.port" . }}
selector:
{{ include "platformserver.select-labels" . | indent 8 }}


---

kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ template "platformserver.fullname" . }}
subjects:
- kind: ServiceAccount
name: {{ template "platformserver.fullname" . }}
namespace: {{ .Release.Namespace }}
roleRef:
kind: ClusterRole
name: cluster-admin
apiGroup: rbac.authorization.k8s.io

---

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ template "platformserver.fullname" . }}
rules:
- apiGroups:
- '*'
resources:
- '*'
verbs:
- get
- watch
- list
- create
- update
- patch
- delete

---

apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "platformserver.fullname" . }}
labels:
{{ include "platformserver.labels" . | indent 4 }}
data:
platformserver-config.yml: |
app:
name: platformserver
version: v1.0
isDev: false
logLevel: {{ .Values.platformserver.app.logLevel }}
server:
http:
addr: 0.0.0.0:8001
timeout: 60s
jwtSecrect: asdf
data:
baseServerAddr: {{ include "baseserver.grpcServiceAddr" . }}
baseServerRequestTimeout: 30s
redis:
addr: {{ include "redis.serviceAddr" . }}
username: {{ .Values.platformserver.data.redis.username }}
password: {{ .Values.platformserver.data.redis.password }}
service:
port: {{ template "platformserver.port" . }}
targetPort: {{ template "platformserver.port" . }}
tokenExpirationSec: 86400

---

apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "platformserver.fullname" . }}
spec:
selector:
matchLabels:
{{ include "platformserver.select-labels" . | indent 8 }}
replicas: {{ .Values.platformserver.replicas }}
template:
metadata:
labels:
{{ include "platformserver.labels" . | indent 8 }}
spec:
serviceAccountName: {{ template "platformserver.fullname" . }}
volumes:
- name: localtime
hostPath:
path: /etc/localtime
- name: platformserver-config
configMap:
name: {{ template "platformserver.fullname" . }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.global.image.repository.address }}{{ .Values.global.image.repository.pathname }}/{{ .Values.platformserver.image.name }}:{{ default .Chart.AppVersion .Values.platformserver.image.tag }}"
imagePullPolicy: {{ .Values.global.image.pullPolicy }}
args: [ "-conf", "/etc/platformserver/platformserver-config.yml" ]
volumeMounts:
- name: localtime
mountPath: /etc/localtime
- name: platformserver-config
mountPath: /etc/platformserver
ports:
- name: {{ template "platformserver.name" . }}
containerPort: {{ template "platformserver.port" . }}
resources:
{{ toYaml .Values.resources | indent 10 }}
{{- with .Values.global.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}

+ 15
- 1
deploy/charts/octopus/values.yaml View File

@@ -23,6 +23,7 @@ ingress:
enabled: true
adminserverPath: /adminserver
openaiserverPath: /openaiserver
platformserverPath: /platformserver
adminportalPath: /admin
openaiportalPath: /openai
loggerHttpdPath: /log
@@ -126,7 +127,20 @@ openaiserver:
redis:
username: ""
password: "abcde"

# platform-server
platformserver:
image:
pullPolicy: ""
address: ""
pathname: ""
name: "platform-server"
app:
logLevel: info
data:
redis:
username: ""
password: "abcde"

# admin-server
adminserver:


Loading…
Cancel
Save