Skip to content

Commit f730bd5

Browse files
authored
bugfix: 支持使用runtime单实例 (#118)
* bugfix: 支持使用runtime单实例
1 parent bb33452 commit f730bd5

File tree

15 files changed

+435
-33
lines changed

15 files changed

+435
-33
lines changed

deployment/helm/datamate/Chart.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,23 @@ version: 0.0.1
2222
# follow Semantic Versioning. They should reflect the version the application is using.
2323
# It is recommended to use it with quotes.
2424
appVersion: "0.0.1"
25+
26+
dependencies:
27+
- name: backend
28+
version: 0.0.1
29+
- name: frontend
30+
version: 0.0.1
31+
- name: database
32+
version: 0.0.1
33+
- name: backend-python
34+
version: 0.0.1
35+
- name: kuberay-operator
36+
version: 1.4.2
37+
condition: ray-cluster.enabled
38+
- name: ray-cluster
39+
version: 1.4.2
40+
condition: ray-cluster.enabled
41+
- name: runtime
42+
version: 0.0.1
43+
condition: runtime.enabled
44+

deployment/helm/datamate/charts/backend/templates/_helpers.tpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Common labels
3535
*/}}
3636
{{- define "backend.labels" -}}
3737
helm.sh/chart: {{ include "backend.chart" . }}
38+
app: {{ .Release.Name }}
3839
{{ include "backend.selectorLabels" . }}
3940
{{- if .Chart.AppVersion }}
4041
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
apiVersion: v2
2+
name: runtime
3+
description: A Helm chart for Kubernetes
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: 0.0.1
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application. Versions are not expected to
22+
# follow Semantic Versioning. They should reflect the version the application is using.
23+
# It is recommended to use it with quotes.
24+
appVersion: "0.0.1"
25+
26+
dependencies:
27+
- name: database
28+
repository: file://../database
29+
version: 0.0.1
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "runtime.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "runtime.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "runtime.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "runtime.labels" -}}
37+
helm.sh/chart: {{ include "runtime.chart" . }}
38+
app: {{ .Release.Name }}
39+
{{ include "runtime.selectorLabels" . }}
40+
{{- if .Chart.AppVersion }}
41+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
42+
{{- end }}
43+
app.kubernetes.io/managed-by: {{ .Release.Service }}
44+
{{- end }}
45+
46+
{{/*
47+
Selector labels
48+
*/}}
49+
{{- define "runtime.selectorLabels" -}}
50+
app.kubernetes.io/name: {{ include "runtime.name" . }}
51+
app.kubernetes.io/instance: {{ .Release.Name }}
52+
{{- end }}
53+
54+
{{/*
55+
Create the name of the service account to use
56+
*/}}
57+
{{- define "runtime.serviceAccountName" -}}
58+
{{- if .Values.serviceAccount.create }}
59+
{{- default (include "runtime.fullname" .) .Values.serviceAccount.name -}}
60+
{{- else }}
61+
{{- default "default" .Values.serviceAccount.name -}}
62+
{{- end }}
63+
{{- end }}
64+
65+
{{/*
66+
Name of image
67+
*/}}
68+
{{- define "runtime.image" -}}
69+
{{- $name := default .Values.image.repository .Values.global.image.runtime.name }}
70+
{{- $tag := default .Values.image.tag .Values.global.image.runtime.tag }}
71+
{{- if .Values.global.image.repository }}
72+
{{- .Values.global.image.repository | trimSuffix "/" }}/{{ $name }}:{{ $tag }}
73+
{{- else }}
74+
{{- $name }}:{{ $tag }}
75+
{{- end }}
76+
{{- end }}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "runtime.fullname" . }}
5+
labels:
6+
{{- include "runtime.labels" . | nindent 4 }}
7+
spec:
8+
{{- if not .Values.autoscaling.enabled }}
9+
replicas: {{ .Values.replicaCount }}
10+
{{- end }}
11+
selector:
12+
matchLabels:
13+
{{- include "runtime.selectorLabels" . | nindent 6 }}
14+
template:
15+
metadata:
16+
{{- with .Values.podAnnotations }}
17+
annotations:
18+
{{- toYaml . | nindent 8 }}
19+
{{- end }}
20+
labels:
21+
{{- include "runtime.labels" . | nindent 8 }}
22+
{{- with .Values.podLabels }}
23+
{{- toYaml . | nindent 8 }}
24+
{{- end }}
25+
spec:
26+
{{- with .Values.imagePullSecrets }}
27+
imagePullSecrets:
28+
{{- toYaml . | nindent 8 }}
29+
{{- end }}
30+
serviceAccountName: {{ include "runtime.serviceAccountName" . }}
31+
{{- with .Values.podSecurityContext }}
32+
securityContext:
33+
{{- toYaml . | nindent 8 }}
34+
{{- end }}
35+
containers:
36+
- name: {{ .Chart.Name }}
37+
{{- with .Values.args }}
38+
args:
39+
{{- toYaml . | nindent 12 }}
40+
{{- end }}
41+
{{- with .Values.securityContext }}
42+
securityContext:
43+
{{- toYaml . | nindent 12 }}
44+
{{- end }}
45+
image: "{{ include "runtime.image" . }}"
46+
imagePullPolicy: {{ default .Values.image.pullPolicy .Values.global.image.pullPolicy }}
47+
ports:
48+
- name: http
49+
containerPort: {{ .Values.service.port }}
50+
protocol: TCP
51+
{{- with .Values.livenessProbe }}
52+
livenessProbe:
53+
{{- toYaml . | nindent 12 }}
54+
{{- end }}
55+
{{- with .Values.readinessProbe }}
56+
readinessProbe:
57+
{{- toYaml . | nindent 12 }}
58+
{{- end }}
59+
{{- with .Values.resources }}
60+
resources:
61+
{{- toYaml . | nindent 12 }}
62+
{{- end }}
63+
{{- with .Values.env }}
64+
env:
65+
{{- toYaml . | nindent 12 }}
66+
{{- end }}
67+
{{- with .Values.volumeMounts }}
68+
volumeMounts:
69+
{{- toYaml . | nindent 12 }}
70+
{{- end }}
71+
{{- with .Values.volumes }}
72+
volumes:
73+
{{- toYaml . | nindent 8 }}
74+
{{- end }}
75+
{{- with .Values.nodeSelector }}
76+
nodeSelector:
77+
{{- toYaml . | nindent 8 }}
78+
{{- end }}
79+
{{- with .Values.affinity }}
80+
affinity:
81+
{{- toYaml . | nindent 8 }}
82+
{{- end }}
83+
{{- with .Values.tolerations }}
84+
tolerations:
85+
{{- toYaml . | nindent 8 }}
86+
{{- end }}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ include "runtime.fullname" . }}
5+
labels:
6+
{{- include "runtime.labels" . | nindent 4 }}
7+
spec:
8+
type: {{ .Values.service.type }}
9+
ports:
10+
- port: {{ .Values.service.port }}
11+
targetPort: {{ .Values.service.port }}
12+
protocol: TCP
13+
name: {{ .Chart.Name }}
14+
selector:
15+
{{- include "runtime.selectorLabels" . | nindent 4 }}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{{- if .Values.serviceAccount.create -}}
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: {{ include "runtime.serviceAccountName" . }}
6+
labels:
7+
{{- include "runtime.labels" . | nindent 4 }}
8+
{{- with .Values.serviceAccount.annotations }}
9+
annotations:
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
12+
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
13+
{{- end }}
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Default values for datamate.
2+
# This is a YAML-formatted file.
3+
# Declare variables to be passed into your templates.
4+
5+
# This will set the replicaset count more information can be found here: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/
6+
replicaCount: 1
7+
8+
# This sets the container image more information can be found here: https://kubernetes.io/docs/concepts/containers/images/
9+
image:
10+
repository: "datamate-runtime"
11+
# This sets the pull policy for images.
12+
pullPolicy: "IfNotPresent"
13+
# Overrides the image tag whose default is the chart appVersion.
14+
tag: "latest"
15+
16+
# 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/
17+
imagePullSecrets: []
18+
# This is to override the chart name.
19+
nameOverride: "datamate-runtime"
20+
fullnameOverride: "datamate-runtime"
21+
22+
env: []
23+
24+
# This section builds out the service account more information can be found here: https://kubernetes.io/docs/concepts/security/service-accounts/
25+
serviceAccount:
26+
# Specifies whether a service account should be created
27+
create: true
28+
# Automatically mount a ServiceAccount's API credentials?
29+
automount: true
30+
# Annotations to add to the service account
31+
annotations: {}
32+
# The name of the service account to use.
33+
# If not set and create is true, a name is generated using the fullname template
34+
name: ""
35+
36+
# This is for setting Kubernetes Annotations to a Pod.
37+
# For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/
38+
podAnnotations: {}
39+
# This is for setting Kubernetes Labels to a Pod.
40+
# For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/
41+
podLabels: {}
42+
43+
podSecurityContext: {}
44+
# fsGroup: 2000
45+
46+
securityContext: {}
47+
# capabilities:
48+
# drop:
49+
# - ALL
50+
# readOnlyRootFilesystem: true
51+
# runAsNonRoot: true
52+
# runAsUser: 1000
53+
54+
# This is for setting up a service more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/
55+
service:
56+
# This sets the service type more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types
57+
type: ClusterIP
58+
# This sets the ports more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#field-spec-ports
59+
port: 8081
60+
61+
resources: {}
62+
# We usually recommend not to specify default resources and to leave this as a conscious
63+
# choice for the user. This also increases chances charts run on environments with little
64+
# resources, such as Minikube. If you do want to specify resources, uncomment the following
65+
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
66+
# limits:
67+
# cpu: 100m
68+
# memory: 128Mi
69+
# requests:
70+
# cpu: 100m
71+
# memory: 128Mi
72+
73+
# 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/
74+
# livenessProbe:
75+
# httpGet:
76+
# path: /
77+
# port: http
78+
# readinessProbe:
79+
# httpGet:
80+
# path: /
81+
# port: http
82+
83+
# This section is for setting up autoscaling more information can be found here: https://kubernetes.io/docs/concepts/workloads/autoscaling/
84+
autoscaling:
85+
enabled: false
86+
minReplicas: 1
87+
maxReplicas: 100
88+
targetCPUUtilizationPercentage: 80
89+
# targetMemoryUtilizationPercentage: 80
90+
91+
# Additional volumes on the output Deployment definition.
92+
volumes: []
93+
# - name: foo
94+
# secret:
95+
# secretName: mysecret
96+
# optional: false
97+
98+
# Additional volumeMounts on the output Deployment definition.
99+
volumeMounts: []
100+
# - name: foo
101+
# mountPath: "/etc/foo"
102+
# readOnly: true
103+
104+
nodeSelector: {}
105+
106+
tolerations: []
107+
108+
affinity: {}

0 commit comments

Comments
 (0)