From f730bd5b0c0b14077b0022e008dea83424cfa2e5 Mon Sep 17 00:00:00 2001 From: hhhhsc701 <56435672+hhhhsc701@users.noreply.github.com> Date: Mon, 1 Dec 2025 19:05:50 +0800 Subject: [PATCH] =?UTF-8?q?bugfix:=20=E6=94=AF=E6=8C=81=E4=BD=BF=E7=94=A8r?= =?UTF-8?q?untime=E5=8D=95=E5=AE=9E=E4=BE=8B=20(#118)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * bugfix: 支持使用runtime单实例 --- deployment/helm/datamate/Chart.yaml | 20 ++++ .../charts/backend/templates/_helpers.tpl | 1 + .../helm/datamate/charts/runtime/.helmignore | 23 ++++ .../helm/datamate/charts/runtime/Chart.yaml | 29 +++++ .../charts/runtime/templates/_helpers.tpl | 76 ++++++++++++ .../charts/runtime/templates/deployment.yaml | 86 ++++++++++++++ .../charts/runtime/templates/service.yaml | 15 +++ .../runtime/templates/serviceaccount.yaml | 13 +++ .../helm/datamate/charts/runtime/values.yaml | 108 ++++++++++++++++++ deployment/helm/datamate/values.yaml | 70 +++++++----- .../etcd/charts/common/templates/_images.tpl | 2 +- .../charts/etcd/templates/deployment.yaml | 3 +- .../charts/minio/templates/deployment.yaml | 6 +- deployment/helm/milvus/templates/_helpers.tpl | 10 ++ .../templates/standalone-deployment.yaml | 6 +- 15 files changed, 435 insertions(+), 33 deletions(-) create mode 100644 deployment/helm/datamate/charts/runtime/.helmignore create mode 100644 deployment/helm/datamate/charts/runtime/Chart.yaml create mode 100644 deployment/helm/datamate/charts/runtime/templates/_helpers.tpl create mode 100644 deployment/helm/datamate/charts/runtime/templates/deployment.yaml create mode 100644 deployment/helm/datamate/charts/runtime/templates/service.yaml create mode 100644 deployment/helm/datamate/charts/runtime/templates/serviceaccount.yaml create mode 100644 deployment/helm/datamate/charts/runtime/values.yaml diff --git a/deployment/helm/datamate/Chart.yaml b/deployment/helm/datamate/Chart.yaml index 63455f2..2c6d338 100644 --- a/deployment/helm/datamate/Chart.yaml +++ b/deployment/helm/datamate/Chart.yaml @@ -22,3 +22,23 @@ version: 0.0.1 # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. appVersion: "0.0.1" + +dependencies: + - name: backend + version: 0.0.1 + - name: frontend + version: 0.0.1 + - name: database + version: 0.0.1 + - name: backend-python + version: 0.0.1 + - name: kuberay-operator + version: 1.4.2 + condition: ray-cluster.enabled + - name: ray-cluster + version: 1.4.2 + condition: ray-cluster.enabled + - name: runtime + version: 0.0.1 + condition: runtime.enabled + diff --git a/deployment/helm/datamate/charts/backend/templates/_helpers.tpl b/deployment/helm/datamate/charts/backend/templates/_helpers.tpl index 29d49ad..3d59e85 100644 --- a/deployment/helm/datamate/charts/backend/templates/_helpers.tpl +++ b/deployment/helm/datamate/charts/backend/templates/_helpers.tpl @@ -35,6 +35,7 @@ Common labels */}} {{- define "backend.labels" -}} helm.sh/chart: {{ include "backend.chart" . }} +app: {{ .Release.Name }} {{ include "backend.selectorLabels" . }} {{- if .Chart.AppVersion }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} diff --git a/deployment/helm/datamate/charts/runtime/.helmignore b/deployment/helm/datamate/charts/runtime/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/deployment/helm/datamate/charts/runtime/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/deployment/helm/datamate/charts/runtime/Chart.yaml b/deployment/helm/datamate/charts/runtime/Chart.yaml new file mode 100644 index 0000000..3028bd8 --- /dev/null +++ b/deployment/helm/datamate/charts/runtime/Chart.yaml @@ -0,0 +1,29 @@ +apiVersion: v2 +name: runtime +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.0.1 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "0.0.1" + +dependencies: + - name: database + repository: file://../database + version: 0.0.1 diff --git a/deployment/helm/datamate/charts/runtime/templates/_helpers.tpl b/deployment/helm/datamate/charts/runtime/templates/_helpers.tpl new file mode 100644 index 0000000..3fe25be --- /dev/null +++ b/deployment/helm/datamate/charts/runtime/templates/_helpers.tpl @@ -0,0 +1,76 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "runtime.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "runtime.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "runtime.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "runtime.labels" -}} +helm.sh/chart: {{ include "runtime.chart" . }} +app: {{ .Release.Name }} +{{ include "runtime.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "runtime.selectorLabels" -}} +app.kubernetes.io/name: {{ include "runtime.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "runtime.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "runtime.fullname" .) .Values.serviceAccount.name -}} +{{- else }} +{{- default "default" .Values.serviceAccount.name -}} +{{- end }} +{{- end }} + +{{/* +Name of image +*/}} +{{- define "runtime.image" -}} +{{- $name := default .Values.image.repository .Values.global.image.runtime.name }} +{{- $tag := default .Values.image.tag .Values.global.image.runtime.tag }} +{{- if .Values.global.image.repository }} +{{- .Values.global.image.repository | trimSuffix "/" }}/{{ $name }}:{{ $tag }} +{{- else }} +{{- $name }}:{{ $tag }} +{{- end }} +{{- end }} diff --git a/deployment/helm/datamate/charts/runtime/templates/deployment.yaml b/deployment/helm/datamate/charts/runtime/templates/deployment.yaml new file mode 100644 index 0000000..93384c7 --- /dev/null +++ b/deployment/helm/datamate/charts/runtime/templates/deployment.yaml @@ -0,0 +1,86 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "runtime.fullname" . }} + labels: + {{- include "runtime.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "runtime.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "runtime.labels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "runtime.serviceAccountName" . }} + {{- with .Values.podSecurityContext }} + securityContext: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: {{ .Chart.Name }} + {{- with .Values.args }} + args: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.securityContext }} + securityContext: + {{- toYaml . | nindent 12 }} + {{- end }} + image: "{{ include "runtime.image" . }}" + imagePullPolicy: {{ default .Values.image.pullPolicy .Values.global.image.pullPolicy }} + ports: + - name: http + containerPort: {{ .Values.service.port }} + protocol: TCP + {{- with .Values.livenessProbe }} + livenessProbe: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.readinessProbe }} + readinessProbe: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.resources }} + resources: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.env }} + env: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.volumeMounts }} + volumeMounts: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.volumes }} + volumes: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/deployment/helm/datamate/charts/runtime/templates/service.yaml b/deployment/helm/datamate/charts/runtime/templates/service.yaml new file mode 100644 index 0000000..869295a --- /dev/null +++ b/deployment/helm/datamate/charts/runtime/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "runtime.fullname" . }} + labels: + {{- include "runtime.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: {{ .Values.service.port }} + protocol: TCP + name: {{ .Chart.Name }} + selector: + {{- include "runtime.selectorLabels" . | nindent 4 }} diff --git a/deployment/helm/datamate/charts/runtime/templates/serviceaccount.yaml b/deployment/helm/datamate/charts/runtime/templates/serviceaccount.yaml new file mode 100644 index 0000000..614d826 --- /dev/null +++ b/deployment/helm/datamate/charts/runtime/templates/serviceaccount.yaml @@ -0,0 +1,13 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "runtime.serviceAccountName" . }} + labels: + {{- include "runtime.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +automountServiceAccountToken: {{ .Values.serviceAccount.automount }} +{{- end }} diff --git a/deployment/helm/datamate/charts/runtime/values.yaml b/deployment/helm/datamate/charts/runtime/values.yaml new file mode 100644 index 0000000..f4ec195 --- /dev/null +++ b/deployment/helm/datamate/charts/runtime/values.yaml @@ -0,0 +1,108 @@ +# Default values for datamate. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +# This will set the replicaset count more information can be found here: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/ +replicaCount: 1 + +# This sets the container image more information can be found here: https://kubernetes.io/docs/concepts/containers/images/ +image: + repository: "datamate-runtime" + # This sets the pull policy for images. + pullPolicy: "IfNotPresent" + # Overrides the image tag whose default is the chart appVersion. + tag: "latest" + +# This is for the secrets for pulling an image from a private repository more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ +imagePullSecrets: [] +# This is to override the chart name. +nameOverride: "datamate-runtime" +fullnameOverride: "datamate-runtime" + +env: [] + +# This section builds out the service account more information can be found here: https://kubernetes.io/docs/concepts/security/service-accounts/ +serviceAccount: + # Specifies whether a service account should be created + create: true + # Automatically mount a ServiceAccount's API credentials? + automount: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +# This is for setting Kubernetes Annotations to a Pod. +# For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/ +podAnnotations: {} +# This is for setting Kubernetes Labels to a Pod. +# For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ +podLabels: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +# This is for setting up a service more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/ +service: + # This sets the service type more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types + type: ClusterIP + # This sets the ports more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#field-spec-ports + port: 8081 + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +# This is to setup the liveness and readiness probes more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/ +# livenessProbe: +# httpGet: +# path: / +# port: http +# readinessProbe: +# httpGet: +# path: / +# port: http + +# This section is for setting up autoscaling more information can be found here: https://kubernetes.io/docs/concepts/workloads/autoscaling/ +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +# Additional volumes on the output Deployment definition. +volumes: [] +# - name: foo +# secret: +# secretName: mysecret +# optional: false + +# Additional volumeMounts on the output Deployment definition. +volumeMounts: [] +# - name: foo +# mountPath: "/etc/foo" +# readOnly: true + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/deployment/helm/datamate/values.yaml b/deployment/helm/datamate/values.yaml index 5bd2849..1657a0a 100644 --- a/deployment/helm/datamate/values.yaml +++ b/deployment/helm/datamate/values.yaml @@ -112,7 +112,45 @@ frontend: name: datamate-nginx-conf subPath: backend.conf +runtime: + enabled: false + args: &runtimeArgs + - python + - /opt/runtime/datamate/operator_runtime.py + - --port + - "8081" + env: &runtimeEnv + - name: MYSQL_HOST + value: "datamate-database" + - name: MYSQL_PORT + value: "3306" + - name: MYSQL_USER + value: "root" + - name: MYSQL_PASSWORD + value: *dbPass + - name: MYSQL_DATABASE + value: "datamate" + volumes: + - *datasetVolume + - *flowVolume + - *logVolume + - *operatorVolume + volumeMounts: &runtimeVolumeMounts + - mountPath: /tmp/ray + name: log-volume + subPath: ray/head + - mountPath: /var/log/datamate + name: log-volume + - mountPath: /dataset + name: dataset-volume + - mountPath: /flow + name: flow-volume + - mountPath: /opt/runtime/datamate/ops/user + name: operator-volume + subPath: extract + ray-cluster: + enabled: true head: volumes: - *datasetVolume @@ -134,37 +172,11 @@ ray-cluster: - name: runtime image: datamate-runtime imagePullPolicy: IfNotPresent - args: - - python - - /opt/runtime/datamate/operator_runtime.py - - --port - - "8081" - env: - - name: MYSQL_HOST - value: "datamate-database" - - name: MYSQL_PORT - value: "3306" - - name: MYSQL_USER - value: "root" - - name: MYSQL_PASSWORD - value: "password" - - name: MYSQL_DATABASE - value: "datamate" + args: *runtimeArgs + env: *runtimeEnv ports: - containerPort: 8081 - volumeMounts: - - mountPath: /tmp/ray - name: log-volume - subPath: ray/head - - mountPath: /var/log/datamate - name: log-volume - - mountPath: /dataset - name: dataset-volume - - mountPath: /flow - name: flow-volume - - mountPath: /opt/runtime/datamate/ops/user - name: operator-volume - subPath: extract + volumeMounts: *runtimeVolumeMounts worker: volumes: - *datasetVolume diff --git a/deployment/helm/milvus/charts/etcd/charts/common/templates/_images.tpl b/deployment/helm/milvus/charts/etcd/charts/common/templates/_images.tpl index d60c22e..bd1f6c5 100644 --- a/deployment/helm/milvus/charts/etcd/charts/common/templates/_images.tpl +++ b/deployment/helm/milvus/charts/etcd/charts/common/templates/_images.tpl @@ -18,7 +18,7 @@ Return the proper image name {{- $termination = .imageRoot.digest | toString -}} {{- end -}} {{- if $registryName }} - {{- printf "%s/%s%s%s" $registryName $repositoryName $separator $termination -}} + {{- printf "%s/%s%s%s" ($registryName | trimSuffix "/") $repositoryName $separator $termination -}} {{- else -}} {{- printf "%s%s%s" $repositoryName $separator $termination -}} {{- end -}} diff --git a/deployment/helm/milvus/charts/etcd/templates/deployment.yaml b/deployment/helm/milvus/charts/etcd/templates/deployment.yaml index 42aaff9..4a6af18 100644 --- a/deployment/helm/milvus/charts/etcd/templates/deployment.yaml +++ b/deployment/helm/milvus/charts/etcd/templates/deployment.yaml @@ -15,7 +15,8 @@ spec: replicas: {{ .Values.replicaCount }} selector: matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }} - strategy: {{- include "common.tplvalues.render" (dict "value" .Values.updateStrategy "context" $ ) | nindent 4 }} + strategy: + type: Recreate template: metadata: labels: {{- include "common.labels.standard" . | nindent 8 }} diff --git a/deployment/helm/milvus/charts/minio/templates/deployment.yaml b/deployment/helm/milvus/charts/minio/templates/deployment.yaml index b8e8ad5..3660672 100644 --- a/deployment/helm/milvus/charts/minio/templates/deployment.yaml +++ b/deployment/helm/milvus/charts/minio/templates/deployment.yaml @@ -72,7 +72,11 @@ spec: {{- end }} containers: - name: {{ .Chart.Name }} - image: "{{ .Values.global.imageRegistry }}{{ .Values.image.repository }}:{{ .Values.image.tag }}" + {{- if .Values.global.imageRegistry }} + image: "{{ .Values.global.imageRegistry | trimSuffix "/" }}/{{ .Values.image.repository }}:{{ .Values.image.tag }}" + {{- else }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + {{- end }} imagePullPolicy: {{ .Values.image.pullPolicy }} {{- if .Values.s3gateway.enabled }} command: diff --git a/deployment/helm/milvus/templates/_helpers.tpl b/deployment/helm/milvus/templates/_helpers.tpl index 01a665e..7e042ca 100644 --- a/deployment/helm/milvus/templates/_helpers.tpl +++ b/deployment/helm/milvus/templates/_helpers.tpl @@ -246,3 +246,13 @@ false {{- end -}} {{- end -}} {{- end -}} + +{{- define "runtime.image" -}} +{{- $name := default .Values.image.repository .Values.global.image.runtime.name }} +{{- $tag := default .Values.image.tag .Values.global.image.runtime.tag }} +{{- if .Values.global.image.repository }} +{{- .Values.global.image.repository | trimSuffix "/" }}/{{ $name }}:{{ $tag }} +{{- else }} +{{- $name }}:{{ $tag }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/deployment/helm/milvus/templates/standalone-deployment.yaml b/deployment/helm/milvus/templates/standalone-deployment.yaml index 4109457..e4e176d 100644 --- a/deployment/helm/milvus/templates/standalone-deployment.yaml +++ b/deployment/helm/milvus/templates/standalone-deployment.yaml @@ -49,7 +49,7 @@ spec: - /bin/bash - -c - "cp -r /opt/heaptrack /milvus/tools" - image: "{{ .Values.heaptrack.image.repository }}:{{ .Values.heaptrack.image.tag }}" + image: "{{ .Values.global.imageRegistry | trimSuffix "/" }}/{{ .Values.heaptrack.image.repository }}:{{ .Values.heaptrack.image.tag }}" imagePullPolicy: {{ .Values.heaptrack.image.pullPolicy }} {{ if and (.Values.containerSecurityContext) (not .Values.standalone.containerSecurityContext) }} securityContext: @@ -65,7 +65,11 @@ spec: {{- end }} containers: - name: standalone + {{- if .Values.global.imageRegistry }} + image: "{{ .Values.global.imageRegistry | trimSuffix "/" }}/{{ .Values.image.all.repository }}:{{ .Values.image.all.tag }}" + {{- else }} image: "{{ .Values.image.all.repository }}:{{ .Values.image.all.tag }}" + {{- end }} imagePullPolicy: {{ .Values.image.all.pullPolicy }} {{ if and (.Values.containerSecurityContext) (not .Values.standalone.containerSecurityContext) }} securityContext: