Skip to content

Commit a295f6d

Browse files
committed
feature: add gateway
1 parent 2c5b05b commit a295f6d

File tree

11 files changed

+357
-42
lines changed

11 files changed

+357
-42
lines changed

deployment/helm/datamate/charts/frontend/templates/configmap.yaml

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,6 @@ data:
1616
1717
add_header Set-Cookie "NEXT_LOCALE=zh";
1818
19-
location /api/synthesis/ {
20-
proxy_pass http://datamate-backend-python:18000/api/synthesis/;
21-
proxy_set_header Host $host;
22-
proxy_set_header X-Real-IP $remote_addr;
23-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
24-
}
25-
26-
location /api/evaluation/ {
27-
proxy_pass http://datamate-backend-python:18000/api/evaluation/;
28-
proxy_set_header Host $host;
29-
proxy_set_header X-Real-IP $remote_addr;
30-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
31-
}
32-
33-
location /api/annotation/ {
34-
proxy_pass http://datamate-backend-python:18000/api/annotation/;
35-
proxy_set_header Host $host;
36-
proxy_set_header X-Real-IP $remote_addr;
37-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
38-
}
39-
4019
location /api/ {
4120
proxy_pass http://datamate-backend:8080/api/;
4221
proxy_set_header Host $host;
@@ -91,27 +70,6 @@ data:
9170
9271
client_max_body_size 1024M;
9372
94-
location /api/synthesis/ {
95-
proxy_pass http://datamate-backend-python:18000/api/synthesis/;
96-
proxy_set_header Host $host;
97-
proxy_set_header X-Real-IP $remote_addr;
98-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
99-
}
100-
101-
location /api/evaluation/ {
102-
proxy_pass http://datamate-backend-python:18000/api/evaluation/;
103-
proxy_set_header Host $host;
104-
proxy_set_header X-Real-IP $remote_addr;
105-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
106-
}
107-
108-
location /api/annotation/ {
109-
proxy_pass http://datamate-backend-python:18000/api/annotation/;
110-
proxy_set_header Host $host;
111-
proxy_set_header X-Real-IP $remote_addr;
112-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
113-
}
114-
11573
location /api/ {
11674
proxy_pass http://datamate-backend:8080/api/;
11775
proxy_set_header Host $host;
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: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v2
2+
name: gateway
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"
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 "gateway.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 "gateway.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 "gateway.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "gateway.labels" -}}
37+
helm.sh/chart: {{ include "gateway.chart" . }}
38+
app: {{ .Release.Name }}
39+
{{ include "gateway.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 "gateway.selectorLabels" -}}
50+
app.kubernetes.io/name: {{ include "gateway.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 "gateway.serviceAccountName" -}}
58+
{{- if .Values.serviceAccount.create }}
59+
{{- default (include "gateway.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 "gateway.image" -}}
69+
{{- $name := default .Values.image.repository .Values.global.image.gateway.name }}
70+
{{- $tag := default .Values.image.tag .Values.global.image.gateway.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: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "gateway.fullname" . }}
5+
labels:
6+
{{- include "gateway.labels" . | nindent 4 }}
7+
spec:
8+
{{- if not .Values.autoscaling.enabled }}
9+
replicas: {{ .Values.replicaCount }}
10+
{{- end }}
11+
selector:
12+
matchLabels:
13+
{{- include "gateway.selectorLabels" . | nindent 6 }}
14+
template:
15+
metadata:
16+
{{- with .Values.podAnnotations }}
17+
annotations:
18+
{{- toYaml . | nindent 8 }}
19+
{{- end }}
20+
labels:
21+
{{- include "gateway.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 "gateway.serviceAccountName" . }}
31+
{{- with .Values.podSecurityContext }}
32+
securityContext:
33+
{{- toYaml . | nindent 8 }}
34+
{{- end }}
35+
containers:
36+
- name: {{ .Chart.Name }}
37+
{{- with .Values.securityContext }}
38+
securityContext:
39+
{{- toYaml . | nindent 12 }}
40+
{{- end }}
41+
image: "{{ include "gateway.image" . }}"
42+
imagePullPolicy: {{ default .Values.image.pullPolicy .Values.global.image.pullPolicy }}
43+
ports:
44+
- name: http
45+
containerPort: {{ .Values.service.port }}
46+
protocol: TCP
47+
{{- with .Values.livenessProbe }}
48+
livenessProbe:
49+
{{- toYaml . | nindent 12 }}
50+
{{- end }}
51+
{{- with .Values.readinessProbe }}
52+
readinessProbe:
53+
{{- toYaml . | nindent 12 }}
54+
{{- end }}
55+
{{- with .Values.resources }}
56+
resources:
57+
{{- toYaml . | nindent 12 }}
58+
{{- end }}
59+
{{- with .Values.env }}
60+
env:
61+
{{- toYaml . | nindent 12 }}
62+
{{- end }}
63+
{{- with .Values.volumeMounts }}
64+
volumeMounts:
65+
{{- toYaml . | nindent 12 }}
66+
{{- end }}
67+
{{- with .Values.volumes }}
68+
volumes:
69+
{{- toYaml . | nindent 8 }}
70+
{{- end }}
71+
{{- with .Values.nodeSelector }}
72+
nodeSelector:
73+
{{- toYaml . | nindent 8 }}
74+
{{- end }}
75+
{{- with .Values.affinity }}
76+
affinity:
77+
{{- toYaml . | nindent 8 }}
78+
{{- end }}
79+
{{- with .Values.tolerations }}
80+
tolerations:
81+
{{- toYaml . | nindent 8 }}
82+
{{- 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 "gateway.fullname" . }}
5+
labels:
6+
{{- include "gateway.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 "gateway.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 "gateway.serviceAccountName" . }}
6+
labels:
7+
{{- include "gateway.labels" . | nindent 4 }}
8+
{{- with .Values.serviceAccount.annotations }}
9+
annotations:
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
12+
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
13+
{{- end }}

0 commit comments

Comments
 (0)